From a386c7644daab26e80300a97483dc398a31a8c5f Mon Sep 17 00:00:00 2001 From: Felix Cremer Date: Wed, 13 Mar 2024 09:52:47 +0100 Subject: [PATCH 1/4] Try to make Tyler GeoMakie compatible This is not working at the moment because there are some strange interactions. Maybe it would be better to simply use a GeoAxis and let GeoMakie handle the conversion logic, that is currently done in Tyler. --- src/Tyler.jl | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Tyler.jl b/src/Tyler.jl index b142e9fb..6005121d 100644 --- a/src/Tyler.jl +++ b/src/Tyler.jl @@ -46,12 +46,12 @@ downloading and plotting more tiles as you zoom and pan. -`scale`: a tile scaling factor. Low number decrease the downloads but reduce the resolution. The default is `1.0`. """ -struct Map +struct Map{A<:Makie.AbstractAxis} provider::AbstractProvider crs::CoordinateReferenceSystemFormat zoom::Observable{Int} figure::Figure - axis::Axis + axis::A displayed_tiles::OrderedSet{Tile} plots::Dict{Tile,Any} free_tiles::Vector{Makie.Combined} @@ -152,6 +152,7 @@ function Map(extent, extent_crs=wgs84; X = ext_target.X Y = ext_target.Y axis.autolimitaspect = 1 + @show X[1], X[2] Makie.limits!(axis, (X[1], X[2]), (Y[1], Y[2])) plots = Dict{Tile,Any}() @@ -202,9 +203,11 @@ function Map(extent, extent_crs=wgs84; end # Queue tiles to be downloaded & displayed + @show ext_target update_tiles!(tyler, ext_target) on(axis.scene, axis.finallimits) do extent + @show extent stopped_displaying(figure) && return update_tiles!(tyler, extent) return @@ -283,6 +286,8 @@ function create_tile_plot!(tyler::Map, tile::Tile, image::TileImage) end function fetch_tile(tyler::Map, tile::Tile) + #println("Fetching Tile") + #@show tile return get!(tyler.fetched_tiles, tile) do fetch_tile(tyler.provider, tile) end @@ -339,6 +344,7 @@ function get_zoom(tyler::Map, area) end function update_tiles!(tyler::Map, area::Union{Rect,Extent}) + @show area area = typeof(area) <: Rect ? Extents.extent(area) : area # `depth` determines the number of layers below the current # layer to load. Tiles are downloaded in order from lowest to highest zoom. @@ -346,6 +352,7 @@ function update_tiles!(tyler::Map, area::Union{Rect,Extent}) # Calculate the zoom level zoom = get_zoom(tyler, area) + @show zoom tyler.zoom[] = zoom # And the z layers we will plot From 01213d695c5458f3829ed59753acdf5880faa6cd Mon Sep 17 00:00:00 2001 From: Felix Cremer Date: Wed, 13 Mar 2024 22:38:30 +0100 Subject: [PATCH 2/4] Fix debug_tiles! --- src/Tyler.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Tyler.jl b/src/Tyler.jl index 6005121d..f5028d76 100644 --- a/src/Tyler.jl +++ b/src/Tyler.jl @@ -8,7 +8,7 @@ using HTTP: HTTP using ImageMagick: ImageMagick using LRUCache: LRUCache, LRU using MapTiles: MapTiles, Tile, TileGrid, web_mercator, wgs84, CoordinateReferenceSystemFormat -using Makie: Makie, Observable, Figure, Axis, RGBAf, on, isopen, meta, mesh!, translate!, scale! +using Makie: Makie, Observable, Figure, Axis, RGBAf, on, isopen, linesegments!, meta, mesh!, translate!, scale! using OrderedCollections: OrderedCollections, OrderedSet using ThreadSafeDicts: ThreadSafeDicts, ThreadSafeDict using TileProviders: TileProviders, AbstractProvider, geturl, min_zoom, max_zoom @@ -424,8 +424,8 @@ function debug_tile!(map::Tyler.Map, tile::Tile) end function debug_tiles!(map::Tyler.Map) - for tile in m.displayed_tiles - debug_tile!(m, tile) + for tile in map.displayed_tiles + debug_tile!(map, tile) end end From cd0b7fc0c13b80eca6f0cf1aee95a260f7558fd7 Mon Sep 17 00:00:00 2001 From: Felix Cremer Date: Mon, 8 Apr 2024 10:41:50 +0200 Subject: [PATCH 3/4] Allow Makie 0.21 --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 7a524fe2..af2065c4 100644 --- a/Project.toml +++ b/Project.toml @@ -29,7 +29,7 @@ ImageMagick = "1" ImageMagick_jll = "~6.9.12" LRUCache = "1" LinearAlgebra = "1" -Makie = "0.20" +Makie = "0.20, 0.21" MapTiles = "1" OrderedCollections = "1" ThreadSafeDicts = "0.1" From 790357a0421226e106465aac4927d1fa444ea2f3 Mon Sep 17 00:00:00 2001 From: Felix Cremer Date: Mon, 8 Apr 2024 10:42:23 +0200 Subject: [PATCH 4/4] Remove show statements --- src/Tyler.jl | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/Tyler.jl b/src/Tyler.jl index f5028d76..0c5c4f54 100644 --- a/src/Tyler.jl +++ b/src/Tyler.jl @@ -152,9 +152,7 @@ function Map(extent, extent_crs=wgs84; X = ext_target.X Y = ext_target.Y axis.autolimitaspect = 1 - @show X[1], X[2] Makie.limits!(axis, (X[1], X[2]), (Y[1], Y[2])) - plots = Dict{Tile,Any}() tyler = Map( provider, crs, @@ -203,11 +201,9 @@ function Map(extent, extent_crs=wgs84; end # Queue tiles to be downloaded & displayed - @show ext_target update_tiles!(tyler, ext_target) on(axis.scene, axis.finallimits) do extent - @show extent stopped_displaying(figure) && return update_tiles!(tyler, extent) return @@ -287,7 +283,6 @@ end function fetch_tile(tyler::Map, tile::Tile) #println("Fetching Tile") - #@show tile return get!(tyler.fetched_tiles, tile) do fetch_tile(tyler.provider, tile) end @@ -344,7 +339,6 @@ function get_zoom(tyler::Map, area) end function update_tiles!(tyler::Map, area::Union{Rect,Extent}) - @show area area = typeof(area) <: Rect ? Extents.extent(area) : area # `depth` determines the number of layers below the current # layer to load. Tiles are downloaded in order from lowest to highest zoom. @@ -352,7 +346,6 @@ function update_tiles!(tyler::Map, area::Union{Rect,Extent}) # Calculate the zoom level zoom = get_zoom(tyler, area) - @show zoom tyler.zoom[] = zoom # And the z layers we will plot