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