]> git.openstreetmap.org Git - nominatim.git/blob - test/bdd/osm2pgsql/import/custom_style.feature
penalize search with frequent partials
[nominatim.git] / test / bdd / osm2pgsql / import / custom_style.feature
1 @DB
2 Feature: Import with custom styles by osm2pgsql
3     Tests for the example customizations given in the documentation.
4
5     Scenario: Custom main tags
6         Given the lua style file
7             """
8             local flex = require('import-full')
9
10             flex.set_main_tags{
11                 boundary = {administrative = 'named'},
12                 highway = {'always', street_lamp = 'named'},
13                 landuse = 'fallback'
14             }
15             """
16         When loading osm data
17             """
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
24             """
25         Then place contains exactly
26             | object | class    | type           |
27             | N11    | boundary | administrative |
28             | N13    | highway  | primary        |
29             | N15    | highway  | primary        |
30
31     Scenario: Prefiltering tags
32         Given the lua style file
33             """
34             local flex = require('import-full')
35
36             flex.set_prefilters{
37                 delete_keys = {'source', 'source:*'},
38                 extra_tags = {amenity = {'yes', 'no'}}
39             }
40             flex.set_main_tags{
41                 amenity = 'always',
42                 tourism = 'always'
43             }
44             """
45         When loading osm data
46             """
47             n1 Tamenity=yes x0 y6
48             n2 Tamenity=hospital,source=survey x3 y6
49             n3 Ttourism=hotel,amenity=yes x0 y0
50             n4 Ttourism=hotel,amenity=telephone x0 y0
51             """
52         Then place contains exactly
53             | object     | extratags              |
54             | N2:amenity | -                      |
55             | N3:tourism | 'amenity': 'yes'       |
56             | N4:tourism | - |
57             | N4:amenity | - |
58
59     Scenario: Name tags
60         Given the lua style file
61             """
62             local flex = require('flex-base')
63
64             flex.set_main_tags{highway = {traffic_light = 'named'}}
65             flex.set_name_tags{main = {'name', 'name:*'},
66                                extra = {'ref'}
67                               }
68             """
69         When loading osm data
70             """
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
75             """
76         Then place contains exactly
77             | object     | name                       |
78             | N3:highway | 'name': 'Greens'           |
79             | N4:highway | 'name': 'Red', 'ref': '45' |
80
81     Scenario: Address tags
82         Given the lua style file
83             """
84             local flex = require('import-full')
85
86             flex.set_address_tags{
87                 main = {'addr:housenumber'},
88                 extra = {'addr:*'},
89                 postcode = {'postal_code', 'postcode', 'addr:postcode'},
90                 country = {'country-code', 'ISO3166-1'}
91             }
92             """
93         When loading osm data
94             """
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
98             """
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' |
103
104     Scenario: Unused handling
105         Given the lua style file
106             """
107             local flex = require('import-full')
108
109             flex.set_address_tags{
110                 main = {'addr:housenumber'},
111                 extra = {'addr:*', 'tiger:county'}
112             }
113             flex.set_unused_handling{delete_keys = {'tiger:*'}}
114             """
115         When loading osm data
116             """
117             n1 Ttourism=hotel,tiger:county=Fargo x0 y0
118             n2 Ttourism=hotel,tiger:xxd=56,else=other x0 y0
119             """
120         Then place contains exactly
121             | object     | type  | address                 | extratags        |
122             | N1:tourism | hotel | 'tiger:county': 'Fargo' | -                |
123             | N2:tourism | hotel | -                       | 'else': 'other'  |
124
125     Scenario: Additional relation types
126         Given the lua style file
127             """
128             local flex = require('import-full')
129
130             flex.RELATION_TYPES['site'] = flex.relation_as_multipolygon
131             """
132         And the grid
133             | 1 | 2 |
134             | 4 | 3 |
135         When loading osm data
136             """
137             n1
138             n2
139             n3
140             n4
141             w1 Nn1,n2,n3,n4,n1
142             r1 Ttype=multipolygon,amenity=school Mw1@
143             r2 Ttype=site,amenity=school Mw1@
144             """
145         Then place contains exactly
146             | object     | type   |
147             | R1:amenity | school |
148             | R2:amenity | school |
149
150     Scenario: Exclude country relations
151         Given the lua style file
152             """
153             local flex = require('import-full')
154
155             function osm2pgsql.process_relation(object)
156                 if object.tags.boundary ~= 'administrative' or object.tags.admin_level ~= '2' then
157                   flex.process_relation(object)
158                 end
159             end
160             """
161        And the grid
162             | 1 | 2 |
163             | 4 | 3 |
164        When loading osm data
165             """
166             n1
167             n2
168             n3
169             n4
170             w1 Nn1,n2,n3,n4,n1
171             r1 Ttype=multipolygon,boundary=administrative,admin_level=4,name=Small Mw1@
172             r2 Ttype=multipolygon,boundary=administrative,admin_level=2,name=Big Mw1@
173             """
174         Then place contains exactly
175             | object      | type           |
176             | R1:boundary | administrative |
177
178     Scenario: Customize processing functions
179         Given the lua style file
180             """
181             local flex = require('import-full')
182
183             local original_process_tags = flex.process_tags
184
185             function flex.process_tags(o)
186                 if o.object.tags.highway ~= nil and o.object.tags.access == 'no' then
187                     return
188                 end
189
190                 original_process_tags(o)
191             end
192             """
193         When loading osm data
194             """
195             n1 Thighway=residential x0 y0
196             n2 Thighway=residential,access=no x0 y0
197             """
198         Then place contains exactly
199             | object     | type        |
200             | N1:highway | residential |