]> git.openstreetmap.org Git - nominatim.git/blob - test/bdd/db/import/parenting.feature
bdd: remove special case for osm_type field
[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 grid with origin DE
7          | 10 |   |   |   |   | 11 |
8          |    |   |   |   |   |    |
9          |    | 1 |   | 2 |   |    |
10         And the places
11          | osm | class | type  | housenr |
12          | N1  | place | house | 4       |
13         And the places
14          | osm | class | type  | housenr | postcode |
15          | N2  | place | house | 5       | 99999    |
16         And the places
17          | osm | class   | type        | name  | postcode | geometry |
18          | W1  | highway | residential | galoo | 12345    | 10,11    |
19         When importing
20         Then placex contains
21          | object | parent_place_id |
22          | N1     | W1 |
23          | N2     | W1 |
24         When sending search query "4 galoo"
25         Then results contain
26          | ID | osm | display_name |
27          | 0  | N1  | 4, galoo, 12345, Deutschland |
28         When sending search query "5 galoo"
29         Then results contain
30          | ID | osm | display_name |
31          | 0  | N2  | 5, galoo, 99999, Deutschland |
32
33     Scenario: Address without tags, closest street
34         Given the grid
35          | 10 |   |   |   |   | 11 |
36          |    | 1 | 2 |   |   |    |
37          |    |   |   | 3 | 4 |    |
38          | 20 |   |   |   |   | 21 |
39         And the places
40          | osm | class | type  |
41          | N1  | place | house |
42          | N2  | place | house |
43          | N3  | place | house |
44          | N4  | place | house |
45         And the named places
46          | osm | class   | type        | geometry |
47          | W1  | highway | residential | 10,11    |
48          | W2  | highway | residential | 20,21    |
49         When importing
50         Then placex contains
51          | object | parent_place_id |
52          | N1     | W1 |
53          | N2     | W1 |
54          | N3     | W2 |
55          | N4     | W2 |
56
57     Scenario: Address without tags avoids unnamed streets
58         Given the grid
59          | 10 |   |   |   |   | 11 |
60          |    | 1 | 2 |   |   |    |
61          |    |   |   | 3 | 4 |    |
62          | 20 |   |   |   |   | 21 |
63         And the places
64          | osm | class   | type  |
65          | N1  | place   | house |
66          | N2  | place   | house |
67          | N3  | place   | house |
68          | N4  | place   | house |
69         And the places
70          | osm | class   | type        | geometry |
71          | W1  | highway | residential | 10,11    |
72         And the named places
73          | osm | class   | type        | geometry |
74          | W2  | highway | residential | 20,21 |
75         When importing
76         Then placex contains
77          | object | parent_place_id |
78          | N1     | W2 |
79          | N2     | W2 |
80          | N3     | W2 |
81          | N4     | W2 |
82
83     Scenario: addr:street tag parents to appropriately named street
84         Given the grid
85          | 10 |   |   |   |   | 11 |
86          |    | 1 | 2 |   |   |    |
87          |    |   |   | 3 | 4 |    |
88          | 20 |   |   |   |   | 21 |
89         And the places
90          | osm | class | type  | street|
91          | N1  | place | house | south |
92          | N2  | place | house | north |
93          | N3  | place | house | south |
94          | N4  | place | house | north |
95         And the places
96          | osm | class   | type        | name  | geometry |
97          | W1  | highway | residential | north | 10,11    |
98          | W2  | highway | residential | south | 20,21    |
99         When importing
100         Then placex contains
101          | object | parent_place_id |
102          | N1     | W2 |
103          | N2     | W1 |
104          | N3     | W2 |
105          | N4     | W1 |
106
107     @fail-legacy
108     Scenario: addr:street tag parents to appropriately named street, locale names
109         Given the grid
110          | 10 |   |   |   |   | 11 |
111          |    | 1 | 2 |   |   |    |
112          |    |   |   | 3 | 4 |    |
113          | 20 |   |   |   |   | 21 |
114         And the places
115          | osm | class | type  | street| addr+street:de |
116          | N1  | place | house | south | Süd            |
117          | N2  | place | house | north | Nord           |
118          | N3  | place | house | south | Süd            |
119          | N4  | place | house | north | Nord           |
120         And the places
121          | osm | class   | type        | name  | geometry |
122          | W1  | highway | residential | Nord  | 10,11    |
123          | W2  | highway | residential | Süd   | 20,21    |
124         When importing
125         Then placex contains
126          | object | parent_place_id |
127          | N1     | W2 |
128          | N2     | W1 |
129          | N3     | W2 |
130          | N4     | W1 |
131
132     Scenario: addr:street tag parents to appropriately named street with abbreviation
133         Given the grid
134          | 10 |   |   |   |   | 11 |
135          |    | 1 | 2 |   |   |    |
136          |    |   |   | 3 | 4 |    |
137          | 20 |   |   |   |   | 21 |
138         And the places
139          | osm | class | type  | street   |
140          | N1  | place | house | south st |
141          | N2  | place | house | north st |
142          | N3  | place | house | south st |
143          | N4  | place | house | north st |
144         And the places
145          | osm | class   | type        | name+name:en | geometry |
146          | W1  | highway | residential | north street | 10,11    |
147          | W2  | highway | residential | south street | 20,21    |
148         When importing
149         Then placex contains
150          | object | parent_place_id |
151          | N1     | W2 |
152          | N2     | W1 |
153          | N3     | W2 |
154          | N4     | W1 |
155
156     Scenario: addr:street tag parents to next named street
157         Given the grid
158          | 10 |   |   |   |   | 11 |
159          |    | 1 | 2 |   |   |    |
160          |    |   |   | 3 | 4 |    |
161          | 20 |   |   |   |   | 21 |
162         And the places
163          | osm | class | type  | street |
164          | N1  | place | house | abcdef |
165          | N2  | place | house | abcdef |
166          | N3  | place | house | abcdef |
167          | N4  | place | house | abcdef |
168         And the places
169          | osm | class   | type        | name   | geometry |
170          | W1  | highway | residential | abcdef | 10,11    |
171          | W2  | highway | residential | abcdef | 20,21    |
172         When importing
173         Then placex contains
174          | object | parent_place_id |
175          | N1     | W1 |
176          | N2     | W1 |
177          | N3     | W2 |
178          | N4     | W2 |
179
180     Scenario: addr:street tag without appropriately named street
181         Given the grid
182          | 10 |   |   |   |   | 11 |
183          |    | 1 |   |   |   |    |
184          |    |   |   | 3 |   |    |
185          | 20 |   |   |   |   | 21 |
186         And the places
187          | osm | class | type  | street |
188          | N1  | place | house | abcdef |
189          | N3  | place | house | abcdef |
190         And the places
191          | osm | class   | type        | name  | geometry |
192          | W1  | highway | residential | abcde | 10,11    |
193          | W2  | highway | residential | abcde | 20,21    |
194         When importing
195         Then placex contains
196          | object | parent_place_id |
197          | N1     | W1 |
198          | N3     | W2 |
199
200     Scenario: addr:place address
201         Given the grid
202          | 10 |   | |   |
203          |    | 1 | | 2 |
204          | 11 |   | |   |
205         And the places
206          | osm | class | type   | addr_place |
207          | N1  | place | house  | myhamlet   |
208         And the places
209          | osm | class   | type        | name     | geometry |
210          | N2  | place   | hamlet      | myhamlet | 2 |
211          | W1  | highway | residential | myhamlet | 10,11 |
212         When importing
213         Then placex contains
214          | object | parent_place_id |
215          | N1     | N2 |
216
217     Scenario: addr:street is preferred over addr:place
218         Given the grid
219          | 10 |  |   |   |
220          |    |  | 1 | 2 |
221          | 11 |  |   |   |
222         And the places
223          | osm | class | type   | addr_place | street  |
224          | N1  | place | house  | myhamlet   | mystreet|
225         And the places
226          | osm | class   | type        | name     | geometry |
227          | N2  | place   | hamlet      | myhamlet | 2        |
228          | W1  | highway | residential | mystreet | 10,11    |
229         When importing
230         Then placex contains
231          | object | parent_place_id |
232          | N1     | W1 |
233
234     Scenario: Untagged address in simple associated street relation
235         Given the grid
236          | 10 |   |   |   |   | 11 |
237          |    | 2 |   | 3 |   |    |
238          |    |   |   |   |   |    |
239          | 12 | 1 |   |   |   |    |
240         And the places
241          | osm | class | type  |
242          | N1  | place | house |
243          | N2  | place | house |
244          | N3  | place | house |
245         And the places
246          | osm | class   | type        | name | geometry |
247          | W1  | highway | residential | foo  | 10,11 |
248          | W2  | highway | service     | bar  | 10,12 |
249         And the relations
250          | id | members            | tags+type |
251          | 1  | W1:street,N1,N2,N3 | associatedStreet |
252         When importing
253         Then placex contains
254          | object | parent_place_id |
255          | N1     | W1 |
256          | N2     | W1 |
257          | N3     | W1 |
258
259     Scenario: Avoid unnamed streets in simple associated street relation
260         Given the grid
261          | 10 |   |   |   |   | 11 |
262          |    | 2 |   | 3 |   |    |
263          |    |   |   |   |   |    |
264          | 12 | 1 |   |   |   |    |
265         And the places
266          | osm | class | type  |
267          | N1  | place | house |
268          | N2  | place | house |
269          | N3  | place | house |
270         And the places
271          | osm | class   | type        | geometry |
272          | W2  | highway | residential | 10,12    |
273         And the named places
274          | osm | class   | type        | geometry |
275          | W1  | highway | residential | 10,11    |
276         And the relations
277          | id | members                      | tags+type |
278          | 1  | N1,N2,N3,W2:street,W1:street | associatedStreet |
279         When importing
280         Then placex contains
281          | object | parent_place_id |
282          | N1     | W1 |
283          | N2     | W1 |
284          | N3     | W1 |
285
286     Scenario: Associated street relation overrides addr:street
287         Given the grid
288          | 10 |    |   |    | 11 |
289          |    |    |   |    |    |
290          |    |    | 1 |    |    |
291          |    | 20 |   | 21 |    |
292         And the places
293          | osm | class | type  | street |
294          | N1  | place | house | bar    |
295         And the places
296          | osm | class   | type        | name | geometry |
297          | W1  | highway | residential | foo  | 10,11    |
298          | W2  | highway | residential | bar  | 20,21    |
299         And the relations
300          | id | members      | tags+type |
301          | 1  | W1:street,N1 | associatedStreet |
302         When importing
303         Then placex contains
304          | object | parent_place_id |
305          | N1     | W1 |
306
307     Scenario: Building without tags, closest street from center point
308         Given the grid
309          | 10 |  |   |   | 11 |
310          |    |  | 1 | 2 |    |
311          | 12 |  | 4 | 3 |    |
312         And the named places
313          | osm | class    | type        | geometry    |
314          | W1  | building | yes         | (1,2,3,4,1) |
315          | W2  | highway  | primary     | 10,11       |
316          | W3  | highway  | residential | 10,12       |
317         When importing
318         Then placex contains
319          | object | parent_place_id |
320          | W1     | W2 |
321
322     Scenario: Building with addr:street tags
323         Given the grid
324          | 10 |  |   |   | 11 |
325          |    |  | 1 | 2 |    |
326          | 12 |  | 4 | 3 |    |
327         And the named places
328          | osm | class    | type | street | geometry |
329          | W1  | building | yes  | foo    | (1,2,3,4,1) |
330         And the places
331          | osm | class    | type        | name | geometry |
332          | W2  | highway  | primary     | bar  | 10,11    |
333          | W3  | highway  | residential | foo  | 10,12    |
334         When importing
335         Then placex contains
336          | object | parent_place_id |
337          | W1     | W3 |
338
339     Scenario: Building with addr:place tags
340         Given the grid
341          | 10 |   |   |   |   |
342          |    | 1 | 2 |   | 9 |
343          | 11 | 4 | 3 |   |   |
344         And the places
345          | osm | class    | type        | name | geometry |
346          | N9  | place    | village     | bar  | 9        |
347          | W2  | highway  | primary     | bar  | 10,11    |
348         And the named places
349          | osm | class    | type | addr_place | geometry    |
350          | W1  | building | yes  | bar        | (1,2,3,4,1) |
351         When importing
352         Then placex contains
353          | object | parent_place_id |
354          | W1     | N9 |
355
356     Scenario: Building in associated street relation
357         Given the grid
358          | 10 |  |   |   | 11 |
359          |    |  | 1 | 2 |    |
360          | 12 |  | 4 | 3 |    |
361         And the named places
362          | osm | class    | type | geometry    |
363          | W1  | building | yes  | (1,2,3,4,1) |
364         And the places
365          | osm | class    | type        | name | geometry |
366          | W2  | highway  | primary     | bar  | 10,11 |
367          | W3  | highway  | residential | foo  | 10,12 |
368         And the relations
369          | id | members            | tags+type |
370          | 1  | W1:house,W3:street | associatedStreet |
371         When importing
372         Then placex contains
373          | object | parent_place_id |
374          | W1     | W3 |
375
376     Scenario: Building in associated street relation overrides addr:street
377         Given the grid
378          | 10 |  |   |   | 11 |
379          |    |  | 1 | 2 |    |
380          | 12 |  | 4 | 3 |    |
381         And the named places
382          | osm | class    | type | street | geometry    |
383          | W1  | building | yes  | foo    | (1,2,3,4,1) |
384         And the places
385          | osm | class    | type        | name | geometry |
386          | W2  | highway  | primary     | bar  | 10,11 |
387          | W3  | highway  | residential | foo  | 10,12 |
388         And the relations
389          | id | members            | tags+type |
390          | 1  | W1:house,W2:street | associatedStreet |
391         When importing
392         Then placex contains
393          | object | parent_place_id |
394          | W1     | W2 |
395
396     Scenario: Wrong member in associated street relation is ignored
397         Given the grid
398          | 10 |   |   |   |   |   |   | 11 |
399          |    | 1 |   | 3 | 4 |   |   |    |
400          |    |   |   | 6 | 5 |   |   |    |
401          And the named places
402          | osm | class | type  | geometry |
403          | N1  | place | house | 11       |
404         And the named places
405          | osm | class    | type | street | geometry    |
406          | W1  | building | yes  | foo    | (3,4,5,6,3) |
407         And the places
408          | osm | class    | type        | name | geometry |
409          | W3  | highway  | residential | foo  | 10,11    |
410         And the relations
411          | id | members                      | tags+type |
412          | 1  | N1:house,W1:street,W3:street | associatedStreet |
413         When importing
414         Then placex contains
415          | object | parent_place_id |
416          | N1     | W3 |
417
418     Scenario: street member in associatedStreet relation can be a relation
419         Given the grid
420           | 1 |   |   | 2 |
421           | 3 |   |   | 4 |
422           |   |   |   |   |
423           |   | 9 |   |   |
424           | 5 |   |   | 6 |
425         And the places
426           | osm | class | type  | housenr | geometry |
427           | N9  | place | house | 34      | 9        |
428         And the named places
429           | osm | class   | type       | name      | geometry    |
430           | R14 | highway | pedestrian | Right St  | (1,2,4,3,1) |
431           | W14 | highway | pedestrian | Left St   | 5,6         |
432         And the relations
433           | id | members             | tags+type |
434           | 1  | N9:house,R14:street | associatedStreet |
435         When importing
436         Then placex contains
437           | object | parent_place_id |
438           | N9     | R14             |
439
440
441     Scenario: Choose closest street in associatedStreet relation
442         Given the grid
443          | 1  |   |    |  | 3  |
444          | 10 |   | 11 |  | 12 |
445         And the places
446          | osm | class | type  | housenr | geometry |
447          | N1  | place | house | 1       | 1        |
448          | N3  | place | house | 3       | 3        |
449         And the named places
450          | osm  | class    | type        | geometry |
451          | W100 | highway  | residential | 10,11    |
452          | W101 | highway  | residential | 11,12    |
453         And the relations
454          | id | members                                            | tags+type |
455          | 1  | N1:house,N3:house,W100:street,W101:street | associatedStreet |
456         When importing
457         Then placex contains
458          | object | parent_place_id |
459          | N1     | W100            |
460          | N3     | W101            |
461
462
463     Scenario: POIs in building inherit address
464         Given the grid
465          | 10 |  |   |   |   |   | 11 |
466          |    |  | 5 | 2 | 6 |   |    |
467          |    |  | 3 | 1 |   |   |    |
468          | 12 |  | 8 |   | 7 |   |    |
469         And the named places
470          | osm | class   | type       |
471          | N1  | amenity | bank       |
472          | N2  | shop    | bakery     |
473          | N3  | shop    | supermarket|
474         And the places
475          | osm | class    | type | street | housenr | geometry    |
476          | W1  | building | yes  | foo    | 3       | (5,6,7,8,5) |
477         And the places
478          | osm | class    | type        | name | geometry |
479          | W2  | highway  | primary     | bar  | 10,11    |
480          | W3  | highway  | residential | foo  | 10,12    |
481         When importing
482         Then placex contains
483          | object | parent_place_id | housenumber |
484          | W1     | W3              | 3 |
485          | N1     | W3              | 3 |
486          | N2     | W3              | 3 |
487          | N3     | W3              | 3 |
488         When sending geocodejson search query "3, foo" with address
489         Then results contain
490          | housenumber |
491          | 3           |
492
493     Scenario: POIs don't inherit from streets
494         Given the grid
495          | 10 |   |   |   | 11 |
496          |    | 5 | 1 | 6 |    |
497          |    | 8 |   | 7 |    |
498         And the named places
499          | osm | class   | type  |
500          | N1  | amenity | bank  |
501         And the places
502          | osm | class    | type | name | street | housenr | geometry    |
503          | W1  | highway  | path | bar  | foo    | 3       | (5,6,7,8,5) |
504         And the places
505          | osm | class    | type        | name | geometry |
506          | W3  | highway  | residential | foo  | 10,11    |
507         When importing
508         Then placex contains
509          | object | parent_place_id | housenumber |
510          | N1     | W1              | None |
511
512     Scenario: POIs with own address do not inherit building address
513         Given the grid
514          | 10 |  |   |   |   |   | 11 |
515          |    |  | 6 | 2 | 7 |   |    |
516          |    |  | 3 | 1 |   | 5 |  4 |
517          | 12 |  | 9 |   | 8 |   |    |
518         And the named places
519          | osm | class   | type       | street |
520          | N1  | amenity | bank       | bar    |
521         And the named places
522          | osm | class   | type       | housenr |
523          | N2  | shop    | bakery     | 4       |
524         And the named places
525          | osm | class   | type       | addr_place  |
526          | N3  | shop    | supermarket| nowhere     |
527         And the places
528          | osm | class | type              | name     |
529          | N4  | place | isolated_dwelling | theplace |
530          | N5  | place | isolated_dwelling | nowhere  |
531         And the places
532          | osm | class    | type | addr_place | housenr | geometry    |
533          | W1  | building | yes  | theplace   | 3       | (6,7,8,9,6) |
534         And the places
535          | osm | class    | type        | name | geometry |
536          | W2  | highway  | primary     | bar  | 10,11    |
537          | W3  | highway  | residential | foo  | 10,12    |
538         When importing
539         Then placex contains
540          | object | parent_place_id | housenumber |
541          | W1     | N4              | 3 |
542          | N1     | W2              | None |
543          | N2     | W2              | 4 |
544          | N3     | N5              | None |
545
546     Scenario: POIs parent a road if they are attached to it
547         Given the grid
548          |    | 10 |    |
549          | 20 | 1  | 21 |
550          |    | 11 |    |
551         And the named places
552          | osm | class   | type     |
553          | N1  | highway | bus_stop |
554         And the places
555          | osm | class   | type         | name     | geometry |
556          | W1  | highway | secondary    | North St | 10,11 |
557          | W2  | highway | unclassified | South St | 20,1,21 |
558         And the ways
559          | id | nodes |
560          | 1  | 10,11 |
561          | 2  | 20,1,21 |
562         When importing
563         Then placex contains
564          | object | parent_place_id |
565          | N1     | W2 |
566
567     Scenario: POIs do not parent non-roads they are attached to
568         Given the grid
569          | 10 |   | 1 |   |  11 |  | 30 |
570          | 14 |   |   |   |  15 |  |    |
571          | 13 |   | 2 |   |  12 |  | 31 |
572         And the named places
573          | osm | class   | type     | street   |
574          | N1  | highway | bus_stop | North St |
575          | N2  | highway | bus_stop | South St |
576         And the places
577          | osm | class   | type         | name     | geometry |
578          | W1  | landuse | residential  | North St | (14,15,12,2,13,14) |
579          | W2  | waterway| river        | South St | 10,1,11  |
580          | W3  | highway | residential  | foo      | 30,31    |
581         And the ways
582          | id | nodes |
583          | 1  | 10,11,12,2,13,10 |
584          | 2  | 10,1,11 |
585         When importing
586         Then placex contains
587          | object | parent_place_id |
588          | N1     | W3 |
589          | N2     | W3 |
590
591     Scenario: POIs on building outlines inherit associated street relation
592         Given the grid
593          | 10 |   |   |   | 11 |
594          |    | 5 | 1 | 6 |    |
595          | 12 | 8 |   | 7 |    |
596         And the named places
597          | osm | class    | type  | geometry     |
598          | N1  | place    | house | 1            |
599          | W1  | building | yes   | (5,1,6,7,8,5)|
600         And the places
601          | osm | class    | type        | name | geometry |
602          | W2  | highway  | primary     | bar  | 10,11    |
603          | W3  | highway  | residential | foo  | 10,12    |
604         And the relations
605          | id | members            | tags+type |
606          | 1  | W1:house,W3:street | associatedStreet |
607         And the ways
608          | id | nodes |
609          | 1  | 5,1,6,7,8,5 |
610         When importing
611         Then placex contains
612          | object | parent_place_id |
613          | N1     | W3 |
614
615     # github #1056
616     Scenario: Full names should be preferably matched for nearest road
617         Given the grid
618             | 1 |   | 2 | 5 |
619             |   |   |   |   |
620             | 3 |   |   | 4 |
621             |   | 10|   |   |
622         And the places
623             | osm | class   | type    | name+name               | geometry |
624             | W1  | highway | residential | Via Cavassico superiore | 1, 2 |
625             | W3  | highway | residential | Via Cavassico superiore | 2, 5 |
626             | W2  | highway | primary | Via Frazione Cavassico  | 3, 4     |
627         And the named places
628             | osm | class   | type    | addr+street             |
629             | N10 | shop    | yes     | Via Cavassico superiore |
630         When importing
631         Then placex contains
632           | object | parent_place_id |
633           | N10    | W1 |
634
635      Scenario: place=square may be parented via addr:place
636         Given the grid
637             |   |   | 9 |   |   |
638             |   | 5 |   | 6 |   |
639             |   | 8 |   | 7 |   |
640         And the places
641             | osm | class    | type    | name+name | geometry        |
642             | W2  | place    | square  | Foo pl    | (5, 6, 7, 8, 5) |
643         And the places
644             | osm | class    | type    | name+name | housenr | addr_place | geometry |
645             | N10 | shop     | grocery | le shop   | 5       | Foo pl     | 9        |
646         When importing
647         Then placex contains
648             | object | rank_address |
649             | W2     | 25           |
650         Then placex contains
651             | object | parent_place_id |
652             | N10    | W2              |
653