]> git.openstreetmap.org Git - nominatim.git/blob - test/bdd/db/import/parenting.feature
c00f47016f23af13afbbedc9b35f7e450b121090
[nominatim.git] / test / bdd / db / import / parenting.feature
1 @DB
2 Feature: Parenting of objects
3     Tests that the correct parent is choosen
4
5     Scenario: Address inherits postcode from its street unless it has a postcode
6         Given the scene roads-with-pois
7         And the places
8          | osm | class | type  | housenr | geometry |
9          | N1  | place | house | 4       | :p-N1 |
10         And the places
11          | osm | class | type  | housenr | postcode | geometry |
12          | N2  | place | house | 5       | 99999    | :p-N1 |
13         And the places
14          | osm | class   | type        | name  | postcode | geometry |
15          | W1  | highway | residential | galoo | 12345    | :w-north |
16         When importing
17         Then placex contains
18          | object | parent_place_id |
19          | N1     | W1 |
20          | N2     | W1 |
21         And search_name contains
22          | object | nameaddress_vector |
23          | N1     | 4, galoo, 12345 |
24          | N2     | 5, galoo, 99999 |
25
26     Scenario: Address without tags, closest street
27         Given the scene roads-with-pois
28         And the places
29          | osm | class | type  | geometry |
30          | N1  | place | house | :p-N1 |
31          | N2  | place | house | :p-N2 |
32          | N3  | place | house | :p-S1 |
33          | N4  | place | house | :p-S2 |
34         And the named places
35          | osm | class   | type        | geometry |
36          | W1  | highway | residential | :w-north |
37          | W2  | highway | residential | :w-south |
38         When importing
39         Then placex contains
40          | object | parent_place_id |
41          | N1     | W1 |
42          | N2     | W1 |
43          | N3     | W2 |
44          | N4     | W2 |
45
46     Scenario: Address without tags avoids unnamed streets
47         Given the scene roads-with-pois
48         And the places
49          | osm | class   | type  | geometry |
50          | N1  | place   | house | :p-N1 |
51          | N2  | place   | house | :p-N2 |
52          | N3  | place   | house | :p-S1 |
53          | N4  | place   | house | :p-S2 |
54          | W1  | highway | residential | :w-north |
55         And the named places
56          | osm | class   | type        | geometry |
57          | W2  | highway | residential | :w-south |
58         When importing
59         Then placex contains
60          | object | parent_place_id |
61          | N1     | W2 |
62          | N2     | W2 |
63          | N3     | W2 |
64          | N4     | W2 |
65
66     Scenario: addr:street tag parents to appropriately named street
67         Given the scene roads-with-pois
68         And the places
69          | osm | class | type  | street| geometry |
70          | N1  | place | house | south | :p-N1 |
71          | N2  | place | house | north | :p-N2 |
72          | N3  | place | house | south | :p-S1 |
73          | N4  | place | house | north | :p-S2 |
74         And the places
75          | osm | class   | type        | name  | geometry |
76          | W1  | highway | residential | north | :w-north |
77          | W2  | highway | residential | south | :w-south |
78         When importing
79         Then placex contains
80          | object | parent_place_id |
81          | N1     | W2 |
82          | N2     | W1 |
83          | N3     | W2 |
84          | N4     | W1 |
85
86     Scenario: addr:street tag parents to next named street
87         Given the scene roads-with-pois
88         And the places
89          | osm | class | type  | street | geometry |
90          | N1  | place | house | abcdef | :p-N1 |
91          | N2  | place | house | abcdef | :p-N2 |
92          | N3  | place | house | abcdef | :p-S1 |
93          | N4  | place | house | abcdef | :p-S2 |
94         And the places
95          | osm | class   | type        | name   | geometry |
96          | W1  | highway | residential | abcdef | :w-north |
97          | W2  | highway | residential | abcdef | :w-south |
98         When importing
99         Then placex contains
100          | object | parent_place_id |
101          | N1     | W1 |
102          | N2     | W1 |
103          | N3     | W2 |
104          | N4     | W2 |
105
106     Scenario: addr:street tag without appropriately named street
107         Given the scene roads-with-pois
108         And the places
109          | osm | class | type  | street | geometry |
110          | N1  | place | house | abcdef | :p-N1 |
111          | N2  | place | house | abcdef | :p-N2 |
112          | N3  | place | house | abcdef | :p-S1 |
113          | N4  | place | house | abcdef | :p-S2 |
114         And the places
115          | osm | class   | type        | name  | geometry |
116          | W1  | highway | residential | abcde | :w-north |
117          | W2  | highway | residential | abcde | :w-south |
118         When importing
119         Then placex contains
120          | object | parent_place_id |
121          | N1     | W1 |
122          | N2     | W1 |
123          | N3     | W2 |
124          | N4     | W2 |
125
126     Scenario: addr:place address
127         Given the scene road-with-alley
128         And the places
129          | osm | class | type   | addr_place | geometry |
130          | N1  | place | house  | myhamlet   | :n-alley |
131         And the places
132          | osm | class   | type        | name     | geometry |
133          | N2  | place   | hamlet      | myhamlet | :n-main-west |
134          | W1  | highway | residential | myhamlet | :w-main |
135         When importing
136         Then placex contains
137          | object | parent_place_id |
138          | N1     | N2 |
139
140     Scenario: addr:street is preferred over addr:place
141         Given the scene road-with-alley
142         And the places
143          | osm | class | type   | addr_place | street  | geometry |
144          | N1  | place | house  | myhamlet   | mystreet| :n-alley |
145         And the places
146          | osm | class   | type        | name     | geometry |
147          | N2  | place   | hamlet      | myhamlet | :n-main-west |
148          | W1  | highway | residential | mystreet | :w-main |
149         When importing
150         Then placex contains
151          | object | parent_place_id |
152          | N1     | W1 |
153
154     Scenario: Untagged address in simple associated street relation
155         Given the scene road-with-alley
156         And the places
157          | osm | class | type  | geometry |
158          | N1  | place | house | :n-alley |
159          | N2  | place | house | :n-corner |
160          | N3  | place | house | :n-main-west |
161         And the places
162          | osm | class   | type        | name | geometry |
163          | W1  | highway | residential | foo  | :w-main |
164          | W2  | highway | service     | bar  | :w-alley |
165         And the relations
166          | id | members            | tags+type |
167          | 1  | W1:street,N1,N2,N3 | associatedStreet |
168         When importing
169         Then placex contains
170          | object | parent_place_id |
171          | N1     | W1 |
172          | N2     | W1 |
173          | N3     | W1 |
174
175     Scenario: Avoid unnamed streets in simple associated street relation
176         Given the scene road-with-alley
177         And the places
178          | osm | class | type  | geometry |
179          | N1  | place | house | :n-alley |
180          | N2  | place | house | :n-corner |
181          | N3  | place | house | :n-main-west |
182          | W2  | highway | residential | :w-alley |
183         And the named places
184          | osm | class   | type        | geometry |
185          | W1  | highway | residential | :w-main |
186         And the relations
187          | id | members                      | tags+type |
188          | 1  | N1,N2,N3,W2:street,W1:street | associatedStreet |
189         When importing
190         Then placex contains
191          | object | parent_place_id |
192          | N1     | W1 |
193          | N2     | W1 |
194          | N3     | W1 |
195
196     Scenario: Associated street relation overrides addr:street
197         Given the scene road-with-alley
198         And the places
199          | osm | class | type  | street | geometry |
200          | N1  | place | house | bar    | :n-alley |
201         And the places
202          | osm | class   | type        | name | geometry |
203          | W1  | highway | residential | foo  | :w-main |
204          | W2  | highway | residential | bar  | :w-alley |
205         And the relations
206          | id | members            | tags+type |
207          | 1  | W1:street,N1,N2,N3 | associatedStreet |
208         When importing
209         Then placex contains
210          | object | parent_place_id |
211          | N1     | W1 |
212
213     Scenario: Building without tags, closest street from center point
214         Given the scene building-on-street-corner
215         And the named places
216          | osm | class    | type        | geometry |
217          | W1  | building | yes         | :w-building |
218          | W2  | highway  | primary     | :w-WE |
219          | W3  | highway  | residential | :w-NS |
220         When importing
221         Then placex contains
222          | object | parent_place_id |
223          | W1     | W3 |
224
225     Scenario: Building with addr:street tags
226         Given the scene building-on-street-corner
227         And the named places
228          | osm | class    | type | street | geometry |
229          | W1  | building | yes  | bar    | :w-building |
230         And the places
231          | osm | class    | type        | name | geometry |
232          | W2  | highway  | primary     | bar  | :w-WE |
233          | W3  | highway  | residential | foo  | :w-NS |
234         When importing
235         Then placex contains
236          | object | parent_place_id |
237          | W1     | W2 |
238
239     Scenario: Building with addr:place tags
240         Given the scene building-on-street-corner
241         And the places
242          | osm | class    | type        | name | geometry |
243          | N1  | place    | village     | bar  | :n-outer |
244          | W2  | highway  | primary     | bar  | :w-WE |
245          | W3  | highway  | residential | foo  | :w-NS |
246         And the named places
247          | osm | class    | type | addr_place | geometry |
248          | W1  | building | yes  | bar        | :w-building |
249         When importing
250         Then placex contains
251          | object | parent_place_id |
252          | W1     | N1 |
253
254     Scenario: Building in associated street relation
255         Given the scene building-on-street-corner
256         And the named places
257          | osm | class    | type | geometry |
258          | W1  | building | yes  | :w-building |
259         And the places
260          | osm | class    | type        | name | geometry |
261          | W2  | highway  | primary     | bar  | :w-WE |
262          | W3  | highway  | residential | foo  | :w-NS |
263         And the relations
264          | id | members            | tags+type |
265          | 1  | W1:house,W2:street | associatedStreet |
266         When importing
267         Then placex contains
268          | object | parent_place_id |
269          | W1     | W2 |
270
271     Scenario: Building in associated street relation overrides addr:street
272         Given the scene building-on-street-corner
273         And the named places
274          | osm | class    | type | street | geometry |
275          | W1  | building | yes  | foo    | :w-building |
276         And the places
277          | osm | class    | type        | name | geometry |
278          | W2  | highway  | primary     | bar  | :w-WE |
279          | W3  | highway  | residential | foo  | :w-NS |
280         And the relations
281          | id | members            | tags+type |
282          | 1  | W1:house,W2:street | associatedStreet |
283         When importing
284         Then placex contains
285          | object | parent_place_id |
286          | W1     | W2 |
287
288     Scenario: Wrong member in associated street relation is ignored
289         Given the scene building-on-street-corner
290         And the named places
291          | osm | class | type  | geometry |
292          | N1  | place | house | :n-outer |
293         And the named places
294          | osm | class    | type | street | geometry |
295          | W1  | building | yes  | foo    | :w-building |
296         And the places
297          | osm | class    | type        | name | geometry |
298          | W2  | highway  | primary     | bar  | :w-WE |
299          | W3  | highway  | residential | foo  | :w-NS |
300         And the relations
301          | id | members                      | tags+type |
302          | 1  | N1:house,W1:street,W3:street | associatedStreet |
303         When importing
304         Then placex contains
305          | object | parent_place_id |
306          | N1     | W3 |
307
308     Scenario: POIs in building inherit address
309         Given the scene building-on-street-corner
310         And the named places
311          | osm | class   | type       | geometry |
312          | N1  | amenity | bank       | :n-inner |
313          | N2  | shop    | bakery     | :n-edge-NS |
314          | N3  | shop    | supermarket| :n-edge-WE |
315         And the places
316          | osm | class    | type | street | addr_place | housenr | geometry |
317          | W1  | building | yes  | foo    | nowhere    | 3       | :w-building |
318         And the places
319          | osm | class    | type        | name | geometry |
320          | W2  | highway  | primary     | bar  | :w-WE |
321          | W3  | highway  | residential | foo  | :w-NS |
322         When importing
323         Then placex contains
324          | object | parent_place_id | street | addr_place | housenumber |
325          | W1     | W3              | foo    | nowhere    | 3 |
326          | N1     | W3              | foo    | nowhere    | 3 |
327          | N2     | W3              | foo    | nowhere    | 3 |
328          | N3     | W3              | foo    | nowhere    | 3 |
329
330     Scenario: POIs don't inherit from streets
331         Given the scene building-on-street-corner
332         And the named places
333          | osm | class   | type       | geometry |
334          | N1  | amenity | bank       | :n-inner |
335         And the places
336          | osm | class    | type | street | addr_place | housenr | geometry |
337          | W1  | highway  | path | foo    | nowhere    | 3       | :w-building |
338         And the places
339          | osm | class    | type        | name | geometry |
340          | W3  | highway  | residential | foo  | :w-NS |
341         When importing
342         Then placex contains
343          | object | parent_place_id | street | addr_place | housenumber |
344          | N1     | W3              | None   | None       | None |
345
346     Scenario: POIs with own address do not inherit building address
347         Given the scene building-on-street-corner
348         And the named places
349          | osm | class   | type       | street | geometry |
350          | N1  | amenity | bank       | bar    | :n-inner |
351         And the named places
352          | osm | class   | type       | housenr | geometry |
353          | N2  | shop    | bakery     | 4       | :n-edge-NS |
354         And the named places
355          | osm | class   | type       | addr_place  | geometry |
356          | N3  | shop    | supermarket| nowhere     | :n-edge-WE |
357         And the places
358          | osm | class | type              | name     | geometry |
359          | N4  | place | isolated_dwelling | theplace | :n-outer |
360         And the places
361          | osm | class    | type | addr_place | housenr | geometry |
362          | W1  | building | yes  | theplace   | 3       | :w-building |
363         And the places
364          | osm | class    | type        | name | geometry |
365          | W2  | highway  | primary     | bar  | :w-WE |
366          | W3  | highway  | residential | foo  | :w-NS |
367         When importing
368         Then placex contains
369          | object | parent_place_id | street | addr_place | housenumber |
370          | W1     | N4              | None   | theplace   | 3 |
371          | N1     | W2              | bar    | None       | None |
372          | N2     | W3              | None   | None       | 4 |
373          | N3     | W2              | None   | nowhere    | None |
374
375     Scenario: POIs parent a road if they are attached to it
376         Given the scene points-on-roads
377         And the named places
378          | osm | class   | type     | street   | geometry |
379          | N1  | highway | bus_stop | North St | :n-SE |
380          | N2  | highway | bus_stop | South St | :n-NW |
381          | N3  | highway | bus_stop | North St | :n-S-unglued |
382          | N4  | highway | bus_stop | South St | :n-N-unglued |
383         And the places
384          | osm | class   | type         | name     | geometry |
385          | W1  | highway | secondary    | North St | :w-north |
386          | W2  | highway | unclassified | South St | :w-south |
387         And the ways
388          | id | nodes |
389          | 1  | 100,101,2,103,104 |
390          | 2  | 200,201,1,202,203 |
391         When importing
392         Then placex contains
393          | object | parent_place_id |
394          | N1     | W1 |
395          | N2     | W2 |
396          | N3     | W1 |
397          | N4     | W2 |
398
399     Scenario: POIs do not parent non-roads they are attached to
400         Given the scene points-on-roads
401         And the named places
402          | osm | class   | type     | street   | geometry |
403          | N1  | highway | bus_stop | North St | :n-SE |
404          | N2  | highway | bus_stop | South St | :n-NW |
405         And the places
406          | osm | class   | type         | name     | geometry |
407          | W1  | landuse | residential  | North St | :w-north |
408          | W2  | waterway| river        | South St | :w-south |
409         And the ways
410          | id | nodes |
411          | 1  | 100,101,2,103,104 |
412          | 2  | 200,201,1,202,203 |
413         When importing
414         Then placex contains
415          | object | parent_place_id |
416          | N1     | 0 |
417          | N2     | 0 |
418
419     Scenario: POIs on building outlines inherit associated street relation
420         Given the scene building-on-street-corner
421         And the named places
422          | osm | class    | type  | geometry |
423          | N1  | place    | house | :n-edge-NS |
424          | W1  | building | yes   | :w-building |
425         And the places
426          | osm | class    | type        | name | geometry |
427          | W2  | highway  | primary     | bar  | :w-WE |
428          | W3  | highway  | residential | foo  | :w-NS |
429         And the relations
430          | id | members            | tags+type |
431          | 1  | W1:house,W2:street | associatedStreet |
432         And the ways
433          | id | nodes |
434          | 1  | 100,1,101,102,100 |
435         When importing
436         Then placex contains
437          | object | parent_place_id |
438          | N1     | W2 |
439