biscuit

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 47d0f8edd24a0e64d10a46055b2770b9f4910d72
parent 0a437537376cc60457e584b6f2582bccf5927784
Author: Daniel Barlow <dan@telent.net>
Date:   Tue, 17 Mar 2026 13:23:12 +0000

WIP overlay gpx track on map

Diffstat:
Mpkgs/maps/main.fnl | 26+++++++++++++++++++++++---
1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/pkgs/maps/main.fnl b/pkgs/maps/main.fnl @@ -85,6 +85,9 @@ label.readout { (local state-widgets { }) +(local { : view } (require :fennel)) +(local gpx (require :gpx)) + (local app-state { :time-of-day 0 @@ -97,6 +100,9 @@ label.readout { :orientation 0 ; map rotation angle from north :rotation-speed 0 :tiles {} + :tracks [ + (gpx.get_trackpoints_only "track.gpx") + ] } ) @@ -207,6 +213,20 @@ label.readout { (cairo-road-path g line.points bounds) (g:stroke))) +(fn cairo-tracks [g tracks bounds] + (g:set_source_rgba 0.8 0 0 0.5) + (each [_ track (pairs tracks)] + (g:set_line_width 10) + (let [min bounds.min + { : line_to } g] + (g:move_to 0 0) + (each [_ { : lat : lon } (ipairs track)] + (let [(x y) (tiles.latlon->tile lat lon app-state.zoom) + x1 (* tile-size (- x min.x)) + y1 (* tile-size (- y min.y))] + (line_to g x1 y1)))) + (g:stroke))) + (var map-surface nil) @@ -238,6 +258,7 @@ label.readout { (fn draw-onto-map-surface [surface bounds zoom] (let [{ : num-tiles-x : num-tiles-y } bounds road-width 14 + tracks app-state.tracks lines []] (for [x bounds.min.x bounds.max.x] @@ -256,9 +277,11 @@ label.readout { (g:translate (- (// bounds.pixels.x 2)) (- (// bounds.pixels.y 2))) (cairo-roads g lines bounds) + (cairo-tracks g tracks bounds) (g:set_source_rgb 0.2 0.2 0.2) (g:set_font_size (+ road-width 1)) + (each [_ line (pairs lines)] (case line.name n (let [[tx ty angle] line.label-place @@ -564,8 +587,5 @@ label.readout { (when (os.getenv "MAP_PROFILE") (collect-profile)) (Gtk:main)) -;; (local { : view } (require :fennel)) -;; (local gpx (require :gpx)) -;; (print (view (gpx.get_trackpoints_only "route.gpx"))) { : run }