add on-completion callback to tile fetcher, invalidate map-surface

This commit is contained in:
Daniel Barlow 2025-06-02 13:33:51 +01:00
parent cdd7ea3a94
commit fef52f812a
2 changed files with 7 additions and 3 deletions

View File

@ -150,6 +150,8 @@ label.readout {
(* tile-size (- ny bounds.min.y))
(+ math.pi angle)))))
(var map-surface nil)
(fn cairo-the-map [window]
(let [{ : lat : lon : zoom } app-state
{ : num-tiles-x : num-tiles-y &as bounds } (map-bounds lat lon zoom)
@ -158,7 +160,9 @@ label.readout {
(for [x bounds.min.x bounds.max.x]
(for [y bounds.min.y bounds.max.y]
(merge lines (tiles.polylines cq x y zoom))))
(merge lines (tiles.polylines cq x y zoom
#(set map-surface nil)
))))
(let [map-surface
(window:create_similar_surface
@ -203,7 +207,6 @@ label.readout {
map-surface)))
(var map-surface nil)
(fn on-osm-draw [widget g]
(when (not map-surface)

View File

@ -109,7 +109,7 @@
;; we'd like to have a way for completed background fetch to signal
;; so that the map can be redrawn
(fn polylines [cq x y zoom]
(fn polylines [cq x y zoom cb]
(let [k (.. x "_" y "_" zoom)
pathname (.. "/tmp/tiles/" k ".json")]
(if (file-exists? pathname)
@ -129,6 +129,7 @@
(cqueues.sleep (math.random 2 6))))
(print "got " k)
(f:write json)
(cb)
true)))
[] ; return no lines for now
))))