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))
|
||||
|
||||
(fn cairo-roads-path [g lines bounds]
|
||||
(each [_ line (pairs lines)]
|
||||
(case line.points
|
||||
[[sx sy] & more]
|
||||
(do
|
||||
(g:save)
|
||||
(g:move_to (* tile-size (- sx bounds.min.x))
|
||||
(* tile-size (- sy bounds.min.y)))
|
||||
(each [_ [x y] (ipairs more)]
|
||||
(let [x1 (* tile-size (- x bounds.min.x))
|
||||
y1 (* tile-size (- y bounds.min.y))]
|
||||
(g:line_to x1 y1)))
|
||||
(g:stroke)
|
||||
(g:restore)))))
|
||||
(fn road-width-for [line offset]
|
||||
(+ (or offset 0)
|
||||
(case (?. line :tags :highway)
|
||||
:motorway 18
|
||||
: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:set_line_width width)
|
||||
(g:move_to (* tile-size (- sx bounds.min.x))
|
||||
(* tile-size (- sy bounds.min.y)))
|
||||
(each [_ [x y] (ipairs points)]
|
||||
(let [x1 (* tile-size (- x bounds.min.x))
|
||||
y1 (* tile-size (- y bounds.min.y))]
|
||||
(g:line_to x1 y1)))
|
||||
(g:stroke)
|
||||
(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]
|
||||
(var biggest 0)
|
||||
@ -132,8 +150,6 @@ label.readout {
|
||||
(* tile-size (- ny bounds.min.y))
|
||||
(+ math.pi angle)))))
|
||||
|
||||
|
||||
|
||||
(fn cairo-the-map [window]
|
||||
(let [{ : lat : lon : zoom } app-state
|
||||
{ : 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:fill)
|
||||
|
||||
(g:set_source_rgb 0 0 0)
|
||||
(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)
|
||||
(cairo-roads g lines bounds)
|
||||
|
||||
(g:set_source_rgb 0.2 0.2 0.2)
|
||||
(g:set_font_size (+ road-width 1))
|
||||
|
@ -71,6 +71,7 @@
|
||||
e.id
|
||||
{
|
||||
:name (?. e :tags :name)
|
||||
:tags e.tags
|
||||
:points
|
||||
(icollect [_ nd (ipairs e.nodes)]
|
||||
(let [node (. nodes nd)
|
||||
|
Loading…
Reference in New Issue
Block a user