]> git.openstreetmap.org Git - nominatim.git/blob - test/bdd/db/import/addressing.feature
52f966d807ffb38c140a764e301f05c05965d4a0
[nominatim.git] / test / bdd / db / import / addressing.feature
1 @DB
2 Feature: Address computation
3     Tests for filling of place_addressline
4
5     Scenario: place nodes are added to the address when they are close enough
6         Given the 0.002 grid
7             | 2 |  |  |  |  |  | 1 |  | 3 |
8         And the named places
9             | osm | class | type     | geometry |
10             | N1  | place | square   | 1 |
11             | N2  | place | hamlet   | 2 |
12             | N3  | place | hamlet   | 3 |
13         When importing
14         Then place_addressline contains
15             | object | address | fromarea |
16             | N1     | N3      | False |
17         Then place_addressline doesn't contain
18             | object | address |
19             | N1     | N2      |
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 prefered
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 |   |   |   |   |   | 3 |
74             |   | 5 |   |   |   |   |   |
75             |   | 6 |   |   |   |   |   |
76             | 2 |   |   |   |   |   | 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         When importing
83         Then place_addressline contains
84             | object | address | isaddress | cached_rank_address |
85             | N1     | R1      | True      | 16                  |
86             | N1     | N2      | False     | 16                  |
87
88     Scenario: place nodes outside a smaller ranked area are ignored
89         Given the grid
90             | 1 |   | 2 |   |
91             |   | 7 |   | 9 |
92             | 4 |   | 3 |   |
93         And the named places
94             | osm | class    | type    | admin | geometry |
95             | N1  | place    | square  | 15    | 7 |
96             | N2  | place    | city    | 15    | 9 |
97             | R1  | place    | city    | 8     | (1,2,3,4,1) |
98         When importing
99         Then place_addressline contains
100             | object | address | isaddress | cached_rank_address |
101             | N1     | R1      | True      | 16                  |
102         And place_addressline doesn't contain
103             | object | address |
104             | N1     | N2      |
105
106
107     Scenario: place nodes close enough to smaller ranked place nodes are included
108         Given the 0.002 grid
109             | 2 |   | 3 | 1 |
110         And the named places
111             | osm | class | type     | geometry |
112             | N1  | place | square   | 1 |
113             | N2  | place | hamlet   | 2 |
114             | N3  | place | quarter  | 3 |
115         When importing
116         Then place_addressline contains
117             | object | address | fromarea | isaddress |
118             | N1     | N2      | False    | True      |
119             | N1     | N3      | False    | True      |
120
121
122     Scenario: place nodes too far away from a smaller ranked place nodes are marked non-address
123         Given the 0.002 grid
124             | 2 |  |  | 1 |  | 3 |
125         And the named places
126             | osm | class | type     | geometry |
127             | N1  | place | square   | 1 |
128             | N2  | place | hamlet   | 2 |
129             | N3  | place | quarter  | 3 |
130         When importing
131         Then place_addressline contains
132             | object | address | fromarea | isaddress |
133             | N1     | N2      | False    | True      |
134             | N1     | N3      | False    | False     |
135
136
137     # github #121
138     Scenario: Roads crossing boundaries should contain both states
139         Given the grid
140             | 1 |   |   | 2 |   | 3 |
141             |   | 7 |   |   | 8 |   |
142             | 4 |   |   | 5 |   | 6 |
143         And the named places
144             | osm | class   | type | geometry |
145             | W1  | highway | road | 7, 8     |
146         And the named places
147             | osm | class    | type           | admin | geometry      |
148             | W10 | boundary | administrative | 5     | (1, 2, 5, 4, 1) |
149             | W11 | boundary | administrative | 5     | (2, 3, 6, 5, 2) |
150         When importing
151         Then place_addressline contains
152             | object | address | cached_rank_address |
153             | W1     | W10     | 10                  |
154             | W1     | W11     | 10                  |
155
156
157     Scenario: Roads following a boundary should contain both states
158         Given the grid
159             | 1 |   |   | 2 |   | 3 |
160             |   |   | 8 | 7 |   |   |
161             | 4 |   |   | 5 |   | 6 |
162         And the named places
163             | osm | class   | type | geometry |
164             | W1  | highway | road | 2, 7, 8  |
165         And the named places
166             | osm | class    | type           | admin | geometry      |
167             | W10 | boundary | administrative | 5     | (1, 2, 5, 4, 1) |
168             | W11 | boundary | administrative | 5     | (2, 3, 6, 5, 2) |
169         When importing
170         Then place_addressline contains
171             | object | address | cached_rank_address |
172             | W1     | W10     | 10                  |
173             | W1     | W11     | 10                  |
174
175     Scenario: Roads should not contain boundaries they touch in a end point
176         Given the grid
177             | 1 |   |   | 2 |   | 3 |
178             |   | 7 |   | 8 |   |   |
179             | 4 |   |   | 5 |   | 6 |
180         And the named places
181             | osm | class   | type | geometry |
182             | W1  | highway | road | 7, 8     |
183         And the named places
184             | osm | class    | type           | admin | geometry      |
185             | W10 | boundary | administrative | 5     | (1, 2, 8, 5, 4, 1) |
186             | W11 | boundary | administrative | 5     | (2, 3, 6, 5, 8, 2) |
187         When importing
188         Then place_addressline contains
189             | object | address | cached_rank_address |
190             | W1     | W10     | 10                  |
191         Then place_addressline doesn't contain
192             | object | address |
193             | W1     | W11     |
194
195     Scenario: Roads should not contain boundaries they touch in a middle point
196         Given the grid
197             | 1 |   |   | 2 |   | 3 |
198             |   | 7 |   | 8 |   |   |
199             | 4 |   | 9 | 5 |   | 6 |
200         And the named places
201             | osm | class   | type | geometry |
202             | W1  | highway | road | 7, 8, 9     |
203         And the named places
204             | osm | class    | type           | admin | geometry      |
205             | W10 | boundary | administrative | 5     | (1, 2, 8, 5, 4, 1) |
206             | W11 | boundary | administrative | 5     | (2, 3, 6, 5, 8, 2) |
207         When importing
208         Then place_addressline contains
209             | object | address | cached_rank_address |
210             | W1     | W10     | 10                  |
211         Then place_addressline doesn't contain
212             | object | address |
213             | W1     | W11     |
214
215     Scenario: Locality points should contain all boundaries they touch
216         Given the 0.001 grid
217             | 1 |   |   | 2 |   | 3 |
218             |   |   |   | 8 |   |   |
219             | 4 |   |   | 5 |   | 6 |
220         And the named places
221             | osm | class | type     | geometry |
222             | N1  | place | locality | 8        |
223         And the named places
224             | osm | class    | type           | admin | geometry      |
225             | W10 | boundary | administrative | 5     | (1, 2, 8, 5, 4, 1) |
226             | W11 | boundary | administrative | 5     | (2, 3, 6, 5, 8, 2) |
227         When importing
228         Then place_addressline contains
229             | object | address | cached_rank_address |
230             | N1     | W10     | 10                  |
231             | N1     | W11     | 10                  |
232
233     Scenario: Areas should not contain boundaries they touch
234         Given the grid
235             | 1 |   |   | 2 |   | 3 |
236             |   |   |   |   |   |   |
237             | 4 |   |   | 5 |   | 6 |
238         And the named places
239             | osm | class    | type           | geometry      |
240             | W1  | landuse  | industrial     | (1, 2, 5, 4, 1) |
241         And the named places
242             | osm | class    | type           | admin | geometry      |
243             | W10 | boundary | administrative | 5     | (2, 3, 6, 5, 2) |
244         When importing
245         Then place_addressline doesn't contain
246             | object | address |
247             | W1     | W10     |
248
249     Scenario: buildings with only addr:postcodes do not appear in the address of a way
250         Given the scene admin-areas
251         And the named places
252             | osm | class    | type           | admin | addr+postcode | geometry |
253             | R1  | boundary | administrative | 6     | 112           | :b0      |
254             | R34 | boundary | administrative | 8     | 112 DE        | :b1:E    |
255             | R4  | boundary | administrative | 10    | 112 DE 34     | :b2:N    |
256         And the named places
257             | osm | class    | type           | geometry |
258             | W93 | highway  | residential    | :w2N     |
259         And the places
260             | osm | class    | type        | addr+postcode | geometry |
261             | W22 | place    | postcode    | 445023        | :building:w2N |
262         When importing
263         Then place_addressline doesn't contain
264             | object | address  |
265             | W93    | W22      |
266
267     Scenario: postcode boundaries do appear in the address of a way
268         Given the scene admin-areas
269         And the named places
270             | osm | class    | type           | admin | addr+postcode | geometry |
271             | R1  | boundary | administrative | 6     | 112           | :b0      |
272             | R34 | boundary | administrative | 8     | 112 DE        | :b1:E    |
273         And the places
274             | osm | class    | type        | addr+postcode | geometry |
275             | R4  | boundary | postal_code | 112 DE 34     | :b2:N    |
276         And the named places
277             | osm | class    | type           | geometry |
278             | W93 | highway  | residential    | :w2N     |
279         And the places
280             | osm | class    | type        | addr+postcode | geometry |
281             | W22 | place    | postcode    | 445023        | :building:w2N |
282         When importing
283         Then place_addressline contains
284             | object | address |
285             | W93    | R4      |
286
287     Scenario: squares do not appear in the address of a street
288         Given the grid
289             |   | 1 |   | 2 |   |
290             | 8 |   |   |   | 9 |
291             |   | 4 |   | 3 |   |
292         And the named places
293             | osm | class    | type           | geometry |
294             | W1  | highway  | residential    | 8, 9     |
295             | W2  | place    | square         | (1, 2, 3 ,4, 1) |
296         When importing
297         Then place_addressline doesn't contain
298             | object | address |
299             | W1     | W2      |
300