Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
gmberton opened this issue Aug 16, 2023 · 3 comments

Comments

@gmberton
Copy link

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?

@BinuxLiu
Copy link

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

@gmberton
Copy link
Author

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!

@BinuxLiu
Copy link

Looking forward to your work!
Wish us good luck!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants