walkers icon indicating copy to clipboard operation
walkers copied to clipboard

min_zoom

Open Swarkin opened this issue 8 months ago • 11 comments

The TileSource has a function for max_zoom, but none for min_zoom. Adding it would be a good first step to better support non-global imagery sources.

Since the TileSource::tile_url function doesn't allow you to cancel a request of the given TileId, this can't be solved by the crate user. I would appreciate if this was possible too, but thats out of scope for this issue.

Swarkin avatar Mar 20 '25 10:03 Swarkin

I suppose tile_url could return Result/Option. max_zoom could be then removed.

podusowski avatar Mar 21 '25 19:03 podusowski

On a second thought, we need to know zoom limits before setting it and attempting the download.

podusowski avatar Mar 21 '25 19:03 podusowski

How about a function that returns a range like 1..=19 as well as the ability to cancel tile requests by returning None from tile_url?

Swarkin avatar Mar 21 '25 20:03 Swarkin

I'll try to play with it and see where it ends up.

podusowski avatar Mar 21 '25 20:03 podusowski

Just to clarify. You want walkers to render lower zoom levels using tiles with higher zoom?

podusowski avatar Mar 22 '25 21:03 podusowski

Huh? No. I want a configurable maximum zoom level and the ability to return None from tile_url

Swarkin avatar Mar 22 '25 21:03 Swarkin

This is how TileSource::max_zoom() works. It will not download tiles exceeding it, but you can still zoom in (up to currently hard-coded 26) and it will render it from whatever is available.

podusowski avatar Mar 22 '25 21:03 podusowski

Oh sorry I made a typo, I meant to write minimum zoom level. I was in a rush

Swarkin avatar Mar 22 '25 23:03 Swarkin

It's ok, I figured. :) The thing is that both min_zoom and max_zoom can mean two things - either lock zooming beyond that point or not downloading tiles beyond the limit and using whatever tiles are available.

In max_zoom case, Walkers will not download tiles beyond 19 (this is what TileSource::max_zoom() does), but lets you zoom up to 26 (this is not configurable at the moment). For min zoom it's pretty much the same, but both values are kind of locked at 0.

podusowski avatar Mar 23 '25 08:03 podusowski

The thing is that both min_zoom and max_zoom can mean two things - either lock zooming beyond that point, or not downloading tiles beyond the limit and using whatever tiles are available.

Now that you mention it, locking the zoom amount would also be pretty useful, but it probably should not be configured on a per-Tilesource basis but instead globally on the main Map object. For this issue, though, I wanted to request being able to configure walkers to stop downloading tiles on lower zoom levels.

Approach 1: This could either be done with min_zoom() -> u8 and max_zoom() -> u8, or by having a function that returns a Range object like 0..=19 (if thats possible). Then walkers should internally check whether the tiles it wants are within that zoom level.

Or Approach 2: The tile_url function should be able to return None, so that the user can manually do a simple if check to see whether tiles are within the required zoom levels. This also allows filtering out tiles by using the x and y positions if needed. This way, we can get rid of max_zoom() as well.

Swarkin avatar Mar 23 '25 11:03 Swarkin

Well, they differ in API, but whichever is chosen, we still need to render unavailable tiles somehow. For max_zoom it is already done - i.e. walkers will just magnify available lower level tiles. The other side is a bit harder, because it involves gluing multiple tiles into a single one.

That being said, we definitely need an Error or something in tile_url, as there might be multiple reasons why someone might want to make some ids unavailable. You must be aware however, that without interpolation, it will just draw nothing. So zooming too far away will just make map disappear.

podusowski avatar Mar 25 '25 19:03 podusowski