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