Skip to content

Commit

Permalink
Make max_zoom part of the struct (#52)
Browse files Browse the repository at this point in the history
* Make max_zoom part of the struct

This allows to set the maximal zoom level that is downloaded as a keyword argument during Map construction.
This is useful, when the TileProvider has different zoom levels for different parts of the world.
Using the max_zoom level of the provider would therefore lead to multiple download errors.

* remove show

---------

Co-authored-by: Simon <[email protected]>
  • Loading branch information
felixcremer and SimonDanisch authored Sep 11, 2023
1 parent cefc8d3 commit 09ef6b3
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/Tyler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ struct Map
depth::Int
halo::Float64
scale::Float64
max_zoom::Int
end

# Wait for all tiles to be loaded
Expand Down Expand Up @@ -101,7 +102,8 @@ function Map(extent, extent_crs=wgs84;
cache_size_gb=5,
depth=8,
halo=0.2,
scale=1.0
scale=1.0,
max_zoom=TileProviders.max_zoom(provider)
)

fetched_tiles = LRU{Tile, Matrix{RGB{N0f8}}}(; maxsize=cache_size_gb * 10^9, by=Base.sizeof)
Expand Down Expand Up @@ -135,7 +137,7 @@ function Map(extent, extent_crs=wgs84;
max_parallel_downloads, OrderedSet{Tile}(),
tiles_being_added, downloaded_tiles,
display_task, download_task, screen,
depth, halo, scale
depth, halo, scale, max_zoom
)
tyler.zoom[] = get_zoom(tyler, extent)
download_task[] = @async begin
Expand Down Expand Up @@ -298,7 +300,7 @@ function queue_tile!(tyler::Map, tile)
end
end

TileProviders.max_zoom(tyler::Map) = Int(max_zoom(tyler.provider))
TileProviders.max_zoom(tyler::Map) = tyler.max_zoom
TileProviders.min_zoom(tyler::Map) = Int(min_zoom(tyler.provider))

function get_zoom(tyler::Map, area)
Expand Down

0 comments on commit 09ef6b3

Please sign in to comment.