Changeset bc02e89


Ignore:
Timestamp:
05/23/11 21:14:49 (4 years ago)
Author:
xkolman2 <xkolman2@…>
Branches:
master
Children:
f8d618c
Parents:
123c06c
git-author:
xkolman2 <xkolman2@…> (05/23/11 21:14:49)
git-committer:
xkolman2 <xkolman2@…> (05/23/11 21:14:49)
Message:

add togglable debugging info to tile loading function
redraw screen when new tiles are available

git-svn-id: https://nlp.fi.muni.cz/svn/gps_navigace/trunk@384 0858a4d0-ffff-46e5-938e-62b5ecb34222

Location:
modules
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • modules/mod_mapTiles.py

    r123c06c rbc02e89  
    223223          print "exception in tile download manager thread:\n%s" % e 
    224224 
    225   def startTileLoadingThread(self): 
    226     """start the loading-request consumer thread""" 
    227     t = Thread(target=self.tileLoader, name='tile loading thread') 
    228     t.setDaemon(True) # we need that the worker dies with the program 
    229     t.start() 
     225#  def startTileLoadingThread(self): 
     226#    """start the loading-request consumer thread""" 
     227#    t = Thread(target=self.tileLoader, name='tile loading thread') 
     228#    t.setDaemon(True) # we need that the worker dies with the program 
     229#    t.start() 
    230230 
    231231#  def tileLoader(self): 
     
    642642    # Return the cairo projection to what it was 
    643643    cr.restore() 
    644      
     644 
     645  def _fakePrint(self, text): 
     646    """print that does nothing""" 
     647    pass 
     648 
     649  def _realPrint(self,text): 
     650    print(text) 
     651 
    645652  def loadImage(self,name , x, y, z, layer): 
    646653    """Check that an image is loaded, and try to load it if not""" 
     
    648655    """at this point, there is only a placeholder image in the memmory cache""" 
    649656 
     657    # check if tile loading debugging is on 
     658    debug = self.get('tileLoadingDebug', False) 
     659    if debug: 
     660      sprint = self._realPrint 
     661    else: 
     662      sprint = self._fakePrint 
     663 
     664    sprint("###") 
     665    sprint("loading tile %s" % name) 
     666 
    650667    # first, is it already in the process of being downloaded? 
    651668    with self.threadlListCondition: 
    652669      if name in self.threads.keys(): 
     670        sprint("tile is being downloaded") 
    653671        if(not self.threads[name].finished): 
    654672          with self.imagesLock: # substitute the "loading" tile with a "downloading" tile 
     
    663681    layerInfo = maplayers.get(layer, None) 
    664682    if(layerInfo == None): # is the layer info valid 
     683      sprint("invalid layer") 
    665684      return('NOK') 
    666685 
     
    670689    storeTiles = self.m.get('storeTiles', None) # get the tile storage module 
    671690    if storeTiles: 
     691      start1 = time.clock() 
    672692      pixbuf = storeTiles.getTile(layerPrefix, z, x, y, layerType) 
    673693      """None from getTiles means the tile was not found 
    674694         False means loading the tile from file to pixbuf failed""" 
    675695      if pixbuf: 
     696        start2 = time.clock() 
    676697        self.storeInMemmory(self.pixbufToCairoImageSurface(pixbuf), name) 
     698        if debug: 
     699          storageType = self.get('tileStorageType', 'files') 
     700          sprint("tile loaded from local storage (%s) in %1.2f ms" % (storageType,(1000 * (time.clock() - start1)))) 
     701          sprint("tile cached in memmory in %1.2f ms" % (1000 * (time.clock() - start2))) 
    677702        return('OK') 
    678703 
     704 
     705    # Image not found anywhere locally - resort to downloading it 
    679706    filename = self.getTileFolderPath() + (self.getImagePath(x,y,z,layerPrefix, layerType)) 
    680  
    681     # Image not found anywhere locally - resort to downloading it 
     707    sprint("image not found locally - trying to download") 
    682708 
    683709    # Are we allowed to download it ? (network=='full') 
    684710    if(self.get('network','full')=='full'): 
     711      sprint("automatic tile download enabled - starting download") 
    685712      # use threads 
    686713      """the thread list condition is used to signalize to the download manager, 
     
    700727 
    701728        self.threadlListCondition.notifyAll() # wake up the download manager 
     729    else: 
     730      sprint("automatic tile download disabled - not starting download") 
    702731 
    703732  def loadImageFromFile(self,path,name, type="normal", expireTimestamp=None, dictIndex=0): 
     
    746775      if len(self.images[0]) > self.maxImagesInMemmory: 
    747776        self.trimCache() 
     777      # new tile available, make redraw request TODO: what overhead does this create ? 
     778      if self.get('tileLoadedRedraw', True): 
     779        self.set('needRedraw', True) 
    748780 
    749781  def trimCache(self): 
  • modules/mod_options.py

    r6837014 rbc02e89  
    524524    group = addGroup("Tiles", "tiles", catDebug, "generic") 
    525525    addBoolOpt("Print tile cache status to terminal", "reportTileCachStatus", group, False) 
     526    addBoolOpt("Tile loading status to terminal", "tileLoadingDebug", group, False) 
     527    addBoolOpt("Redraw screen once a new tile is loaded", "tileLoadedRedraw", group, True) 
    526528    addBoolOpt("Remove dups berofe batch dl", "checkTiles", group, False) 
    527529    # ** tracklog drawing 
Note: See TracChangeset for help on using the changeset viewer.