first go at varying the line width based on highway classification
This commit is contained in:
parent
e5e1060c3f
commit
63e592d33d
@ -91,20 +91,38 @@ label.readout {
|
|||||||
|
|
||||||
(local cq (cqueues.new))
|
(local cq (cqueues.new))
|
||||||
|
|
||||||
(fn cairo-roads-path [g lines bounds]
|
(fn road-width-for [line offset]
|
||||||
(each [_ line (pairs lines)]
|
(+ (or offset 0)
|
||||||
(case line.points
|
(case (?. line :tags :highway)
|
||||||
[[sx sy] & more]
|
:motorway 18
|
||||||
(do
|
:trunk 17
|
||||||
|
:primary 16
|
||||||
|
:secondary 14
|
||||||
|
:cycleway 4
|
||||||
|
:footway 4
|
||||||
|
other (do (print "highway " other) 12))))
|
||||||
|
|
||||||
|
(fn cairo-road-path [g [[sx sy] & points] bounds width]
|
||||||
(g:save)
|
(g:save)
|
||||||
|
(g:set_line_width width)
|
||||||
(g:move_to (* tile-size (- sx bounds.min.x))
|
(g:move_to (* tile-size (- sx bounds.min.x))
|
||||||
(* tile-size (- sy bounds.min.y)))
|
(* tile-size (- sy bounds.min.y)))
|
||||||
(each [_ [x y] (ipairs more)]
|
(each [_ [x y] (ipairs points)]
|
||||||
(let [x1 (* tile-size (- x bounds.min.x))
|
(let [x1 (* tile-size (- x bounds.min.x))
|
||||||
y1 (* tile-size (- y bounds.min.y))]
|
y1 (* tile-size (- y bounds.min.y))]
|
||||||
(g:line_to x1 y1)))
|
(g:line_to x1 y1)))
|
||||||
(g:stroke)
|
(g:stroke)
|
||||||
(g:restore)))))
|
(g:restore))
|
||||||
|
|
||||||
|
|
||||||
|
(fn cairo-roads [g lines bounds]
|
||||||
|
(let [road-width 14]
|
||||||
|
(g:set_source_rgb 0 0 0)
|
||||||
|
(each [_ line (pairs lines)]
|
||||||
|
(cairo-road-path g line.points bounds (road-width-for line)))
|
||||||
|
(g:set_source_rgb 1 1 1)
|
||||||
|
(each [_ line (pairs lines)]
|
||||||
|
(cairo-road-path g line.points bounds (road-width-for line -2)))))
|
||||||
|
|
||||||
(fn label-coords [{ : points } bounds]
|
(fn label-coords [{ : points } bounds]
|
||||||
(var biggest 0)
|
(var biggest 0)
|
||||||
@ -132,8 +150,6 @@ label.readout {
|
|||||||
(* tile-size (- ny bounds.min.y))
|
(* tile-size (- ny bounds.min.y))
|
||||||
(+ math.pi angle)))))
|
(+ math.pi angle)))))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(fn cairo-the-map [window]
|
(fn cairo-the-map [window]
|
||||||
(let [{ : lat : lon : zoom } app-state
|
(let [{ : lat : lon : zoom } app-state
|
||||||
{ : num-tiles-x : num-tiles-y &as bounds } (map-bounds lat lon zoom)
|
{ : num-tiles-x : num-tiles-y &as bounds } (map-bounds lat lon zoom)
|
||||||
@ -156,12 +172,7 @@ label.readout {
|
|||||||
(g:rectangle 0 0 (* tile-size num-tiles-x) (* tile-size num-tiles-y))
|
(g:rectangle 0 0 (* tile-size num-tiles-x) (* tile-size num-tiles-y))
|
||||||
(g:fill)
|
(g:fill)
|
||||||
|
|
||||||
(g:set_source_rgb 0 0 0)
|
(cairo-roads g lines bounds)
|
||||||
(g:set_line_width road-width)
|
|
||||||
(cairo-roads-path g lines bounds)
|
|
||||||
(g:set_source_rgb 1 1 1)
|
|
||||||
(g:set_line_width (- road-width 2))
|
|
||||||
(cairo-roads-path g lines bounds)
|
|
||||||
|
|
||||||
(g:set_source_rgb 0.2 0.2 0.2)
|
(g:set_source_rgb 0.2 0.2 0.2)
|
||||||
(g:set_font_size (+ road-width 1))
|
(g:set_font_size (+ road-width 1))
|
||||||
|
@ -71,6 +71,7 @@
|
|||||||
e.id
|
e.id
|
||||||
{
|
{
|
||||||
:name (?. e :tags :name)
|
:name (?. e :tags :name)
|
||||||
|
:tags e.tags
|
||||||
:points
|
:points
|
||||||
(icollect [_ nd (ipairs e.nodes)]
|
(icollect [_ nd (ipairs e.nodes)]
|
||||||
(let [node (. nodes nd)
|
(let [node (. nodes nd)
|
||||||
|
Loading…
Reference in New Issue
Block a user