Changeset 2f5d3e6


Ignore:
Timestamp:
03/25/12 12:38:19 (2 years ago)
Author:
xkolman2 <xkolman2@…>
Branches:
master
Children:
2d03273
Parents:
25f2707
git-author:
xkolman2 <xkolman2@…> (03/25/12 12:38:19)
git-committer:
xkolman2 <xkolman2@…> (03/25/12 12:38:19)
Message:

fix typos

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • modules/mod_mapData.py

    r7d1b4b7 r2f5d3e6  
    9393  def checkTiles(self, tilesToDownload): 
    9494    """ 
    95     Get tiles that need to be downloaded and look if we dont already have some of these tiles, 
    96     then generate a set of ('url','filename') touples and send them to the threaded downloader 
     95    Get tiles that need to be downloaded and look if we don't already have some of these tiles, 
     96    then generate a set of ('url','filename') tuples and send them to the threaded downloader 
    9797    """ 
    9898    print "Checking if there are duplicated tiles" 
     
    103103      return [] 
    104104    layer = self.get('layer', None) # TODO: manual layer setting 
    105     maplayers = self.modrana.getMapLayers() # a dictionary describing supported maplayers 
     105    maplayers = self.modrana.getMapLayers() # a dictionary describing supported map layers 
    106106    extension = maplayers[layer]['type'] # what is the extension for the current layer ? 
    107107    folderPrefix = maplayers[layer]['folderPrefix'] # what is the extension for the current layer ? 
     
    114114      (z,x,y) = (tile[2],tile[0],tile[1]) 
    115115      filePath = tileFolder + mapTiles.getImagePath(x, y, z, folderPrefix, extension) 
    116       if not os.path.exists(filePath): # we dont have this file 
     116      if not os.path.exists(filePath): # we don't have this file 
    117117        neededTiles.append(tile) 
    118118 
     
    125125    mapTiles = self.m.get('mapTiles', None) 
    126126    tileFolder = self._getTileFolderPath() # where should we store the downloaded tiles 
    127     maplayers = self.modrana.getMapLayers() # a distionary describing supported maplayers 
     127    maplayers = self.modrana.getMapLayers() # a dictionary describing supported map layers 
    128128    extension = maplayers[layer]['type'] # what is the extension for the current layer ? 
    129129    folderPrefix = maplayers[layer]['folderPrefix'] # what is the extension for the current layer ? 
     
    135135  def addToQueue(self, neededTiles): 
    136136    """load urls and filenames to download queue, 
    137        optionaly check for duplicates 
     137       optionally check for duplicates 
    138138    """ 
    139139 
     
    144144    if check: 
    145145      neededTiles = self.checkTiles(neededTiles) 
    146     with self.dlListLock: # make sure the set of needed tiles is acessed in an atomic way 
     146    with self.dlListLock: # make sure the set of needed tiles is accessed in an atomic way 
    147147      self.currentDownloadList = neededTiles # load the files to the download queue variable 
    148148 
    149149  def getTileUrl(self,x,y,z,layer): 
    150       """Return url for given tile coorindates and layer""" 
     150      """Return url for given tile coordinates and layer""" 
    151151      mapTiles = self.m.get('mapTiles', None) 
    152152      if mapTiles: 
     
    176176      location = self.get("downloadArea", "here") # here or route 
    177177 
    178       z = self.get('z', 15) # this is the currewnt zoomlevel as show on the map screen 
     178      z = self.get('z', 15) # this is the current zoomlevel as show on the map screen 
    179179      minZ = z - int(self.get('zoomUpSize', 0)) # how many zoomlevels up (from current zoomelevel) should we download ? 
    180180      if minZ < 0: 
     
    201201         are of 40km*40km, instead of the requested 10km 
    202202         therefore, zoom level 15 is used as the minimum number for splitting tiles down 
    203          when the maximum zoomlevel from the range requested is less than 15, we dont split at all""" 
     203         when the maximum zoomlevel from the range requested is less than 15, we don't split at all""" 
    204204      if midZ < 15 and maxZ < 15: 
    205205        midZ = maxZ 
     
    225225        loadTl = self.m.get('loadTracklogs', None) # get the tracklog module 
    226226        GPXTracklog = loadTl.getActiveTracklog() 
    227         """because we dont need all the information in the original list and 
     227        """because we don't need all the information in the original list and 
    228228        also might need to add interpolated points, we make a local copy of 
    229229        the original list""" 
     
    286286      """ 
    287287      2.Oct.2010 2:41 :D 
    288       after a lot of effort spent, I still can't get threaded download to realiably 
    289       work with sqlite sotrage without getting stuck 
     288      after a lot of effort spent, I still can't get threaded download to reliably 
     289      work with sqlite storage without getting stuck 
    290290      this currently happens only on the N900, not on PC (or I was simply not able to to reproduce it) 
    291       therefore, when on N900 with sqlite tile storage, use only simple singlethreaded download 
     291      therefore, when on N900 with sqlite tile storage, use only simple single-threaded download 
    292292      """ 
    293293#      if self.device=='n900': 
     
    304304      well, looks like the culprit was just the urlib3 socket pool with blocking turned on 
    305305      so all the threads (even when doing it with a single thread) hanged on the block 
    306       it seems to be wotrking alright + its pretty fast too 
     306      it seems to be working alright + its pretty fast too 
    307307      """ 
    308308      getFilesThread = self.GetFiles(self, neededTiles, layer, maxThreads) 
     
    331331  def addOtherZoomlevels(self, tiles, tilesZ, maxZ, minZ): 
    332332    """expand the tile coverage to other zoomlevels 
    333     maxZ = maximum NUMERICAL zoom, 17 for eaxmple 
     333    maxZ = maximum NUMERICAL zoom, 17 for example 
    334334    minZ = minimum NUMERICAL zoom, 0 for example 
    335335    we use two different methods to get the needed tiles: 
    336     * spliting the tiles from one zoomlevel down to the other 
    337     * rounding the tiles cooridnates to get tiles from one zoomlevel up 
     336    * splitting the tiles from one zoomlevel down to the other 
     337    * rounding the tiles coordinates to get tiles from one zoomlevel up 
    338338    we choose a zoomlevel (tilesZ) and then split down and round down from it 
    339339    * tilesZ is determined in the handle message method, 
     
    343343    be downloading much more tiles than needed 
    344344    => for now, if we get tilesZ (called midZ in handle message) that is lower than 15, 
    345     we set it to the lowest zoomlevel, so we get dont get too much unneeded tiles when splitting 
     345    we set it to the lowest zoomlevel, so we get don't get too much unneeded tiles when splitting 
    346346    """ 
    347347    start = clock() 
     
    351351 
    352352    """start of the tile splitting code""" 
    353     previousZoomlevelTiles = None # we will splitt the tiles from the previous zoomlevel 
     353    previousZoomlevelTiles = None # we will split the tiles from the previous zoomlevel 
    354354    print "splitting down" 
    355355    for z in range(tilesZ, maxZ): # to max zoom (fo each z we split one zoomlevel down) 
     
    363363        now we split each tile to 4 tiles on a higher zoomlevel nr 
    364364        see: http://wiki.openstreetmap.org/wiki/Slippy_map_tilenames#Subtiles 
    365         for a tile with cooridnates x,y: 
     365        for a tile with coordinates x,y: 
    366366        2x,2y  |2x+1,2y 
    367367        2x,2y+1|2x+1,2y+1 
     
    379379      previousZoomlevelTiles = newTilesFromSplit # set the new tiles s as prev. tiles for next iteration 
    380380 
    381     """start of the tile cooridnates rounding code""" 
    382     previousZoomlevelTiles = None # we will the tile cooridnates to get tiles for the upper level 
     381    """start of the tile coordinates rounding code""" 
     382    previousZoomlevelTiles = None # we will the tile coordinates to get tiles for the upper level 
    383383    print "rounding up" 
    384     r = range(minZ, tilesZ) # we go from the tile-z up, e.g. a seqence of progresivly smaller integers 
     384    r = range(minZ, tilesZ) # we go from the tile-z up, e.g. a sequence progressively smaller integers 
    385385    r.reverse() 
    386386    for z in r: 
     
    392392        y = tile[1] 
    393393        """as per: http://wiki.openstreetmap.org/wiki/Slippy_map_tilenames#Subtiles 
    394         we divide each cooridnate with 2 to get the upper tile 
     394        we divide each coordinate with 2 to get the upper tile 
    395395        some upper tiles can be found up to four times, so this could be most probably 
    396396        optimized if need be (for charting the Jupiter, Sun or a Dyson sphere ? :)""" 
     
    501501          with self.callback.dlListLock: 
    502502            self.callbackSet.discard(item) 
    503           size = 0 # tiles we dont have dont need to be downloaded, therefore 0 
     503          size = 0 # tiles we don't have don't need to be downloaded, therefore 0 
    504504        with incrementLock: 
    505505          self.processed+=1 
     
    518518        (url, filename, folder, folderPrefix, layerType) = self.callback.getTileUrlAndPath(x, y, z, self.layer) 
    519519        m = self.callback.m.get('storeTiles', None) # get the tile storage module 
    520         # get the sotre tiles module 
     520        # get the store tiles module 
    521521        if m: 
    522522          # does the tile exist ? 
     
    670670          with self.callback.dlListLock: 
    671671            item = self.neededTiles.pop() 
    672         except: # start the loop from beggining, so that shutdown can be checked and the thread can exit 
     672        except: # start the loop from beginning, so that shutdown can be checked and the thread can exit 
    673673          print "waiting for more work" 
    674674          time.sleep(2) 
     
    773773    """get tilenamames for tiles around the route for given radius and zoom""" 
    774774    """ now we look whats the distance between each two trackpoints, 
    775     if it is larger than the tracklog radius, we add aditioanl interpolated points, 
     775    if it is larger than the tracklog radius, we add additional interpolated points, 
    776776    so we get continuous coverage for the tracklog """ 
    777777    first = True 
     
    802802      # the spiral gives us tiles around coordinates for a given radius 
    803803      currentPointTiles = self.spiral(x,y,z,radius) 
    804       """now we take the resulting list  and process it in suach a way, 
     804      """now we take the resulting list  and process it in such a way, 
    805805      that the tiles coordinates can be stored in a set, 
    806806      so we will save only unique tiles""" 
     
    812812 
    813813  def addPointsToLine(self, lat1, lon1, lat2, lon2, maxDistance): 
    814     """experimental (recursive) function for adding aditional points between two coordinates, 
     814    """experimental (recursive) function for adding additional points between two coordinates, 
    815815    until their distance is less or or equal to maxDistance 
    816816    (this is actually a wrapper for a local recursive function)""" 
     
    818818    def localAddPointsToLine(lat1, lon1, lat2, lon2, maxDistance): 
    819819      distance = geo.distance(lat1, lon1, lat2, lon2) 
    820       if distance <= maxDistance: # the termination criterium 
     820      if distance <= maxDistance: # the termination criterion 
    821821        return 
    822822      else: 
     
    834834    # is this menu the correct menu ? 
    835835    if menuName == 'batchTileDl': 
    836       """in order for the threeds to work normally, it is needed to pause the main loop for a while 
     836      """in order for the threads to work normally, it is needed to pause the main loop for a while 
    837837      * this works only for this menu, in other menus (even the edit  menu) the threads will be slow to start 
    838838      * when looking at map, the threads behave as expected :) 
     
    963963        else: 
    964964          failedCountString = "%d downloads failed" % failedCount 
    965         text = "<b>%s</b>: <b>%d</b> of <b>%d</b> tiles done\n\n<b>%1.2f MB</b> transfered, %s" % (action, currentTileCount, totalTileCount, MBTotalTransfered, failedCountString) 
     965        text = "<b>%s</b>: <b>%d</b> of <b>%d</b> tiles done\n\n<b>%1.2f MB</b> transferred, %s" % (action, currentTileCount, totalTileCount, MBTotalTransfered, failedCountString) 
    966966      elif getFilesThread.isAlive() == False: #TODO: send an alert that download is complete 
    967967        if getFilesThread.getDownloadCount(): 
    968           # some downloads occured 
     968          # some downloads occurred 
    969969          text = "<b>Download complete.</b>" 
    970970        else: 
    971           # no downloads occured 
     971          # no downloads occurred 
    972972          if failedCount: 
    973973            # no downloads + failed downloads 
    974974            text = "<b>Download of all tiles failed.</b>" 
    975975          else: 
    976             # no downalods and no failed downloads 
     976            # no downloads and no failed downloads 
    977977            text = "<b>All tiles were locally available.</b>" 
    978978    return text 
Note: See TracChangeset for help on using the changeset viewer.