|
| 1 | +-- --------------------------------------------------------------------------- |
| 2 | +-- |
| 3 | +-- Theme: experimental |
| 4 | +-- Topic: highways |
| 5 | +-- |
| 6 | +-- Osmium Prefilter: w/highway |
| 7 | +-- |
| 8 | +-- --------------------------------------------------------------------------- |
| 9 | + |
| 10 | +local themepark, theme, cfg = ... |
| 11 | + |
| 12 | +themepark:add_table({ |
| 13 | + name = 'highways', |
| 14 | + ids_type = 'way', |
| 15 | + geom = 'linestring', |
| 16 | + columns = themepark:columns('core/name', { |
| 17 | + { column = 'kind', type = 'text', not_null = true }, |
| 18 | + { column = 'tunnel', type = 'bool', not_null = true }, |
| 19 | + { column = 'bridge', type = 'bool', not_null = true }, |
| 20 | + { column = 'oneway', type = 'bool' }, |
| 21 | + { column = 'oneway_reverse', type = 'bool' }, |
| 22 | + { column = 'tracktype', type = 'text' }, |
| 23 | + { column = 'surface', type = 'text' }, |
| 24 | + { column = 'access', type = 'text' }, |
| 25 | + { column = 'foot', type = 'text' }, |
| 26 | + { column = 'bicycle', type = 'text' }, |
| 27 | + { column = 'horse', type = 'text' }, |
| 28 | + { column = 'layer', type = 'int', not_null = true }, |
| 29 | + { column = 'area_id', type = 'int8', create_only = true }, |
| 30 | + }), |
| 31 | +}) |
| 32 | + |
| 33 | +local as_bool = function(value) |
| 34 | + return value == 'yes' or value == 'true' or value == '1' |
| 35 | +end |
| 36 | + |
| 37 | +themepark:add_proc('way', function(object, data) |
| 38 | + local t = object.tags |
| 39 | + if t.highway then |
| 40 | + local a = { |
| 41 | + kind = t.highway, |
| 42 | + tunnel = as_bool(t.tunnel) or t.tunnel == 'building_passage' or t.covered == 'yes', |
| 43 | + bridge = as_bool(t.bridge), |
| 44 | + oneway = false, |
| 45 | + oneway_reverse = false, |
| 46 | + tracktype = t.tracktype, |
| 47 | + surface = t.surface, |
| 48 | + access = t.access, |
| 49 | + foot = t.foot, |
| 50 | + bicycle = t.bicycle, |
| 51 | + horse = t.horse, |
| 52 | + layer = data.core.layer, |
| 53 | + geom = object:as_linestring() |
| 54 | + } |
| 55 | + |
| 56 | + if t.oneway == 'yes' or t.oneway == '1' or t.oneway == 'true' then |
| 57 | + a.oneway = true |
| 58 | + elseif t.oneway == '-1' then |
| 59 | + a.oneway = true |
| 60 | + a.oneway_reverse = true |
| 61 | + end |
| 62 | + |
| 63 | + themepark.themes.core.add_name(a, object) |
| 64 | + |
| 65 | + themepark:insert('highways', a, t) |
| 66 | + end |
| 67 | +end) |
| 68 | + |
| 69 | +-- --------------------------------------------------------------------------- |
0 commit comments