def on_source(self, instance, value): if value.startswith("http://") or value.startswith("https://"): Downloader.instance().download(value, self._load_geojson_url) else: with open(value, "rb") as fd: geojson = json.load(fd) self.geojson = geojson
def on_source(self, instance, value): if value.startswith("http://") or value.startswith("https://"): Downloader.instance().download(value, self._load_geojson_url) else: # "rb" was replaced by "r" to avoid this error: # TypeError: the JSON object must be str, not 'bytes' with open(value, "r") as fd: geojson = json.load(fd) self.geojson = geojson
def fill_tile(self, tile): """Add this tile to load within the downloader """ if tile.state == "done": return if self.bounds is not None and self.restrict_to_bounds: min_x, min_y, max_x, max_y = self.get_bounds_xy( self.bounds, tile.zoom) if (tile.tile_x < min_x or tile.tile_x > max_x or tile.tile_y < min_y or tile.tile_y > max_y): tile.state = "done" return Downloader.instance(cache_dir=self.cache_dir).download_tile(tile)
def fill_tile(self, tile): if tile.state == "done": return Downloader.instance().submit(self._load_tile, tile)
def fill_tile(self, tile): """Add this tile to load within the downloader """ if tile.state == "done": return Downloader.instance().download_tile(tile)