2 Feature: Import with custom styles by osm2pgsql
3 Tests for the example customizations given in the documentation.
5 Scenario: Custom main tags
6 Given the lua style file
8 local flex = require('import-full')
11 boundary = {administrative = 'named'},
12 highway = {'always', street_lamp = 'named'},
18 n10 Tboundary=administrative x0 y0
19 n11 Tboundary=administrative,name=Foo x0 y0
20 n12 Tboundary=electoral x0 y0
21 n13 Thighway=primary x0 y0
22 n14 Thighway=street_lamp x0 y0
23 n15 Thighway=primary,landuse=street x0 y0
25 Then place contains exactly
26 | object | class | type |
27 | N11 | boundary | administrative |
28 | N13 | highway | primary |
29 | N15 | highway | primary |
31 Scenario: Prefiltering tags
32 Given the lua style file
34 local flex = require('import-full')
37 delete_keys = {'source', 'source:*'},
38 extra_tags = {amenity = {'yes', 'no'}}
48 n2 Tamenity=hospital,source=survey x3 y6
49 n3 Ttourism=hotel,amenity=yes x0 y0
50 n4 Ttourism=hotel,amenity=telephone x0 y0
52 Then place contains exactly
53 | object | extratags |
55 | N3:tourism | 'amenity': 'yes' |
60 Given the lua style file
62 local flex = require('flex-base')
64 flex.set_main_tags{highway = {traffic_light = 'named'}}
65 flex.set_name_tags{main = {'name', 'name:*'},
71 n1 Thighway=stop,name=Something x0 y0
72 n2 Thighway=traffic_light,ref=453-4 x0 y0
73 n3 Thighway=traffic_light,name=Greens x0 y0
74 n4 Thighway=traffic_light,name=Red,ref=45 x0 y0
76 Then place contains exactly
78 | N3:highway | 'name': 'Greens' |
79 | N4:highway | 'name': 'Red', 'ref': '45' |
81 Scenario: Address tags
82 Given the lua style file
84 local flex = require('import-full')
86 flex.set_address_tags{
87 main = {'addr:housenumber'},
89 postcode = {'postal_code', 'postcode', 'addr:postcode'},
90 country = {'country-code', 'ISO3166-1'}
95 n1 Ttourism=hotel,addr:street=Foo x0 y0
96 n2 Taddr:housenumber=23,addr:street=Budd,postal_code=5567 x0 y0
97 n3 Taddr:street=None,addr:city=Where x0 y0
99 Then place contains exactly
100 | object | type | address |
101 | N1:tourism | hotel | 'street': 'Foo' |
102 | N2:place | house | 'housenumber': '23', 'street': 'Budd', 'postcode': '5567' |
104 Scenario: Unused handling
105 Given the lua style file
107 local flex = require('import-full')
109 flex.set_address_tags{
110 main = {'addr:housenumber'},
111 extra = {'addr:*', 'tiger:county'}
113 flex.set_unused_handling{delete_keys = {'tiger:*'}}
115 When loading osm data
117 n1 Ttourism=hotel,tiger:county=Fargo x0 y0
118 n2 Ttourism=hotel,tiger:xxd=56,else=other x0 y0
120 Then place contains exactly
121 | object | type | address | extratags |
122 | N1:tourism | hotel | 'tiger:county': 'Fargo' | - |
123 | N2:tourism | hotel | - | 'else': 'other' |
125 Scenario: Additional relation types
126 Given the lua style file
128 local flex = require('import-full')
130 flex.RELATION_TYPES['site'] = flex.relation_as_multipolygon
135 When loading osm data
142 r1 Ttype=multipolygon,amenity=school Mw1@
143 r2 Ttype=site,amenity=school Mw1@
145 Then place contains exactly
147 | R1:amenity | school |
148 | R2:amenity | school |
150 Scenario: Exclude country relations
151 Given the lua style file
153 local flex = require('import-full')
155 function osm2pgsql.process_relation(object)
156 if object.tags.boundary ~= 'administrative' or object.tags.admin_level ~= '2' then
157 flex.process_relation(object)
164 When loading osm data
171 r1 Ttype=multipolygon,boundary=administrative,admin_level=4,name=Small Mw1@
172 r2 Ttype=multipolygon,boundary=administrative,admin_level=2,name=Big Mw1@
174 Then place contains exactly
176 | R1:boundary | administrative |
178 Scenario: Customize processing functions
179 Given the lua style file
181 local flex = require('import-full')
183 local original_process_tags = flex.process_tags
185 function flex.process_tags(o)
186 if o.object.tags.highway ~= nil and o.object.tags.access == 'no' then
190 original_process_tags(o)
193 When loading osm data
195 n1 Thighway=residential x0 y0
196 n2 Thighway=residential,access=no x0 y0
198 Then place contains exactly
200 | N1:highway | residential |