Skip to content

Commit cc61981

Browse files
committed
Experimental topics to extract protected areas and highways
1 parent 6ecbf28 commit cc61981

File tree

3 files changed

+153
-0
lines changed

3 files changed

+153
-0
lines changed

config/protected_areas.lua

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
-- ---------------------------------------------------------------------------
2+
--
3+
-- Example config for protected_areas topic
4+
--
5+
-- Configuration for the osm2pgsql Themepark framework
6+
--
7+
-- ---------------------------------------------------------------------------
8+
9+
local themepark = require('themepark')
10+
11+
themepark.debug = true
12+
13+
themepark:set_option('srid', 4326)
14+
themepark:set_option('tags', 'all_tags')
15+
16+
-- ---------------------------------------------------------------------------
17+
18+
themepark:add_topic('core/clean-tags')
19+
themepark:add_topic('core/layer')
20+
21+
themepark:add_topic('core/name-single', { column = 'name' })
22+
themepark:add_topic('experimental/protected_areas')
23+
themepark:add_topic('experimental/highways')
24+
25+
-- ---------------------------------------------------------------------------
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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+
-- ---------------------------------------------------------------------------
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
-- ---------------------------------------------------------------------------
2+
--
3+
-- Theme: experimental
4+
-- Topic: protected_areas
5+
--
6+
-- Osmium Prefilter: boundary=protected_area,national_park,water_protection_area
7+
-- protect_class protection_title short_protection_title
8+
--
9+
-- ---------------------------------------------------------------------------
10+
11+
local themepark, theme, cfg = ...
12+
13+
themepark:add_table{
14+
name = 'protected_areas',
15+
ids_type = 'area',
16+
geom = 'multipolygon',
17+
columns = themepark:columns('core/name', {
18+
{ column = 'boundary', type = 'text' },
19+
{ column = 'protect_class', type = 'text' },
20+
{ column = 'protection_title', type = 'text' },
21+
{ column = 'short_protection_title', type = 'text' },
22+
{ column = 'ref', type = 'text' },
23+
{ column = 'access', type = 'text' },
24+
{ column = 'wikidata', type = 'text' }, -- WIKIDATA https://www.wikidata.org/wiki/Q123
25+
{ column = 'wdpa', type = 'text' }, -- WDPA https://www.protectedplanet.net/32666
26+
{ column = 'iucn', type = 'text' },
27+
{ column = 'iucn_level', type = 'text' },
28+
{ column = 'dtp_id', type = 'text' }, -- DIGITIZE THE PLANET
29+
-- https://content.digitizetheplanet.org/de/rules/show_protectedarea/bc04f80f-5342-4c40-8d13-1da5be7da6ea
30+
{ column = 'capad_pa_id', type = 'text' }, -- Collaborative Australian Protected Areas Database (CAPAD)
31+
}),
32+
}
33+
34+
themepark:add_proc('area', function(object, data)
35+
local t = object.tags
36+
if t.boundary == 'protected_area' or t.boundary == 'national_park' or t.boundary == 'water_protection_area' then
37+
local a = {
38+
boundary = t.boundary,
39+
protect_class = t.protect_class,
40+
protection_title = t.protection_title,
41+
short_protection_title = t.short_protection_title,
42+
ref = t.ref,
43+
access = t.access,
44+
wikidata = t.wikidata,
45+
wdpa = t['ref:WDPA'],
46+
iucn = t['ref:IUCN'],
47+
iucn_level = t.iucn_level,
48+
dtp_id = t.dtp_id,
49+
capad_pa_id = t['ref:capad:pa_id'],
50+
geom = object:as_area(),
51+
}
52+
53+
themepark.themes.core.add_name(a, object)
54+
55+
themepark:insert('protected_areas', a, t)
56+
end
57+
end)
58+
59+
-- ---------------------------------------------------------------------------

0 commit comments

Comments
 (0)