staticmap icon indicating copy to clipboard operation
staticmap copied to clipboard

First example in the README not working when using m.render() with zoom >= 20 (it was working until some weeks ago)

Open gmberton opened this issue 2 years ago • 3 comments

The first example in the README

from staticmap import StaticMap, Line
m = StaticMap(300, 400, 10)
m.add_line(Line(((13.4, 52.5), (2.3, 48.9)), 'blue', 3))
image = m.render()
image.save('map.png')

does not work when m.render() is called using zoom >= 20. For example this does not work

m = StaticMap(300, 400, 10)
m.add_line(Line(((13.4, 52.5), (2.3, 48.9)), 'blue', 3))
image = m.render(zoom=20)
image.save('map.png')

but this does work

from staticmap import StaticMap, Line
m = StaticMap(300, 400, 10)
m.add_line(Line(((13.4, 52.5), (2.3, 48.9)), 'blue', 3))
image = m.render(zoom=19)
image.save('map.png')

When using zoom >= 20 an error is shown saying request failed [400]: https://a.tile.openstreetmap.org/20/547152/352422.png although it was working until a few weeks ago. Is the issue related to issue 33? Is there any workaround to this issue?

gmberton avatar Aug 16 '23 16:08 gmberton

map_builder doesn't work anymore, so I want to raise an issue here. (The reason may be here: [https://operations.osmfoundation.org/policies/tiles/]) After seeing your issue, I tried to use other methods to implement it. Here is the code and a demo, I hope it can help you. (I am using the demo generated by the sf_xl_small data set, so the points in the graph are sparser than those in your paper.)

grouped_gps_coords = _get_coordinates_from_dataset(join(dataset_folder, "images"))

center, bounds = get_center_and_bounds([coords for _, coords in grouped_gps_coords])
m = folium.Map(location=center, zoom_start=13)  # Set center based on the mean of all coords
m.fit_bounds(bounds)  # Adjust zoom to fit the bounds

COLOR_MAP = {
    "test - database": "#0000FF",  # Red
    "test - queries_queries_night": "#FF0000"  # Blue
}

for folder_name, coords in grouped_gps_coords:
    print(folder_name)
    color = COLOR_MAP.get(folder_name, "#FF0000")
    m = add_points_to_map(m, coords, color)

m.save(os.path.join(dataset_folder, "map.html"))

image

BinuxLiu avatar Oct 25 '23 07:10 BinuxLiu

Hi @BinuxLiu thank you for your help! This workaround is very interesting: it would still be better to download the images as PNG, but according to the link you shared it seems like there is not hope to do that through OSM (and therefore komoot). If you want you could do a PR on https://github.com/gmberton/VPR-datasets-downloader , if not I'll work on it after the CVPR deadline. Thanks again!

gmberton avatar Oct 25 '23 10:10 gmberton

Looking forward to your work! Wish us good luck!

BinuxLiu avatar Oct 25 '23 13:10 BinuxLiu