@@ -4,7 +4,7 @@ function move_in_front!(plot, amount, ::Rect2)
44 if ! hasproperty (plot, :depth_shift )
55 translate! (plot, 0 , 0 , amount)
66 else
7- plot. depth_shift = - amount / 100f0
7+ plot. depth_shift = - amount / 10000f0
88 end
99end
1010
@@ -13,10 +13,31 @@ function move_to_back!(plot, amount, ::Rect2)
1313 if ! hasproperty (plot, :depth_shift )
1414 translate! (plot, 0 , 0 , - amount)
1515 else
16- plot. depth_shift = amount / 100f0
16+ plot. depth_shift = amount / 10000f0
1717 end
1818end
1919
20+ move_z (m:: AbstractMap , plot, tile:: Tile , bounds:: Rect3 ) = nothing
21+ function move_z (m:: AbstractMap , plot, tile:: Tile , bounds:: Rect2 )
22+ # We want to see everything of the current zoom and more zoomed out,
23+ # to fill gaps until they load
24+ if haskey (m. foreground_tiles, tile)
25+ plot. visible = true
26+ amount = - tile. z
27+ elseif m. zoom[] >= tile. z
28+ # @show "zoom is more or equal tile"
29+ plot. visible = true
30+ # move_to_front!(plot, amount, bounds)
31+ # If we are zoomed in we want to see everything
32+ # of that zoom and more zoomed out, to fill gaps until they load
33+ amount = 30 - tile. z # Flip the order for negative shift
34+ move_to_back! (plot, amount, bounds)
35+ else
36+ plot. visible = false
37+ end
38+ # @show m.zoom[] tile.z amount shift
39+ end
40+
2041struct PlotConfig <: AbstractPlotConfig
2142 attributes:: Dict{Symbol, Any}
2243 preprocess:: Function
@@ -126,7 +147,7 @@ function cull_plots!(m::Map)
126147 end
127148end
128149
129- function create_tile_plot ! (m:: AbstractMap , tile:: Tile , data)
150+ function create_tyler_plot ! (m:: AbstractMap , tile:: Tile , data)
130151 # For providers which have to map the same data to different tiles
131152 # Or providers that have e.g. additional parameters like a date
132153 # the url is a much better key than the tile itself
@@ -149,16 +170,10 @@ function create_tile_plot!(m::AbstractMap, tile::Tile, data)
149170 cull_plots! (m)
150171
151172 if isempty (m. unused_plots)
152- mplot = create_tileplot! (cfg, m. axis, data_processed, bounds, (tile, m. crs))
173+ mplot = create_tileplot! (cfg, m. axis, m, data_processed, bounds, (tile, m. crs))
153174 else
154175 mplot = pop! (m. unused_plots)
155- update_tile_plot! (mplot, cfg, m. axis, data_processed, bounds, (tile, m. crs))
156- end
157-
158- if haskey (m. foreground_tiles, tile)
159- move_in_front! (mplot, abs (m. zoom[] - tile. z), bounds)
160- else
161- move_to_back! (mplot, abs (m. zoom[] - tile. z), bounds)
176+ update_tile_plot! (mplot, cfg, m. axis, m, data_processed, bounds, (tile, m. crs))
162177 end
163178
164179 # Always move new plots to the front
@@ -195,7 +210,7 @@ function get_bounds(tile::Tile, data::ElevationData, crs)
195210end
196211
197212function create_tileplot! (
198- config:: PlotConfig , axis:: AbstractAxis , data:: ElevationData , bounds:: Rect , tile_crs
213+ config:: PlotConfig , axis:: AbstractAxis , m, data:: ElevationData , bounds:: Rect , tile_crs
199214)
200215 # not so elegant with empty array, we may want to make this a bit nicer going forward
201216 color = isempty (data. color) ? (;) : (color= data. color,)
@@ -215,7 +230,7 @@ function create_tileplot!(
215230end
216231
217232function update_tile_plot! (
218- plot:: Surface , :: PlotConfig , :: AbstractAxis , data:: ElevationData , bounds:: Rect , tile_crs
233+ plot:: Surface , :: PlotConfig , :: AbstractAxis , m, data:: ElevationData , bounds:: Rect , tile_crs
219234)
220235 mini, maxi = extrema (bounds)
221236 plot. args[1 ]. val = (mini[1 ], maxi[1 ])
234249const ImageData = AbstractMatrix{<: Colorant }
235250
236251function create_tileplot! (
237- config:: PlotConfig , axis:: AbstractAxis , data:: ImageData , bounds:: Rect , tile_crs
252+ config:: PlotConfig , axis:: AbstractAxis , m, data:: ImageData , bounds:: Rect , (tile, crs)
238253)
239254 mini, maxi = extrema (bounds)
240255 plot = Makie. image! (
@@ -244,11 +259,12 @@ function create_tileplot!(
244259 inspectable= false ,
245260 config. attributes...
246261 )
262+ translate! (plot, 0 , 0 , - 10 )
247263 return plot
248264end
249265
250266function update_tile_plot! (
251- plot:: Makie.Image , :: PlotConfig , axis:: AbstractAxis , data:: ImageData , bounds:: Rect , tile_crs
267+ plot:: Makie.Image , :: PlotConfig , axis:: AbstractAxis , m, data:: ImageData , bounds:: Rect , tile_crs
252268)
253269 mini, maxi = extrema (bounds)
254270 plot[1 ] = (mini[1 ], maxi[1 ])
@@ -280,7 +296,7 @@ function Base.map(f::Function, data::PointCloudData)
280296end
281297
282298function create_tileplot! (
283- config:: PlotConfig , axis:: AbstractAxis , data:: PointCloudData , :: Rect , tile_crs
299+ config:: PlotConfig , axis:: AbstractAxis , m, data:: PointCloudData , :: Rect , tile_crs
284300)
285301 p = Makie. scatter! (
286302 axis. scene, data. points;
@@ -296,7 +312,7 @@ function create_tileplot!(
296312end
297313
298314function update_tile_plot! (
299- plot:: Makie.Scatter , :: PlotConfig , :: AbstractAxis , data:: PointCloudData , bounds:: Rect , tile_crs
315+ plot:: Makie.Scatter , :: PlotConfig , :: AbstractAxis , m, data:: PointCloudData , bounds:: Rect , tile_crs
300316)
301317 plot. color. val = data. color
302318 plot[1 ] = data. points
@@ -312,7 +328,7 @@ get_preprocess(config::AbstractPlotConfig) = get_preprocess(config.plcfg)
312328get_postprocess (config:: AbstractPlotConfig ) = get_postprocess (config. plcfg)
313329
314330function create_tileplot! (
315- config:: MeshScatterPlotconfig , axis:: AbstractAxis , data:: PointCloudData , :: Rect , tile_crs
331+ config:: MeshScatterPlotconfig , axis:: AbstractAxis , m, data:: PointCloudData , :: Rect , tile_crs
316332)
317333 m = Rect3f (Vec3f (0 ), Vec3f (1 ))
318334 p = Makie. meshscatter! (
@@ -327,7 +343,7 @@ function create_tileplot!(
327343end
328344
329345function update_tile_plot! (
330- plot:: Makie.MeshScatter , :: MeshScatterPlotconfig , :: AbstractAxis , data:: PointCloudData , bounds:: Rect , tile_crs
346+ plot:: Makie.MeshScatter , :: MeshScatterPlotconfig , :: AbstractAxis , m, data:: PointCloudData , bounds:: Rect , tile_crs
331347)
332348 plot. color = data. color
333349 plot[1 ] = data. points
@@ -347,7 +363,7 @@ DebugPlotConfig(; plot_attributes...) =
347363 DebugPlotConfig (Dict {Symbol,Any} (plot_attributes))
348364
349365function create_tileplot! (
350- config:: DebugPlotConfig , axis:: AbstractAxis , data:: ImageData , bounds:: Rect , tile_crs
366+ config:: DebugPlotConfig , axis:: AbstractAxis , m, data:: ImageData , bounds:: Rect , tile_crs
351367)
352368 plot = Makie. poly! (
353369 axis. scene,
@@ -363,7 +379,7 @@ function create_tileplot!(
363379end
364380
365381function update_tile_plot! (
366- plot:: Makie.Poly , :: DebugPlotConfig , axis:: AbstractAxis , data:: ImageData , bounds:: Rect , tile_crs
382+ plot:: Makie.Poly , :: DebugPlotConfig , axis:: AbstractAxis , m, data:: ImageData , bounds:: Rect , tile_crs
367383)
368384 plot[1 ] = bounds
369385 plot. color = reverse (data; dims= 1 )
0 commit comments