print fewer upside down road labels

This commit is contained in:
Daniel Barlow 2025-06-04 00:14:43 +01:00
parent e728052bb6
commit c53120ab2a

View File

@ -122,10 +122,16 @@ label.readout {
(let [[x y] (. points biggest-n)
[nx ny] (. points (+ 1 biggest-n))
angle (math.atan (- ny y) (- nx x))]
(values
(* tile-size (- x bounds.min.x))
(* tile-size (- y bounds.min.y))
angle)))
(if (> nx x)
(values
(* tile-size (- x bounds.min.x))
(* tile-size (- y bounds.min.y))
angle)
(values ; if way runs r->l, prefer label to read l->r
(* tile-size (- nx bounds.min.x))
(* tile-size (- ny bounds.min.y))
(+ math.pi angle)))))
(fn cairo-the-map [window]