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

Add option to auto-detect maxzoom #3110

Open
mnalis opened this issue Dec 31, 2024 · 3 comments
Open

Add option to auto-detect maxzoom #3110

mnalis opened this issue Dec 31, 2024 · 3 comments

Comments

@mnalis
Copy link

mnalis commented Dec 31, 2024

Is your feature request related to a problem? Please describe.
When using raster satellite imagery (TMS), one has to specify maxzoom. It is fine if the TMS has the same maxzoom everywhere, but that is often not the case for e.g. satellite (and aerial) imagery where coverage has different details in different areas.

E.g. https://server.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer

in some places same maxzoom=18 (or even up to 21) works just fine, while in other places maxzoom 18 is not available and it returns dummy image instead:

Image

That is extremely annoying to the user, who has to choose between 3 bad solutions:

  • set the maxzoom once to maximum possibly supported level (e.g. 21), which causes abrupt changes from normal satellite imagery to dummy imagery when they zoom in too much in places where such zoom is not available
  • set the maxzoom once to minimum version supported everywhere on than TMS (17 or even down to 13), resulting in blurry low-detail images even in places where much higher resolution is offered by the TMS
  • constantly manually change maxzoom depending where on the map they are the panning/zooming.

(FYI, the App I'm using is SCEE, and here are relevant discussions: Helium314/SCEE#615 and PRs Helium314/SCEE#708. Here is the debug .apk if one wants to play with it -- one needs to enable Settings / UI / Quick settings button to be able to switch to satellite imagery, and in Settings / Data management / Tile source for sattellite / aerial images one can set tile URL and its maxzoom)

Describe the solution you'd like
I would like if MapLibre had an option to automatically detect when real maxzoom is exceeded and fallback to in-library scaling (like it does currently if e.g. maxzoom=17 is specified and user zooms to 19). It already does that if remote server provides HTTP 404 error on invalid zooms, but not if it provides "fake" tile instead.

I know TMS does not provide that information (which maxzoom is available in the area), but it could be autodetected with some heuristics (if app developer specifies they want such behaviour, of course):

  • when user zooms in and new tiles are downloaded, check if all (or few) of the newly downloaded adjacent tiles are the same (i.e. have the same checksum)
  • if they are the same, assume that we've hit over supported maxzoom for that area (there could be optional extra safety check here, e.g. try to download a single tile at newcurrentzoom+1 , and see if that one is also the same)
  • if it is decided we've hit maxzoom, implement in-library software scaling (like we currently do when maxzoom was manually set to lower value then current map view zoom)

Describe alternatives you've considered
See 3 alternatives listed above -- all have been tried and all are bad for user experience.
The third option (user must manually determine and change maxzoom) seems the best we can do currently without MapLibre help, but even when accompanied with a FAQ it requires not only users being advanced, but it also constantly annoys them with need to manually change setting if they cover more then a single area.

Additional context

@goldfndr
Copy link

Perhaps also check blank-tile in header and don't use/cache if true (if not implemented)?

@louwers
Copy link
Collaborator

louwers commented Jan 17, 2025

I would recommend to set op a proxy with a Cloudflare Worker or AWS Lambda to return 404 instead of the Map data unavailable image. Adding this heuristic logic to the library sounds like a complicated solution for a very specific problem.

Actually now that I think of it, you don't need a proxy, you can probably achieve the result by using a Custom Module provider that intercepts the HTTP response and turns it into a 404 if the dummy image is detected. #2231

@mnalis
Copy link
Author

mnalis commented Jan 18, 2025

Thanks for suggestion; although the proxy is not really useful as a solution in many cases, as it adds a cost1 (and maintenance/another SPOF) for an app developer where previously there were none.

However, your suggestion for custom module provider might work, esp. seems relatively easy if TMS is hardcoded in app and single "fake tile" checksum can be precalculated. If TMS is custom, original idea is harder to implement, as it would not know when zoom was increased like MapLibre core could, but probably still doable via Custom Module HTTP provider.

If somebody does it, it would be appreciated if they link their solution here!

Tip

For those interested, that specific Arcgisonline.com TMS server example mentioned in the original issue can be fixed with usage of ?blankTile=false - see e.g. Helium314/SCEE#724, so for my specific use case it lowered priority from "important" to "nice to have"; but the other TMSs may not be so lucky

Footnotes

  1. and not only cost, but possibly escalating cost with an alternative of global app failure when limits are reached.

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

3 participants