]> git.openstreetmap.org Git - nominatim.git/blob - test/bdd/features/db/import/addressing.feature
release 5.1.0.post6
[nominatim.git] / test / bdd / features / db / import / addressing.feature
1 Feature: Address computation
2     Tests for filling of place_addressline
3
4     Scenario: place nodes are added to the address when they are close enough
5         Given the 0.002 grid
6             | 2 |  |  |  |  |  | 1 |  | 3 |
7         And the places
8             | osm | class | type     | name      | geometry |
9             | N1  | place | square   | Square    | 1 |
10             | N2  | place | hamlet   | West Farm | 2 |
11             | N3  | place | hamlet   | East Farm | 3 |
12         When importing
13         Then place_addressline contains exactly
14             | object | address | fromarea |
15             | N1     | N3      | False |
16         When geocoding "Square"
17         Then the result set contains
18            | object | display_name      |
19            | N1     | Square, East Farm |
20
21     Scenario: given two place nodes, the closer one wins for the address
22         Given the grid
23             | 2 |  |  | 1 |  | 3 |
24         And the named places
25             | osm | class | type     | geometry |
26             | N1  | place | square   | 1 |
27             | N2  | place | hamlet   | 2 |
28             | N3  | place | hamlet   | 3 |
29         When importing
30         Then place_addressline contains
31             | object | address | fromarea | isaddress |
32             | N1     | N3      | False    | True |
33             | N1     | N2      | False    | False |
34
35     Scenario: boundaries around the place are added to the address
36         Given the grid
37             | 1 |    | 4 | | 7 | 10 |
38             | 2 |    | 5 | | 8 | 11 |
39             |   |    |   | |   |    |
40             |   |    |   | |   |    |
41             |   |    | 6 | | 9 |    |
42             |   | 99 |   | |   |    |
43             | 3 |    |   | |   | 12 |
44         And the named places
45             | osm | class    | type           | admin | geometry |
46             | R1  | boundary | administrative | 3     | (1,2,3,12,11,10,7,8,9,6,5,4,1) |
47             | R2  | boundary | administrative | 4     | (2,3,12,11,8,9,6,5,2) |
48             | N1  | place    | square         | 15    | 99 |
49         When importing
50         Then place_addressline contains
51             | object | address | isaddress |
52             | N1     | R1      | True |
53             | N1     | R2      | True |
54
55     Scenario: with boundaries of same rank the one with the closer centroid is preferred
56         Given the grid
57             | 1 |   |   | 3 |  | 5 |
58             |   | 9 |   |   |  |   |
59             | 2 |   |   | 4 |  | 6 |
60         And the named places
61             | osm | class    | type           | admin | geometry |
62             | R1  | boundary | administrative | 8     | (1,2,4,3,1) |
63             | R2  | boundary | administrative | 8     | (1,2,6,5,1) |
64             | N1  | place    | square         | 15    | 9 |
65         When importing
66         Then place_addressline contains
67             | object | address | isaddress |
68             | N1     | R1      | True |
69             | N1     | R2      | False |
70
71     Scenario: boundary areas are preferred over place nodes in the address
72         Given the grid
73             | 1 |   |   |   | 10 |   | 3 |
74             |   | 5 |   |   |    |   |   |
75             |   | 6 |   |   |    |   |   |
76             | 2 |   |   |   | 11 |   | 4 |
77         And the named places
78             | osm | class    | type           | admin | geometry |
79             | N1  | place    | square         | 15    | 5 |
80             | N2  | place    | city           | 15    | 6 |
81             | R1  | place    | city           | 8     | (1,2,4,3,1) |
82             | R2  | boundary | administrative | 9     | (1,10,11,2,1) |
83         When importing
84         Then place_addressline contains
85             | object | address | isaddress | cached_rank_address |
86             | N1     | R1      | True      | 16                  |
87             | N1     | R2      | True      | 18                  |
88             | N1     | N2      | False     | 18                  |
89
90     Scenario: place nodes outside a smaller ranked area are ignored
91         Given the grid
92             | 1 |   | 2 |   |
93             |   | 7 |   | 9 |
94             | 4 |   | 3 |   |
95         And the named places
96             | osm | class    | type    | admin | geometry |
97             | N1  | place    | square  | 15    | 7 |
98             | N2  | place    | city    | 15    | 9 |
99             | R1  | place    | city    | 8     | (1,2,3,4,1) |
100         When importing
101         Then place_addressline contains exactly
102             | object | address | isaddress | cached_rank_address |
103             | N1     | R1      | True      | 16                  |
104
105
106     Scenario: place nodes close enough to smaller ranked place nodes are included
107         Given the 0.002 grid
108             | 2 |   | 3 | 1 |
109         And the named places
110             | osm | class | type     | geometry |
111             | N1  | place | square   | 1 |
112             | N2  | place | hamlet   | 2 |
113             | N3  | place | quarter  | 3 |
114         When importing
115         Then place_addressline contains
116             | object | address | fromarea | isaddress |
117             | N1     | N2      | False    | True      |
118             | N1     | N3      | False    | True      |
119
120
121     Scenario: place nodes too far away from a smaller ranked place nodes are marked non-address
122         Given the 0.002 grid
123             | 2 |  |  | 1 |  | 3 |
124         And the named places
125             | osm | class | type     | geometry |
126             | N1  | place | square   | 1 |
127             | N2  | place | hamlet   | 2 |
128             | N3  | place | quarter  | 3 |
129         When importing
130         Then place_addressline contains
131             | object | address | fromarea | isaddress |
132             | N1     | N2      | False    | True      |
133             | N1     | N3      | False    | False     |
134
135
136     # github #121
137     Scenario: Roads crossing boundaries should contain both states
138         Given the grid
139             | 1 |   |   | 2 |   | 3 |
140             |   | 7 |   |   | 8 |   |
141             | 4 |   |   | 5 |   | 6 |
142         And the named places
143             | osm | class   | type | geometry |
144             | W1  | highway | road | 7, 8     |
145         And the named places
146             | osm | class    | type           | admin | geometry      |
147             | W10 | boundary | administrative | 5     | (1, 2, 5, 4, 1) |
148             | W11 | boundary | administrative | 5     | (2, 3, 6, 5, 2) |
149         When importing
150         Then place_addressline contains
151             | object | address | cached_rank_address |
152             | W1     | W10     | 10                  |
153             | W1     | W11     | 10                  |
154
155
156     Scenario: Roads following a boundary should contain both states
157         Given the grid
158             | 1 |   |   | 2 |   | 3 |
159             |   |   | 8 | 7 |   |   |
160             | 4 |   |   | 5 |   | 6 |
161         And the named places
162             | osm | class   | type | geometry |
163             | W1  | highway | road | 2, 7, 8  |
164         And the named places
165             | osm | class    | type           | admin | geometry      |
166             | W10 | boundary | administrative | 5     | (1, 2, 5, 4, 1) |
167             | W11 | boundary | administrative | 5     | (2, 3, 6, 5, 2) |
168         When importing
169         Then place_addressline contains
170             | object | address | cached_rank_address |
171             | W1     | W10     | 10                  |
172             | W1     | W11     | 10                  |
173
174     Scenario: Roads should not contain boundaries they touch in a end point
175         Given the grid
176             | 1 |   |   | 2 |   | 3 |
177             |   | 7 |   | 8 |   |   |
178             | 4 |   |   | 5 |   | 6 |
179         And the named places
180             | osm | class   | type | geometry |
181             | W1  | highway | road | 7, 8     |
182         And the named places
183             | osm | class    | type           | admin | geometry      |
184             | W10 | boundary | administrative | 5     | (1, 2, 8, 5, 4, 1) |
185             | W11 | boundary | administrative | 5     | (2, 3, 6, 5, 8, 2) |
186         When importing
187         Then place_addressline contains exactly
188             | object | address | cached_rank_address |
189             | W1     | W10     | 10                  |
190
191     Scenario: Roads should not contain boundaries they touch in a middle point
192         Given the grid
193             | 1 |   |   | 2 |   | 3 |
194             |   | 7 |   | 8 |   |   |
195             | 4 |   | 9 | 5 |   | 6 |
196         And the named places
197             | osm | class   | type | geometry |
198             | W1  | highway | road | 7, 8, 9     |
199         And the named places
200             | osm | class    | type           | admin | geometry      |
201             | W10 | boundary | administrative | 5     | (1, 2, 8, 5, 4, 1) |
202             | W11 | boundary | administrative | 5     | (2, 3, 6, 5, 8, 2) |
203         When importing
204         Then place_addressline contains exactly
205             | object | address | cached_rank_address |
206             | W1     | W10     | 10                  |
207
208     Scenario: Locality points should contain all boundaries they touch
209         Given the 0.001 grid
210             | 1 |   |   | 2 |   | 3 |
211             |   |   |   | 8 |   |   |
212             | 4 |   |   | 5 |   | 6 |
213         And the named places
214             | osm | class | type     | geometry |
215             | N1  | place | locality | 8        |
216         And the named places
217             | osm | class    | type           | admin | geometry      |
218             | W10 | boundary | administrative | 5     | (1, 2, 8, 5, 4, 1) |
219             | W11 | boundary | administrative | 5     | (2, 3, 6, 5, 8, 2) |
220         When importing
221         Then place_addressline contains
222             | object | address | cached_rank_address |
223             | N1     | W10     | 10                  |
224             | N1     | W11     | 10                  |
225
226     Scenario: Areas should not contain boundaries they touch
227         Given the grid
228             | 1 |   |   | 2 |   | 3 |
229             |   |   |   |   |   |   |
230             | 4 |   |   | 5 |   | 6 |
231         And the named places
232             | osm | class    | type           | geometry      |
233             | W1  | landuse  | industrial     | (1, 2, 5, 4, 1) |
234         And the named places
235             | osm | class    | type           | admin | geometry      |
236             | W10 | boundary | administrative | 5     | (2, 3, 6, 5, 2) |
237         When importing
238         Then place_addressline contains exactly
239             | object | address |
240
241     Scenario: buildings with only addr:postcodes do not appear in the address of a way
242         Given the grid with origin DE
243             | 1 |   |   |   |   | 8 |   | 6 |   | 2 |
244             |   |10 |11 |   |   |   |   |   |   |   |
245             |   |13 |12 |   |   |   |   |   |   |   |
246             | 20|   |   | 21|   |   |   |   |   |   |
247             |   |   |   |   |   |   |   |   |   |   |
248             |   |   |   |   |   | 9 |   |   |   |   |
249             | 4 |   |   |   |   |   |   | 7 |   | 3 |
250         And the named places
251             | osm | class    | type           | admin | addr+postcode | geometry   |
252             | R1  | boundary | administrative | 6     | 10000         | (1,2,3,4,1)|
253             | R34 | boundary | administrative | 8     | 11200         | (1,6,7,4,1)|
254             | R4  | boundary | administrative | 10    | 11230         | (1,8,9,4,1)|
255         And the named places
256             | osm | class    | type           | geometry |
257             | W93 | highway  | residential    | 20,21    |
258         And the places
259             | osm | class    | type        | addr+postcode | geometry |
260             | W22 | place    | postcode    | 11234         | (10,11,12,13,10) |
261         When importing
262         Then place_addressline contains exactly
263             | object | address  |
264             | R4     | R1       |
265             | R4     | R34      |
266             | R34    | R1       |
267             | W93    | R1       |
268             | W93    | R34      |
269             | W93    | R4       |
270
271     Scenario: postcode boundaries do appear in the address of a way
272        Given the grid with origin DE
273             | 1 |   |   |   |   | 8 |   | 6 |   | 2 |
274             |   |10 |11 |   |   |   |   |   |   |   |
275             |   |13 |12 |   |   |   |   |   |   |   |
276             | 20|   |   | 21|   |   |   |   |   |   |
277             |   |   |   |   |   |   |   |   |   |   |
278             |   |   |   |   |   | 9 |   |   |   |   |
279             | 4 |   |   |   |   |   |   | 7 |   | 3 |
280         And the named places
281             | osm | class    | type           | admin | addr+postcode | geometry    |
282             | R1  | boundary | administrative | 6     | 10000         | (1,2,3,4,1) |
283             | R34 | boundary | administrative | 8     | 11000         | (1,6,7,4,1) |
284         And the places
285             | osm | class    | type        | addr+postcode | geometry |
286             | R4  | boundary | postal_code | 11200         | (1,8,9,4,1) |
287         And the named places
288             | osm | class    | type           | geometry |
289             | W93 | highway  | residential    | 20,21    |
290         And the places
291             | osm | class    | type        | addr+postcode | geometry |
292             | W22 | place    | postcode    | 11234         | (10,11,12,13,10) |
293         When importing
294         Then place_addressline contains
295             | object | address |
296             | W93    | R4      |
297
298     Scenario: squares do not appear in the address of a street
299         Given the grid
300             |   | 1 |   | 2 |   |
301             | 8 |   |   |   | 9 |
302             |   | 4 |   | 3 |   |
303         And the named places
304             | osm | class    | type           | geometry |
305             | W1  | highway  | residential    | 8, 9     |
306             | W2  | place    | square         | (1, 2, 3 ,4, 1) |
307         When importing
308         Then place_addressline contains exactly
309             | object | address |
310
311     Scenario: addr:* tags are honored even when a street is far away from the place
312         Given the grid
313             | 1 |   | 2 |   |   | 5 |
314             |   |   |   | 8 | 9 |   |
315             | 4 |   | 3 |   |   | 6 |
316         And the places
317             | osm | class    | type           | admin | name  | geometry    |
318             | R1  | boundary | administrative | 8     | Left  | (1,2,3,4,1) |
319             | R2  | boundary | administrative | 8     | Right | (2,3,6,5,2) |
320         And the places
321             | osm | class   | type    | addr+city | geometry |
322             | W1  | highway | primary | Left      | 8,9      |
323             | W2  | highway | primary | Right     | 8,9      |
324         When importing
325         Then place_addressline contains exactly
326            | object | address | isaddress |
327            | W1     | R1      | True      |
328            | W1     | R2      | False     |
329            | W2     | R2      | True      |
330
331
332     Scenario: addr:* tags are honored even when a POI is far away from the place
333         Given the grid
334             | 1 |   | 2 |   |   | 5 |
335             |   |   |   | 8 | 9 |   |
336             | 4 |   | 3 |   |   | 6 |
337         And the places
338             | osm | class    | type           | admin | name  | geometry    |
339             | R1  | boundary | administrative | 8     | Left  | (1,2,3,4,1) |
340             | R2  | boundary | administrative | 8     | Right | (2,3,6,5,2) |
341         And the places
342             | osm | class   | type    | name      | addr+city | geometry |
343             | W1  | highway | primary | Wonderway | Right     | 8,9      |
344             | N1  | amenity | cafe    | Bolder    | Left      | 9        |
345         When importing
346         Then place_addressline contains exactly
347            | object | address | isaddress |
348            | W1     | R2      | True      |
349            | N1     | R1      | True      |
350         When geocoding "Bolder"
351         Then the result set contains
352            | object | display_name            |
353            | N1     | Bolder, Wonderway, Left |
354
355     Scenario: addr:* tags do not produce addresslines when the parent has the address part
356         Given the grid
357             | 1 |   |   | 5 |
358             |   | 8 | 9 |   |
359             | 4 |   |   | 6 |
360         And the places
361             | osm | class    | type           | admin | name  | geometry    |
362             | R1  | boundary | administrative | 8     | Outer | (1,5,6,4,1) |
363         And the places
364             | osm | class   | type    | name      | addr+city | geometry |
365             | W1  | highway | primary | Wonderway | Outer     | 8,9      |
366             | N1  | amenity | cafe    | Bolder    | Outer     | 9        |
367         When importing
368         Then place_addressline contains exactly
369            | object | address | isaddress |
370            | W1     | R1      | True      |
371         When geocoding "Bolder"
372         Then the result set contains
373            | object | display_name             |
374            | N1     | Bolder, Wonderway, Outer |
375
376     Scenario: addr:* tags on outside do not produce addresslines when the parent has the address part
377         Given the grid
378             | 1 |   | 2 |   |   | 5 |
379             |   |   |   | 8 | 9 |   |
380             | 4 |   | 3 |   |   | 6 |
381         And the places
382             | osm | class    | type           | admin | name  | geometry    |
383             | R1  | boundary | administrative | 8     | Left  | (1,2,3,4,1) |
384             | R2  | boundary | administrative | 8     | Right | (2,3,6,5,2) |
385         And the places
386             | osm | class   | type    | name      | addr+city | geometry |
387             | W1  | highway | primary | Wonderway | Left      | 8,9      |
388             | N1  | amenity | cafe    | Bolder    | Left      | 9        |
389         When importing
390         Then place_addressline contains exactly
391            | object | address | isaddress |
392            | W1     | R1      | True      |
393            | W1     | R2      | False     |
394         When geocoding "Bolder"
395         Then the result set contains
396            | object | display_name            |
397            | N1     | Bolder, Wonderway, Left |
398
399     Scenario: POIs can correct address parts on the fly
400         Given the grid
401             | 1 |   |   |   |  2 |   | 5 |
402             |   |   |   | 9 |    | 8 |   |
403             | 4 |   |   |   |  3 |   | 6 |
404         And the places
405             | osm | class    | type           | admin | name  | geometry    |
406             | R1  | boundary | administrative | 8     | Left  | (1,2,3,4,1) |
407             | R2  | boundary | administrative | 8     | Right | (2,3,6,5,2) |
408         And the places
409             | osm | class   | type    | name      | geometry |
410             | W1  | highway | primary | Wonderway | 2,3      |
411             | N1  | amenity | cafe    | Bolder    | 9        |
412             | N2  | amenity | cafe    | Leftside  | 8        |
413         When importing
414         Then place_addressline contains exactly
415            | object | address | isaddress |
416            | W1     | R1      | False     |
417            | W1     | R2      | True      |
418         When geocoding "Bolder"
419         Then the result set contains
420            | object | display_name            |
421            | N1     | Bolder, Wonderway, Left |
422         When geocoding "Leftside"
423         Then the result set contains
424            | object | display_name               |
425            | N2     | Leftside, Wonderway, Right |
426
427
428     Scenario: POIs can correct address parts on the fly (with partial unmatching address)
429         Given the grid
430             | 1 |   |   |   |  2 |   | 5 |
431             |   |   |   | 9 |    | 8 |   |
432             |   | 10| 11|   |    | 12|   |
433             | 4 |   |   |   |  3 |   | 6 |
434         And the places
435             | osm | class    | type           | admin | name  | geometry    |
436             | R1  | boundary | administrative | 8     | Left  | (1,2,3,4,1) |
437             | R2  | boundary | administrative | 8     | Right | (2,3,6,5,2) |
438         And the places
439             | osm | class   | type    | name      | geometry |
440             | W1  | highway | primary | Wonderway | 10,11,12 |
441         And the places
442             | osm | class   | type    | name      | addr+suburb | geometry |
443             | N1  | amenity | cafe    | Bolder    | Boring      | 9        |
444             | N2  | amenity | cafe    | Leftside  | Boring      | 8        |
445         When importing
446         Then place_addressline contains exactly
447            | object | address | isaddress |
448            | W1     | R1      | True      |
449            | W1     | R2      | False     |
450         When geocoding "Bolder"
451         Then the result set contains
452            | object | display_name            |
453            | N1     | Bolder, Wonderway, Left |
454         When geocoding "Leftside"
455         Then the result set contains
456            | object | display_name               |
457            | N2     | Leftside, Wonderway, Right |
458
459
460
461     Scenario: POIs can correct address parts on the fly (with partial matching address)
462         Given the grid
463             | 1 |   |   |   |  2 |   | 5 |
464             |   |   |   | 9 |    | 8 |   |
465             |   | 10| 11|   |    | 12|   |
466             | 4 |   |   |   |  3 |   | 6 |
467         And the places
468             | osm | class    | type           | admin | name  | geometry    |
469             | R1  | boundary | administrative | 8     | Left  | (1,2,3,4,1) |
470             | R2  | boundary | administrative | 8     | Right | (2,3,6,5,2) |
471         And the places
472             | osm | class   | type    | name      | geometry |
473             | W1  | highway | primary | Wonderway | 10,11,12 |
474         And the places
475             | osm | class   | type    | name      | addr+state | geometry |
476             | N1  | amenity | cafe    | Bolder    | Left       | 9        |
477             | N2  | amenity | cafe    | Leftside  | Left       | 8        |
478         When importing
479         Then place_addressline contains exactly
480            | object | address | isaddress |
481            | W1     | R1      | True      |
482            | W1     | R2      | False     |
483         When geocoding "Bolder"
484         Then the result set contains
485            | object | display_name            |
486            | N1     | Bolder, Wonderway, Left |
487         When geocoding "Leftside"
488         Then the result set contains
489            | object | display_name               |
490            | N2     | Leftside, Wonderway, Left |
491
492
493     Scenario: addr:* tags always match the closer area
494         Given the grid
495             | 1 |   |   |   |  2 |   | 5 |
496             |   |   |   |   |    |   |   |
497             | 4 |   |   |   |  3 |   | 6 |
498             |   | 10| 11|   |    |   |   |
499         And the places
500             | osm | class    | type           | admin | name  | geometry    |
501             | R1  | boundary | administrative | 8     | Left  | (1,2,3,4,1) |
502             | R2  | boundary | administrative | 8     | Left  | (2,3,6,5,2) |
503         And the places
504             | osm | class   | type    | name      | addr+city | geometry |
505             | W1  | highway | primary | Wonderway | Left      | 10,11    |
506         When importing
507         Then place_addressline contains exactly
508             | object | address |
509             | W1     | R1      |
510
511     Scenario: Full name is prefered for unlisted addr:place tags
512         Given the grid
513             |   | 1 | 2 |   |
514             | 8 |   |   | 9 |
515         And the places
516             | osm | class | type | name    | geometry |
517             | W10 | place | city | Away    | (8,1,2,9,8) |
518         And the places
519             | osm | class   | type        | name          | addr+city | geometry |
520             | W1  | highway | residential | Royal Terrace | Gardens   | 8,9      |
521         And the places
522             | osm | class | type  | housenr | addr+place            | geometry | extra+foo |
523             | N1  | place | house | 1       | Royal Terrace Gardens | 1        | bar |
524         And the places
525             | osm | class | type  | housenr | addr+street   | geometry |
526             | N2  | place | house | 2       | Royal Terrace | 2        |
527         When importing
528         When geocoding "1, Royal Terrace Gardens"
529         Then result 0 contains
530             | object |
531             | N1  |