def get_location_tiles(top_left, bottom_right, zoom, layer): top_left_tile = mapTool.coord_to_tile((top_left[0], top_left[1], zoom)) bottom_right_tile = mapTool.coord_to_tile((bottom_right[0], bottom_right[1], zoom)) xmin = top_left_tile[0][0] ymin = top_left_tile[0][1] xmax = bottom_right_tile[0][0] ymax = bottom_right_tile[0][1] return get_region_tiles(xmin, xmax, ymin, ymax, zoom, layer)
def get_location_tiles(top_left, bottom_right, zoom, layer): top_left_tile = mapTool.coord_to_tile((top_left[0], top_left[1], zoom)) bottom_right_tile = mapTool.coord_to_tile( (bottom_right[0], bottom_right[1], zoom)) xmin = top_left_tile[0][0] ymin = top_left_tile[0][1] xmax = bottom_right_tile[0][0] ymax = bottom_right_tile[0][1] return get_region_tiles(xmin, xmax, ymin, ymax, zoom, layer)
def merge_location_image(top_left, bottom_right, zoom, layer): top_left_tile = mapTool.coord_to_tile((top_left[0], top_left[1], zoom)) bottom_right_tile = mapTool.coord_to_tile( (bottom_right[0], bottom_right[1], zoom)) xmin = top_left_tile[0][0] ymin = top_left_tile[0][1] xmax = bottom_right_tile[0][0] ymax = bottom_right_tile[0][1] world_tiles = 1 << zoom if xmax - xmin >= world_tiles: xmin, xmax = 0, world_tiles - 1 if ymax - ymin >= world_tiles: ymin, ymax = 0, world_tiles - 1 width = (xmax - xmin + world_tiles) % world_tiles + 1 height = (ymax - ymin + world_tiles) % world_tiles + 1 map_image = Image.new("RGB", (width * 256, height * 256)) for i in xrange(width): x = (xmin + i) % world_tiles for j in xrange(height): y = (ymin + j) % world_tiles tile = MapTile(layer, x, y, zoom) file_path = tile.get_file_path() if os.path.exists(file_path): paste_box = (i * 256, j * 256, (i + 1) * 256, (j + 1) * 256) paste_im = Image.open(file_path) map_image.paste(paste_im, paste_box) if layer == 'sat_cn': tile = MapTile('road_cn', x, y, zoom) file_path = tile.get_file_path() if os.path.exists(file_path): #paste_box = (i*256, j*256, (i+1)*256, (j+1)*256) paste_im = Image.open(file_path) map_image.paste(paste_im, paste_box, paste_im) return map_image
def merge_location_image(top_left, bottom_right, zoom, layer): top_left_tile = mapTool.coord_to_tile((top_left[0], top_left[1], zoom)) bottom_right_tile = mapTool.coord_to_tile((bottom_right[0], bottom_right[1], zoom)) xmin = top_left_tile[0][0] ymin = top_left_tile[0][1] xmax = bottom_right_tile[0][0] ymax = bottom_right_tile[0][1] world_tiles = 1 << zoom if xmax - xmin >= world_tiles: xmin, xmax = 0, world_tiles-1 if ymax - ymin >= world_tiles: ymin, ymax = 0, world_tiles-1 width = (xmax - xmin+world_tiles)%world_tiles + 1 height = (ymax - ymin+world_tiles)%world_tiles + 1 map_image = Image.new("RGB", (width*256,height*256)) for i in xrange(width): x = (xmin + i)%world_tiles for j in xrange(height): y = (ymin + j)%world_tiles tile = MapTile(layer, x, y, zoom) file_path = tile.get_file_path() if os.path.exists(file_path): paste_box = (i*256, j*256, (i+1)*256, (j+1)*256) paste_im = Image.open(file_path) map_image.paste(paste_im, paste_box) if layer == 'sat_cn': tile = MapTile('road_cn', x, y, zoom) file_path = tile.get_file_path() if os.path.exists(file_path): #paste_box = (i*256, j*256, (i+1)*256, (j+1)*256) paste_im = Image.open(file_path) map_image.paste(paste_im, paste_box, paste_im) return map_image