Esempio n. 1
0
 def refreshtiles_get(self, canvasextent, canvascrs, widthpx, forcedownload=False, cancelledcallback=None):
     extll = osm.unproject(canvasextent, canvascrs)
     
     zoom = self.zoom(widthpx, extll)
     if zoom is None or self.tiletype is None:
         return list(self.loadedlayers.keys()), [], []
     
     tiles = osm.tiles(extll.xMinimum(), extll.xMaximum(), 
                       extll.yMinimum(), extll.yMaximum(), zoom)
     
     if forcedownload:
         tilestoclean = list(self.loadedlayers.keys())
         tilestoload = tiles
     else:
         loadedtiles = set(self.loadedlayers.keys())
         tilestoclean = loadedtiles.difference(set(tiles))
         tilestoload = list(set(tiles).difference(loadedtiles))
     
     #calculate file names and urls
     cachedir = qosmsettings.get(qosmsettings.CACHE_DIRECTORY)
     tilefiles = [tm.filename(cachedir, self.tiletype, tile, zoom) for tile in tilestoload]
     tileurls = [tm.tileurl(self.tiletype, tile, zoom) for tile in tilestoload]
     
     if qosmsettings.get(qosmsettings.AUTODOWNLOAD):
         #download (keep on same thread for now)
         if not cancelledcallback:
             cancelledcallback = lambda: False
         dlerrors = []
         downloader.download(tileurls, tilefiles, overwrite=forcedownload, 
                             errorhandler=dlerrors.append, 
                             cancelledcallback=cancelledcallback)
         if dlerrors:
             self.rendererrors += 1
     
     return tilestoclean, tilestoload, tilefiles
Esempio n. 2
0
 def set_summarystats(self):   
     numtiles = len(self.layer.loadedlayers)
     zoom = self.layer.actualzoom if self.layer.specifiedzoom is None else \
             self.layer.specifiedzoom
     
     extent = self.iface.mapCanvas().extent() 
     crs = self.iface.mapCanvas().mapRenderer().destinationCrs()
     widthpx = self.iface.mapCanvas().width()
     extll = osm.unproject(extent, crs)
     
     calczoom = osm.autozoom(widthpx/(extll.xMaximum()-extll.xMinimum()))
     layerzoom = calczoom if zoom is None else zoom
     numtilestot = len(osm.tiles(extll.xMinimum(), extll.xMaximum(), 
                   extll.yMinimum(), extll.yMaximum(), layerzoom))
     
     self.statusText.setText("Loaded %s of %s tiles at zoom level %s (automatic zoom would be %s). \
                             %s rendering errors (see QOSM Settings/Logs for more details)." %
                             (numtiles, numtilestot, zoom, calczoom, self.layer.rendererrors))
Esempio n. 3
0
 def set_extent(self):
     extent = self.iface.mapCanvas().extent()
     crs = self.iface.mapCanvas().mapRenderer().destinationCrs()
     self.extent = osm.unproject(extent, crs)