Skip to content

Commit 1ac2376

Browse files
committed
Add tags for untagged callbacks
1 parent c5e6385 commit 1ac2376

File tree

2 files changed

+147
-0
lines changed

2 files changed

+147
-0
lines changed

tests/bdd/flex/untagged.feature

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
Feature: Adding untagged objects to a flex database
2+
3+
Scenario: Import with normal and "untagged" callbacks
4+
Given the style file 'test_output_flex_untagged.lua'
5+
And the OSM data
6+
"""
7+
n11 v1 dV x1 y1
8+
n12 v1 dV x2 y2
9+
n13 v1 dV x3 y3
10+
n14 v1 dV Tamenity=restaurant x4 y4
11+
w20 v1 dV Thighway=primary Nn11,n12
12+
w21 v1 dV Nn13,n14
13+
r30 v1 dV Mn11@,w20@
14+
r31 v1 dV Ttype=route Mw20@
15+
"""
16+
When running osm2pgsql flex
17+
Then table osm2pgsql_test_nodes contains exactly
18+
| node_id | tagged | tags |
19+
| 11 | False | {} |
20+
| 12 | False | {} |
21+
| 13 | False | {} |
22+
| 14 | True | {'amenity': 'restaurant'} |
23+
24+
Then table osm2pgsql_test_ways contains exactly
25+
| way_id | tagged | tags |
26+
| 20 | True | {'highway': 'primary'} |
27+
| 21 | False | {} |
28+
29+
Then table osm2pgsql_test_relations contains exactly
30+
| relation_id | tagged | tags |
31+
| 30 | False | {} |
32+
| 31 | True | {'type': 'route'} |
33+
34+
Scenario: Import then update with normal and "untagged" callbacks
35+
Given the style file 'test_output_flex_untagged.lua'
36+
And the OSM data
37+
"""
38+
n11 v1 dV x1 y1
39+
n12 v1 dV x2 y2
40+
n13 v1 dV x3 y3
41+
n14 v1 dV Tamenity=restaurant x4 y4
42+
w20 v1 dV Thighway=primary Nn11,n12
43+
w21 v1 dV Nn13,n14
44+
w22 v1 dV Nn11,n12
45+
r30 v1 dV Mn11@,w20@
46+
r31 v1 dV Ttype=route Mw20@
47+
"""
48+
When running osm2pgsql flex with parameters
49+
| --slim |
50+
Then table osm2pgsql_test_nodes contains exactly
51+
| node_id | tagged | tags |
52+
| 11 | False | {} |
53+
| 12 | False | {} |
54+
| 13 | False | {} |
55+
| 14 | True | {'amenity': 'restaurant'} |
56+
57+
Then table osm2pgsql_test_ways contains exactly
58+
| way_id | tagged | tags |
59+
| 20 | True | {'highway': 'primary'} |
60+
| 21 | False | {} |
61+
| 22 | False | {} |
62+
63+
Then table osm2pgsql_test_relations contains exactly
64+
| relation_id | tagged | tags |
65+
| 30 | False | {} |
66+
| 31 | True | {'type': 'route'} |
67+
68+
Given the style file 'test_output_flex_untagged.lua'
69+
And the OSM data
70+
"""
71+
n11 v2 dV Tnatural=tree x1 y1
72+
n14 v2 dV x4 y4
73+
w21 v2 dV Nn14,n13
74+
"""
75+
When running osm2pgsql flex with parameters
76+
| --slim | -a |
77+
Then table osm2pgsql_test_nodes contains exactly
78+
| node_id | tagged | tags |
79+
| 11 | True | {'natural': 'tree'} |
80+
| 12 | False | {} |
81+
| 13 | False | {} |
82+
| 14 | False | {} |
83+
84+
Then table osm2pgsql_test_ways contains exactly
85+
| way_id | tagged | tags |
86+
| 20 | True | {'highway': 'primary'} |
87+
| 21 | False | {} |
88+
| 22 | False | {} |
89+
90+
Then table osm2pgsql_test_relations contains exactly
91+
| relation_id | tagged | tags |
92+
| 30 | False | {} |
93+
| 31 | True | {'type': 'route'} |
94+
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
2+
local tables = {}
3+
4+
tables.nodes = osm2pgsql.define_node_table('osm2pgsql_test_nodes', {
5+
{ column = 'tags', type = 'jsonb' },
6+
{ column = 'tagged', type = 'bool' },
7+
{ column = 'geom', type = 'point', not_null = true },
8+
})
9+
10+
tables.ways = osm2pgsql.define_way_table('osm2pgsql_test_ways', {
11+
{ column = 'tags', type = 'jsonb' },
12+
{ column = 'tagged', type = 'bool' },
13+
{ column = 'geom', type = 'linestring', not_null = true },
14+
})
15+
16+
tables.relations = osm2pgsql.define_relation_table('osm2pgsql_test_relations', {
17+
{ column = 'tags', type = 'jsonb' },
18+
{ column = 'tagged', type = 'bool' },
19+
{ column = 'geom', type = 'geometry', not_null = true },
20+
})
21+
22+
function insert(dtable, object, tagged, geom)
23+
tables[dtable]:insert({
24+
tags = object.tags,
25+
tagged = tagged,
26+
geom = geom,
27+
})
28+
end
29+
30+
function osm2pgsql.process_node(object)
31+
insert('nodes', object, true, object:as_point())
32+
end
33+
34+
function osm2pgsql.process_way(object)
35+
insert('ways', object, true, object:as_linestring())
36+
end
37+
38+
function osm2pgsql.process_relation(object)
39+
insert('relations', object, true, object:as_geometrycollection())
40+
end
41+
42+
function osm2pgsql.process_untagged_node(object)
43+
insert('nodes', object, false, object:as_point())
44+
end
45+
46+
function osm2pgsql.process_untagged_way(object)
47+
insert('ways', object, false, object:as_linestring())
48+
end
49+
50+
function osm2pgsql.process_untagged_relation(object)
51+
insert('relations', object, false, object:as_geometrycollection())
52+
end
53+

0 commit comments

Comments
 (0)