]> git.openstreetmap.org Git - nominatim.git/blob - test/bdd/features/db/import/addressing.feature
release 5.2.0.post7
[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: squares do not appear in the address of a street
272         Given the grid
273             |   | 1 |   | 2 |   |
274             | 8 |   |   |   | 9 |
275             |   | 4 |   | 3 |   |
276         And the named places
277             | osm | class    | type           | geometry |
278             | W1  | highway  | residential    | 8, 9     |
279             | W2  | place    | square         | (1, 2, 3 ,4, 1) |
280         When importing
281         Then place_addressline contains exactly
282             | object | address |
283
284     Scenario: addr:* tags are honored even when a street is far away from the place
285         Given the grid
286             | 1 |   | 2 |   |   | 5 |
287             |   |   |   | 8 | 9 |   |
288             | 4 |   | 3 |   |   | 6 |
289         And the places
290             | osm | class    | type           | admin | name  | geometry    |
291             | R1  | boundary | administrative | 8     | Left  | (1,2,3,4,1) |
292             | R2  | boundary | administrative | 8     | Right | (2,3,6,5,2) |
293         And the places
294             | osm | class   | type    | addr+city | geometry |
295             | W1  | highway | primary | Left      | 8,9      |
296             | W2  | highway | primary | Right     | 8,9      |
297         When importing
298         Then place_addressline contains exactly
299            | object | address | isaddress |
300            | W1     | R1      | True      |
301            | W1     | R2      | False     |
302            | W2     | R2      | True      |
303
304
305     Scenario: addr:* tags are honored even when a POI is far away from the place
306         Given the grid
307             | 1 |   | 2 |   |   | 5 |
308             |   |   |   | 8 | 9 |   |
309             | 4 |   | 3 |   |   | 6 |
310         And the places
311             | osm | class    | type           | admin | name  | geometry    |
312             | R1  | boundary | administrative | 8     | Left  | (1,2,3,4,1) |
313             | R2  | boundary | administrative | 8     | Right | (2,3,6,5,2) |
314         And the places
315             | osm | class   | type    | name      | addr+city | geometry |
316             | W1  | highway | primary | Wonderway | Right     | 8,9      |
317             | N1  | amenity | cafe    | Bolder    | Left      | 9        |
318         When importing
319         Then place_addressline contains exactly
320            | object | address | isaddress |
321            | W1     | R2      | True      |
322            | N1     | R1      | True      |
323         When geocoding "Bolder"
324         Then the result set contains
325            | object | display_name            |
326            | N1     | Bolder, Wonderway, Left |
327
328     Scenario: addr:* tags do not produce addresslines when the parent has the address part
329         Given the grid
330             | 1 |   |   | 5 |
331             |   | 8 | 9 |   |
332             | 4 |   |   | 6 |
333         And the places
334             | osm | class    | type           | admin | name  | geometry    |
335             | R1  | boundary | administrative | 8     | Outer | (1,5,6,4,1) |
336         And the places
337             | osm | class   | type    | name      | addr+city | geometry |
338             | W1  | highway | primary | Wonderway | Outer     | 8,9      |
339             | N1  | amenity | cafe    | Bolder    | Outer     | 9        |
340         When importing
341         Then place_addressline contains exactly
342            | object | address | isaddress |
343            | W1     | R1      | True      |
344         When geocoding "Bolder"
345         Then the result set contains
346            | object | display_name             |
347            | N1     | Bolder, Wonderway, Outer |
348
349     Scenario: addr:* tags on outside do not produce addresslines when the parent has the address part
350         Given the grid
351             | 1 |   | 2 |   |   | 5 |
352             |   |   |   | 8 | 9 |   |
353             | 4 |   | 3 |   |   | 6 |
354         And the places
355             | osm | class    | type           | admin | name  | geometry    |
356             | R1  | boundary | administrative | 8     | Left  | (1,2,3,4,1) |
357             | R2  | boundary | administrative | 8     | Right | (2,3,6,5,2) |
358         And the places
359             | osm | class   | type    | name      | addr+city | geometry |
360             | W1  | highway | primary | Wonderway | Left      | 8,9      |
361             | N1  | amenity | cafe    | Bolder    | Left      | 9        |
362         When importing
363         Then place_addressline contains exactly
364            | object | address | isaddress |
365            | W1     | R1      | True      |
366            | W1     | R2      | False     |
367         When geocoding "Bolder"
368         Then the result set contains
369            | object | display_name            |
370            | N1     | Bolder, Wonderway, Left |
371
372     Scenario: POIs can correct address parts on the fly
373         Given the grid
374             | 1 |   |   |   |  2 |   | 5 |
375             |   |   |   | 9 |    | 8 |   |
376             | 4 |   |   |   |  3 |   | 6 |
377         And the places
378             | osm | class    | type           | admin | name  | geometry    |
379             | R1  | boundary | administrative | 8     | Left  | (1,2,3,4,1) |
380             | R2  | boundary | administrative | 8     | Right | (2,3,6,5,2) |
381         And the places
382             | osm | class   | type    | name      | geometry |
383             | W1  | highway | primary | Wonderway | 2,3      |
384             | N1  | amenity | cafe    | Bolder    | 9        |
385             | N2  | amenity | cafe    | Leftside  | 8        |
386         When importing
387         Then place_addressline contains exactly
388            | object | address | isaddress |
389            | W1     | R1      | False     |
390            | W1     | R2      | True      |
391         When geocoding "Bolder"
392         Then the result set contains
393            | object | display_name            |
394            | N1     | Bolder, Wonderway, Left |
395         When geocoding "Leftside"
396         Then the result set contains
397            | object | display_name               |
398            | N2     | Leftside, Wonderway, Right |
399
400
401     Scenario: POIs can correct address parts on the fly (with partial unmatching address)
402         Given the grid
403             | 1 |   |   |   |  2 |   | 5 |
404             |   |   |   | 9 |    | 8 |   |
405             |   | 10| 11|   |    | 12|   |
406             | 4 |   |   |   |  3 |   | 6 |
407         And the places
408             | osm | class    | type           | admin | name  | geometry    |
409             | R1  | boundary | administrative | 8     | Left  | (1,2,3,4,1) |
410             | R2  | boundary | administrative | 8     | Right | (2,3,6,5,2) |
411         And the places
412             | osm | class   | type    | name      | geometry |
413             | W1  | highway | primary | Wonderway | 10,11,12 |
414         And the places
415             | osm | class   | type    | name      | addr+suburb | geometry |
416             | N1  | amenity | cafe    | Bolder    | Boring      | 9        |
417             | N2  | amenity | cafe    | Leftside  | Boring      | 8        |
418         When importing
419         Then place_addressline contains exactly
420            | object | address | isaddress |
421            | W1     | R1      | True      |
422            | W1     | R2      | False     |
423         When geocoding "Bolder"
424         Then the result set contains
425            | object | display_name            |
426            | N1     | Bolder, Wonderway, Left |
427         When geocoding "Leftside"
428         Then the result set contains
429            | object | display_name               |
430            | N2     | Leftside, Wonderway, Right |
431
432
433
434     Scenario: POIs can correct address parts on the fly (with partial matching address)
435         Given the grid
436             | 1 |   |   |   |  2 |   | 5 |
437             |   |   |   | 9 |    | 8 |   |
438             |   | 10| 11|   |    | 12|   |
439             | 4 |   |   |   |  3 |   | 6 |
440         And the places
441             | osm | class    | type           | admin | name  | geometry    |
442             | R1  | boundary | administrative | 8     | Left  | (1,2,3,4,1) |
443             | R2  | boundary | administrative | 8     | Right | (2,3,6,5,2) |
444         And the places
445             | osm | class   | type    | name      | geometry |
446             | W1  | highway | primary | Wonderway | 10,11,12 |
447         And the places
448             | osm | class   | type    | name      | addr+state | geometry |
449             | N1  | amenity | cafe    | Bolder    | Left       | 9        |
450             | N2  | amenity | cafe    | Leftside  | Left       | 8        |
451         When importing
452         Then place_addressline contains exactly
453            | object | address | isaddress |
454            | W1     | R1      | True      |
455            | W1     | R2      | False     |
456         When geocoding "Bolder"
457         Then the result set contains
458            | object | display_name            |
459            | N1     | Bolder, Wonderway, Left |
460         When geocoding "Leftside"
461         Then the result set contains
462            | object | display_name               |
463            | N2     | Leftside, Wonderway, Left |
464
465
466     Scenario: addr:* tags always match the closer area
467         Given the grid
468             | 1 |   |   |   |  2 |   | 5 |
469             |   |   |   |   |    |   |   |
470             | 4 |   |   |   |  3 |   | 6 |
471             |   | 10| 11|   |    |   |   |
472         And the places
473             | osm | class    | type           | admin | name  | geometry    |
474             | R1  | boundary | administrative | 8     | Left  | (1,2,3,4,1) |
475             | R2  | boundary | administrative | 8     | Left  | (2,3,6,5,2) |
476         And the places
477             | osm | class   | type    | name      | addr+city | geometry |
478             | W1  | highway | primary | Wonderway | Left      | 10,11    |
479         When importing
480         Then place_addressline contains exactly
481             | object | address |
482             | W1     | R1      |
483
484     Scenario: Full name is prefered for unlisted addr:place tags
485         Given the grid
486             |   | 1 | 2 |   |
487             | 8 |   |   | 9 |
488         And the places
489             | osm | class | type | name    | geometry |
490             | W10 | place | city | Away    | (8,1,2,9,8) |
491         And the places
492             | osm | class   | type        | name          | addr+city | geometry |
493             | W1  | highway | residential | Royal Terrace | Gardens   | 8,9      |
494         And the places
495             | osm | class | type  | housenr | addr+place            | geometry | extra+foo |
496             | N1  | place | house | 1       | Royal Terrace Gardens | 1        | bar |
497         And the places
498             | osm | class | type  | housenr | addr+street   | geometry |
499             | N2  | place | house | 2       | Royal Terrace | 2        |
500         When importing
501         When geocoding "1, Royal Terrace Gardens"
502         Then result 0 contains
503             | object |
504             | N1  |