Skip to content

Commit

Permalink
Merge branch 'fc/geomakie' into patch-2
Browse files Browse the repository at this point in the history
  • Loading branch information
asinghvi17 committed May 12, 2024
2 parents bcbcd26 + 790357a commit 5f15bf7
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/Tyler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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::A
displayed_tiles::OrderedSet{Tile}
plots::Dict{Tile,Any}
free_tiles::Vector{Makie.Plot}
Expand Down Expand Up @@ -151,14 +151,15 @@ function Map(extent, extent_crs=wgs84;
ext_target = MapTiles.project_extent(extent, extent_crs, crs)
X = ext_target.X
Y = ext_target.Y
if axis isa Axis
if axis isa Makie.Axis3
Makie.xlims!(axis, X[1], X[2])
Makie.ylims!(axis, Y[1], Y[2])
elseif axis isa Makie.LScene
# do nothing
else # any other axis is 2d
axis.autolimitaspect = 1
Makie.limits!(axis, (X[1], X[2]), (Y[1], Y[2]))
elseif axis isa Makie.Axis3
Makie.xlims!(axis, (X[1], X[2]))
Makie.ylims!(axis, (Y[1], Y[2]))
end

plots = Dict{Tile,Any}()
tyler = Map(
provider, crs,
Expand Down Expand Up @@ -293,6 +294,7 @@ function create_tile_plot!(tyler::Map, tile::Tile, image::TileImage)
end

function fetch_tile(tyler::Map, tile::Tile)
#println("Fetching Tile")
return get!(tyler.fetched_tiles, tile) do
fetch_tile(tyler.provider, tile)
end
Expand Down

0 comments on commit 5f15bf7

Please sign in to comment.