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 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_region_around_location(self, lat0, lon0, dlat, dlon, zoom, *args, **kwargs): if dlat > 170: lat0 = 0 dlat = 170 if dlon > 358: lon0 = 0 dlon = 358 top_left = mapUtils.coord_to_tile((lat0 + dlat / 2, lon0 - dlon / 2, zoom)) bottom_right = mapUtils.coord_to_tile((lat0 - dlat / 2, lon0 + dlon / 2, zoom)) self.query_region(top_left[0][0], bottom_right[0][0], top_left[0][1], bottom_right[0][1], zoom, *args, **kwargs)
def query_region_around_location(self, lat0, lon0, dlat, dlon, zoom, *args, **kwargs): if dlat > 170: lat0 = 0 dlat = 170 if dlon > 358: lon0 = 0 dlon = 358 top_left = mapUtils.coord_to_tile( (lat0 + dlat / 2, lon0 - dlon / 2, zoom)) bottom_right = mapUtils.coord_to_tile( (lat0 - dlat / 2, lon0 + dlon / 2, zoom)) self.query_region(top_left[0][0], bottom_right[0][0], top_left[0][1], bottom_right[0][1], zoom, *args, **kwargs)
def coord_to_screen(self, x, y, zl): mct = mapUtils.coord_to_tile((x, y, zl)) xy = mapUtils.tile_coord_to_screen((mct[0][0], mct[0][1], zl), self.get_allocation(), self.center) if xy: for x, y in xy: return (x + mct[1][0], y + mct[1][1])
def coord_to_screen(self, x, y, zl): mct = mapUtils.coord_to_tile((x, y, zl)) xy = mapUtils.tile_coord_to_screen( (mct[0][0], mct[0][1], zl), self.get_allocation(), self.center ) if xy: for x,y in xy: return (x + mct[1][0], y + mct[1][1])