|
| 1 | +-- --------------------------------------------------------------------------- |
| 2 | +-- |
| 3 | +-- Theme: experimental |
| 4 | +-- Topic: power |
| 5 | +-- |
| 6 | +-- --------------------------------------------------------------------------- |
| 7 | + |
| 8 | +local themepark, theme, cfg = ... |
| 9 | + |
| 10 | +themepark:add_table{ |
| 11 | + name = 'generators', |
| 12 | + ids_type = 'node', |
| 13 | + geom = 'point', |
| 14 | + columns = themepark:columns('core/name', { |
| 15 | + { column = 'energy_source', type = 'text' }, |
| 16 | + { column = 'solar_tracking', type = 'text' }, |
| 17 | + }) |
| 18 | +} |
| 19 | + |
| 20 | +themepark:add_table{ |
| 21 | + name = 'powerlines', |
| 22 | + ids_type = 'way', |
| 23 | + geom = 'linestring', |
| 24 | + columns = themepark:columns({ |
| 25 | + { column = 'voltage', type = 'int' }, |
| 26 | + { column = 'frequency', type = 'int' }, |
| 27 | + { column = 'cables', type = 'int' }, |
| 28 | + { column = 'operator', type = 'text' }, |
| 29 | + { column = 'operator_wikidata', type = 'text' }, |
| 30 | + }) |
| 31 | +} |
| 32 | + |
| 33 | +themepark:add_table{ |
| 34 | + name = 'powerplants', |
| 35 | + ids_type = 'area', |
| 36 | + geom = 'multipolygon', |
| 37 | + columns = themepark:columns('core/name', { |
| 38 | + { column = 'energy_source', type = 'text' }, |
| 39 | + }) |
| 40 | +} |
| 41 | + |
| 42 | +themepark:add_proc('node', function(object, data) |
| 43 | + if object.tags.power == 'generator' then |
| 44 | + local a = { |
| 45 | + geom = object:as_point() |
| 46 | + } |
| 47 | + |
| 48 | + themepark.themes.core.add_name(a, object) |
| 49 | + |
| 50 | + local source = object.tags['generator:source'] |
| 51 | + if source ~= nil and source:find(';') then |
| 52 | + source = nil |
| 53 | + end |
| 54 | + a.energy_source = source |
| 55 | + |
| 56 | + a.solar_tracking = object.tags['generator:solar:tracking'] |
| 57 | + |
| 58 | + themepark:insert('generators', a, object.tags) |
| 59 | + end |
| 60 | +end) |
| 61 | + |
| 62 | +themepark:add_proc('way', function(object, data) |
| 63 | + if object.tags.power == 'line' then |
| 64 | + local a = { |
| 65 | + geom = object:as_linestring(), |
| 66 | + voltage = object.tags.voltage, |
| 67 | + frequency = object.tags.frequency, |
| 68 | + cables = object.tags.cables, |
| 69 | + operator = object.tags.operator, |
| 70 | + operator_wikidata = object.tags['operator:wikidata'], |
| 71 | + } |
| 72 | + themepark:insert('powerlines', a, object.tags) |
| 73 | + end |
| 74 | +end) |
| 75 | + |
| 76 | +themepark:add_proc('area', function(object, data) |
| 77 | + if object.tags.power == 'plant' then |
| 78 | + local a = { |
| 79 | + geom = object:as_area() |
| 80 | + } |
| 81 | + |
| 82 | + themepark.themes.core.add_name(a, object) |
| 83 | + |
| 84 | + local source = object.tags['plant:source'] |
| 85 | + if source ~= nil and source:find(';') then |
| 86 | + source = nil |
| 87 | + end |
| 88 | + a.energy_source = source |
| 89 | + |
| 90 | + themepark:insert('powerplants', a, object.tags) |
| 91 | + end |
| 92 | +end) |
| 93 | + |
0 commit comments