def query_tile(self, coord, layer, callback, online=True, force_update=False, conf=None, hybrid_background=LAYER_SAT): ret = 0 if layer == LAYER_HYB or layer == LAYER_CHA: ret += self.query_tile(coord, hybrid_background, callback, online, force_update, conf) #print "query_tile(",coord,layer,callback,online,force_update,")" world_tiles = mapUtils.tiles_on_level(coord[2]) coord = (mapUtils.mod(coord[0], world_tiles), mapUtils.mod(coord[1], world_tiles), coord[2]) # try to get a tile offline if self.ctx_map.is_tile_in_local_repos(coord, layer) or (not online): if not (force_update and online): callback(True, coord, layer) return ret if not (coord, layer) in self.queued: self.queued.append((coord, layer)) self.taskq.put( DownloadTask(coord, layer, callback, force_update, conf)) return ret + 1
def get_tiles_range_for_zoom(self, zoom): # get tiles - copied from mapDownloader dlon = mapUtils.km_to_lon(mapUtils.nice_round(self.reg_width), self.center_lat) dlat = mapUtils.km_to_lat(mapUtils.nice_round(self.reg_height)) if dlat > 170: dlat = 170 if dlon > 358: dlon = 358 top_left = mapUtils.coord_to_tile( (self.center_lat + dlat / 2, self.center_lon - dlon / 2, zoom)) bottom_right = mapUtils.coord_to_tile( (self.center_lat - dlat / 2, self.center_lon + dlon / 2, zoom)) # top_left[0][0], bottom_right[0][0], top_left[0][1], bottom_right[0][1] # xmin, xmax, ymin, ymax world_tiles = mapUtils.tiles_on_level(zoom) if bottom_right[0][0] - top_left[0][0] >= world_tiles: top_left[0][0], bottom_right[0][0] = 0, world_tiles - 1 if bottom_right[0][1] - top_left[0][1] >= world_tiles: top_left[0][1], bottom_right[0][1] = 0, world_tiles - 1 # xmin, xmax, ymin, ymax return (top_left[0][0], bottom_right[0][0], top_left[0][1], bottom_right[0][1])
def query_tile(self, coord, layer, callback, online=True, force_update=False, conf=None): ret = 0 if layer == LAYER_HYB: ret += self.query_tile(coord, LAYER_SAT, callback, online, force_update, conf) #print "query_tile(",coord,layer,callback,online,force_update,")" world_tiles = mapUtils.tiles_on_level(coord[2]) coord = (mapUtils.mod(coord[0], world_tiles), mapUtils.mod(coord[1], world_tiles), coord[2]) # try to get a tile offline if self.ctx_map.is_tile_in_local_repos(coord, layer) or (not online): if not (force_update and online): callback(True, coord, layer) return ret if not (coord, layer) in self.queued: self.queued.append((coord, layer)) self.taskq.put( DownloadTask( coord, layer, callback, force_update, conf ) ) return ret + 1
def get_tiles_range_for_zoom(self, zoom): # get tiles - copied from mapDownloader dlon = mapUtils.km_to_lon(mapUtils.nice_round(self.reg_width), self.center_lat) dlat = mapUtils.km_to_lat(mapUtils.nice_round(self.reg_height)) if dlat > 170: dlat = 170 if dlon > 358: dlon = 358 top_left = mapUtils.coord_to_tile( (self.center_lat + dlat / 2, self.center_lon - dlon / 2, zoom) ) bottom_right = mapUtils.coord_to_tile( (self.center_lat - dlat / 2, self.center_lon + dlon / 2, zoom) ) # top_left[0][0], bottom_right[0][0], top_left[0][1], bottom_right[0][1] # xmin, xmax, ymin, ymax world_tiles = mapUtils.tiles_on_level(zoom) if bottom_right[0][0] - top_left[0][0] >= world_tiles: top_left[0][0], bottom_right[0][0] = 0, world_tiles - 1 if bottom_right[0][1] - top_left[0][1] >= world_tiles: top_left[0][1], bottom_right[0][1] = 0, world_tiles - 1 # xmin, xmax, ymin, ymax return(top_left[0][0], bottom_right[0][0], top_left[0][1], bottom_right[0][1])
def query_tile(self, coord, layer, callback, online=True, force_update=False, conf=None): ret = 0 if layer == LAYER_HYB: ret += self.query_tile(coord, LAYER_SAT, callback, online, force_update, conf) elif MAP_SERVICES[layer]['ID'] == LAYER_HYB: ret += self.query_tile(coord, layer - HYB_SAT_LAYER_OFFSETS[MAP_SERVICES[layer]['serviceName']], callback, online, force_update, conf) #print "query_tile(",coord,layer,callback,online,force_update,")" world_tiles = mapUtils.tiles_on_level(coord[2]) coord = (mapUtils.mod(coord[0], world_tiles), mapUtils.mod(coord[1], world_tiles), coord[2]) # try to get a tile offline if self.ctx_map.is_tile_in_local_repos(coord, layer) or (not online): if not (force_update and online): callback(True, coord, layer) return ret if not (coord,layer) in self.queued: self.queued.append((coord, layer)) self.taskq.put( DownloadTask( coord, layer, callback, force_update, conf ) ) return ret + 1
def query_region(self, xmin, xmax, ymin, ymax, zoom, *args, **kwargs): ret = 0 world_tiles = mapUtils.tiles_on_level(zoom) if xmax - xmin >= world_tiles: xmin, xmax = 0, world_tiles - 1 if ymax - ymin >= world_tiles: ymin, ymax = 0, world_tiles - 1 #print "Query region",xmin,xmax,ymin,ymax,zoom for i in xrange((xmax - xmin + world_tiles) % world_tiles + 1): x = (xmin + i) % world_tiles for j in xrange((ymax - ymin + world_tiles) % world_tiles + 1): y = (ymin + j) % world_tiles ret += self.query_tile((x, y, zoom), *args, **kwargs) return ret
def query_region(self, xmin, xmax, ymin, ymax, zoom, *args, **kwargs): ret = 0 world_tiles = mapUtils.tiles_on_level(zoom) if xmax - xmin >= world_tiles: xmin, xmax = 0, world_tiles - 1 if ymax - ymin >= world_tiles: ymin, ymax = 0, world_tiles - 1 # print "Query region",xmin,xmax,ymin,ymax,zoom for i in xrange((xmax - xmin + world_tiles) % world_tiles + 1): x = (xmin + i) % world_tiles for j in xrange((ymax - ymin + world_tiles) % world_tiles + 1): y = (ymin + j) % world_tiles ret += self.query_tile((x, y, zoom), *args, **kwargs) return ret