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

max_native_zoom property for Providers #161

Open
vpipkt opened this issue Sep 23, 2020 · 4 comments
Open

max_native_zoom property for Providers #161

vpipkt opened this issue Sep 23, 2020 · 4 comments

Comments

@vpipkt
Copy link

vpipkt commented Sep 23, 2020

Allow for a max_native_zoom property in Provider object, which would have the same semantics as maxNativeZoom in Leaflet. Honoring this option would require auto-scaling the returned image at max_native_zoom to the requested zoom.

Implementation seems like it would entail changes in tile.py especially _validate_zoom, bounds2img, and possibly _fetch_tile. In bounds2img and _validate_zoom, logic to track the requested zoom from the caller and the zto pass to the provider. And it seems reasonable to usePIL.Image.resizein bounds2img` while the data are still in a PIL.Image.

I am happy to propose a PR, but I'm curious to hear what others may have to think about this idea. I am pretty new to contextily so I'm curious if there might be unintended consequences.

@vpipkt
Copy link
Author

vpipkt commented Sep 23, 2020

Somewhat related: https://github.com/leaflet-extras/leaflet-providers/pull/369/files

If that PR is merged I suppose I will make a PR against contextily/_providers.py

@jorisvandenbossche
Copy link
Member

What is exactly the difference between max_zoom and max_native_zoom ?

@vpipkt
Copy link
Author

vpipkt commented Sep 23, 2020

In leaflet, maxZoom, is "the maximum zoom level up to which this layer will be displayed (inclusive)." At higher zoom levels the default behavior is to display an empty / transparent image for that layer. In some instances the map will just be a grey box.

In leaflet, maxNativeZoom is "Maximum zoom number the tile source has available. If it is specified, the tiles on all zoom levels higher than maxNativeZoom will be loaded from maxNativeZoom level and auto-scaled." Instead of a transparent or grey display, it will upsample the result from the specified maxNativeZoom.

Basically specifying maxNativeZoom allows you to set a maximum on the zoom level the client requests; then the client knows to auto scale in cases where the state demands a higher zoom level.

@vpipkt
Copy link
Author

vpipkt commented Sep 25, 2020

oops made a comment that was meant for a PR in another repo. @jorisvandenbossche does this sound reasonable enough that a PR would be considered?

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