]> git.openstreetmap.org Git - nominatim.git/blob - tests/features/db/import/parenting.feature
Merge remote-tracking branch 'upstream/master'
[nominatim.git] / tests / features / db / import / parenting.feature
1 @DB
2 Feature: Parenting of objects
3     Tests that the correct parent is choosen
4
5     Scenario: Address inherits postcode from its street unless it has a postcode
6         Given the scene roads-with-pois
7         And the place nodes
8          | osm_id | class | type  | housenumber | geometry
9          | 1      | place | house | 4           | :p-N1
10         And the place nodes
11          | osm_id | class | type  | housenumber | postcode | geometry
12          | 2      | place | house | 5           | 99999    | :p-N1
13         And the place ways
14          | osm_id | class   | type        | name  | postcode | geometry
15          | 1      | highway | residential | galoo | 12345    | :w-north
16         When importing
17         Then table placex contains
18          | object | parent_place_id
19          | N1     | W1
20          | N2     | W1
21         When sending query "4 galoo"
22         Then results contain
23          | ID | osm_type | osm_id | langaddress
24          | 0  | N        | 1      | 4, galoo, 12345
25         When sending query "5 galoo"
26         Then results contain
27          | ID | osm_type | osm_id | langaddress
28          | 0  | N        | 2      | 5, galoo, 99999
29
30
31     Scenario: Address without tags, closest street
32         Given the scene roads-with-pois
33         And the place nodes
34          | osm_id | class | type  | geometry
35          | 1      | place | house | :p-N1
36          | 2      | place | house | :p-N2
37          | 3      | place | house | :p-S1
38          | 4      | place | house | :p-S2
39         And the named place ways
40          | osm_id | class   | type        | geometry
41          | 1      | highway | residential | :w-north
42          | 2      | highway | residential | :w-south
43         When importing
44         Then table placex contains
45          | object | parent_place_id
46          | N1     | W1
47          | N2     | W1
48          | N3     | W2
49          | N4     | W2
50
51     Scenario: Address without tags avoids unnamed streets
52         Given the scene roads-with-pois
53         And the place nodes
54          | osm_id | class | type  | geometry
55          | 1      | place | house | :p-N1
56          | 2      | place | house | :p-N2
57          | 3      | place | house | :p-S1
58          | 4      | place | house | :p-S2
59         And the place ways
60          | osm_id | class   | type        | geometry
61          | 1      | highway | residential | :w-north
62         And the named place ways
63          | osm_id | class   | type        | geometry
64          | 2      | highway | residential | :w-south
65         When importing
66         Then table placex contains
67          | object | parent_place_id
68          | N1     | W2
69          | N2     | W2
70          | N3     | W2
71          | N4     | W2
72
73     Scenario: addr:street tag parents to appropriately named street
74         Given the scene roads-with-pois
75         And the place nodes
76          | osm_id | class | type  | street| geometry
77          | 1      | place | house | south | :p-N1
78          | 2      | place | house | north | :p-N2
79          | 3      | place | house | south | :p-S1
80          | 4      | place | house | north | :p-S2
81         And the place ways
82          | osm_id | class   | type        | name  | geometry
83          | 1      | highway | residential | north | :w-north
84          | 2      | highway | residential | south | :w-south
85         When importing
86         Then table placex contains
87          | object | parent_place_id
88          | N1     | W2
89          | N2     | W1
90          | N3     | W2
91          | N4     | W1
92
93     Scenario: addr:street tag parents to next named street
94         Given the scene roads-with-pois
95         And the place nodes
96          | osm_id | class | type  | street | geometry
97          | 1      | place | house | abcdef | :p-N1
98          | 2      | place | house | abcdef | :p-N2
99          | 3      | place | house | abcdef | :p-S1
100          | 4      | place | house | abcdef | :p-S2
101         And the place ways
102          | osm_id | class   | type        | name   | geometry
103          | 1      | highway | residential | abcdef | :w-north
104          | 2      | highway | residential | abcdef | :w-south
105         When importing
106         Then table placex contains
107          | object | parent_place_id
108          | N1     | W1
109          | N2     | W1
110          | N3     | W2
111          | N4     | W2
112
113     Scenario: addr:street tag without appropriately named street
114         Given the scene roads-with-pois
115         And the place nodes
116          | osm_id | class | type  | street | geometry
117          | 1      | place | house | abcdef | :p-N1
118          | 2      | place | house | abcdef | :p-N2
119          | 3      | place | house | abcdef | :p-S1
120          | 4      | place | house | abcdef | :p-S2
121         And the place ways
122          | osm_id | class   | type        | name  | geometry
123          | 1      | highway | residential | abcde | :w-north
124          | 2      | highway | residential | abcde | :w-south
125         When importing
126         Then table placex contains
127          | object | parent_place_id
128          | N1     | W1
129          | N2     | W1
130          | N3     | W2
131          | N4     | W2
132
133     Scenario: addr:place address
134         Given the scene road-with-alley
135         And the place nodes
136          | osm_id | class | type   | addr_place | geometry
137          | 1      | place | house  | myhamlet   | :n-alley
138         And the place nodes
139          | osm_id | class | type   | name     | geometry
140          | 2      | place | hamlet | myhamlet | :n-main-west
141         And the place ways
142          | osm_id | class   | type        | name     | geometry
143          | 1      | highway | residential | myhamlet | :w-main
144         When importing
145         Then table placex contains
146          | object | parent_place_id
147          | N1     | N2
148
149     Scenario: addr:street is preferred over addr:place
150         Given the scene road-with-alley
151         And the place nodes
152          | osm_id | class | type   | addr_place | street  | geometry
153          | 1      | place | house  | myhamlet   | mystreet| :n-alley
154         And the place nodes
155          | osm_id | class | type   | name     | geometry
156          | 2      | place | hamlet | myhamlet | :n-main-west
157         And the place ways
158          | osm_id | class   | type        | name     | geometry
159          | 1      | highway | residential | mystreet | :w-main
160         When importing
161         Then table placex contains
162          | object | parent_place_id
163          | N1     | W1
164
165      Scenario: Untagged address in simple associated street relation
166         Given the scene road-with-alley
167         And the place nodes
168          | osm_id | class | type  | geometry
169          | 1      | place | house | :n-alley
170          | 2      | place | house | :n-corner
171          | 3      | place | house | :n-main-west
172         And the place ways
173          | osm_id | class   | type        | name | geometry
174          | 1      | highway | residential | foo  | :w-main
175          | 2      | highway | service     | bar  | :w-alley
176         And the relations
177          | id | members            | tags
178          | 1  | W1:street,N1,N2,N3 | 'type' : 'associatedStreet'
179         When importing
180         Then table placex contains
181          | object | parent_place_id
182          | N1     | W1
183          | N2     | W1
184          | N3     | W1
185          
186     Scenario: Avoid unnamed streets in simple associated street relation
187         Given the scene road-with-alley
188         And the place nodes
189          | osm_id | class | type  | geometry
190          | 1      | place | house | :n-alley
191          | 2      | place | house | :n-corner
192          | 3      | place | house | :n-main-west
193         And the named place ways
194          | osm_id | class   | type        | geometry
195          | 1      | highway | residential | :w-main
196         And the place ways
197          | osm_id | class   | type        | geometry
198          | 2      | highway | residential | :w-alley
199         And the relations
200          | id | members            | tags
201          | 1  | N1,N2,N3,W2:street,W1:street | 'type' : 'associatedStreet'
202         When importing
203         Then table placex contains
204          | object | parent_place_id
205          | N1     | W1
206          | N2     | W1
207          | N3     | W1
208
209     ### Scenario 10
210     Scenario: Associated street relation overrides addr:street
211         Given the scene road-with-alley
212         And the place nodes
213          | osm_id | class | type  | street | geometry
214          | 1      | place | house | bar    | :n-alley
215         And the place ways
216          | osm_id | class   | type        | name | geometry
217          | 1      | highway | residential | foo  | :w-main
218          | 2      | highway | residential | bar  | :w-alley
219         And the relations
220          | id | members            | tags
221          | 1  | W1:street,N1,N2,N3 | 'type' : 'associatedStreet'
222         When importing
223         Then table placex contains
224          | object | parent_place_id
225          | N1     | W1
226
227     Scenario: Building without tags, closest street from center point
228         Given the scene building-on-street-corner
229         And the named place ways
230          | osm_id | class    | type        | geometry
231          | 1      | building | yes         | :w-building
232          | 2      | highway  | primary     | :w-WE
233          | 3      | highway  | residential | :w-NS
234         When importing
235         Then table placex contains
236          | object | parent_place_id
237          | W1     | W3
238
239     Scenario: Building with addr:street tags
240         Given the scene building-on-street-corner
241         And the named place ways
242          | osm_id | class    | type | street | geometry
243          | 1      | building | yes  | bar    | :w-building
244         And the place ways
245          | osm_id | class    | type        | name | geometry
246          | 2      | highway  | primary     | bar  | :w-WE
247          | 3      | highway  | residential | foo  | :w-NS
248         When importing
249         Then table placex contains
250          | object | parent_place_id
251          | W1     | W2
252
253     Scenario: Building with addr:place tags
254         Given the scene building-on-street-corner
255         And the place nodes
256          | osm_id | class | type    | name | geometry
257          | 1      | place | village | bar  | :n-outer
258         And the named place ways
259          | osm_id | class    | type | addr_place | geometry
260          | 1      | building | yes  | bar        | :w-building
261         And the place ways
262          | osm_id | class    | type        | name | geometry
263          | 2      | highway  | primary     | bar  | :w-WE
264          | 3      | highway  | residential | foo  | :w-NS
265         When importing
266         Then table placex contains
267          | object | parent_place_id
268          | W1     | N1
269
270     Scenario: Building in associated street relation
271         Given the scene building-on-street-corner
272         And the named place ways
273          | osm_id | class    | type | geometry
274          | 1      | building | yes  | :w-building
275         And the place ways
276          | osm_id | class    | type        | name | geometry
277          | 2      | highway  | primary     | bar  | :w-WE
278          | 3      | highway  | residential | foo  | :w-NS
279         And the relations
280          | id | members            | tags
281          | 1  | W1:house,W2:street | 'type' : 'associatedStreet'
282         When importing
283         Then table placex contains
284          | object | parent_place_id
285          | W1     | W2
286
287     Scenario: Building in associated street relation overrides addr:street
288         Given the scene building-on-street-corner
289         And the named place ways
290          | osm_id | class    | type | street | geometry
291          | 1      | building | yes  | foo    | :w-building
292         And the place ways
293          | osm_id | class    | type        | name | geometry
294          | 2      | highway  | primary     | bar  | :w-WE
295          | 3      | highway  | residential | foo  | :w-NS
296         And the relations
297          | id | members            | tags
298          | 1  | W1:house,W2:street | 'type' : 'associatedStreet'
299         When importing
300         Then table placex contains
301          | object | parent_place_id
302          | W1     | W2
303
304     Scenario: Wrong member in associated street relation is ignored
305         Given the scene building-on-street-corner
306         And the named place nodes
307          | osm_id | class | type  | geometry
308          | 1      | place | house | :n-outer
309         And the named place ways
310          | osm_id | class    | type | street | geometry
311          | 1      | building | yes  | foo    | :w-building
312         And the place ways
313          | osm_id | class    | type        | name | geometry
314          | 2      | highway  | primary     | bar  | :w-WE
315          | 3      | highway  | residential | foo  | :w-NS
316         And the relations
317          | id | members                      | tags
318          | 1  | N1:house,W1:street,W3:street | 'type' : 'associatedStreet'
319         When importing
320         Then table placex contains
321          | object | parent_place_id
322          | N1     | W3
323
324     Scenario: POIs in building inherit address
325         Given the scene building-on-street-corner
326         And the named place nodes
327          | osm_id | class   | type       | geometry
328          | 1      | amenity | bank       | :n-inner
329          | 2      | shop    | bakery     | :n-edge-NS
330          | 3      | shop    | supermarket| :n-edge-WE
331         And the place ways
332          | osm_id | class    | type | street | addr_place | housenumber | geometry
333          | 1      | building | yes  | foo    | nowhere    | 3           | :w-building
334         And the place ways
335          | osm_id | class    | type        | name | geometry
336          | 2      | highway  | primary     | bar  | :w-WE
337          | 3      | highway  | residential | foo  | :w-NS
338         When importing
339         Then table placex contains
340          | object | parent_place_id | street | addr_place | housenumber
341          | W1     | W3              | foo    | nowhere    | 3
342          | N1     | W3              | foo    | nowhere    | 3
343          | N2     | W3              | foo    | nowhere    | 3
344          | N3     | W3              | foo    | nowhere    | 3
345
346     Scenario: POIs don't inherit from streets
347         Given the scene building-on-street-corner
348         And the named place nodes
349          | osm_id | class   | type       | geometry
350          | 1      | amenity | bank       | :n-inner
351         And the place ways
352          | osm_id | class    | type | street | addr_place | housenumber | geometry
353          | 1      | highway  | path | foo    | nowhere    | 3           | :w-building
354         And the place ways
355          | osm_id | class    | type        | name | geometry
356          | 3      | highway  | residential | foo  | :w-NS
357         When importing
358         Then table placex contains
359          | object | parent_place_id | street | addr_place | housenumber
360          | N1     | W3              | None   | None       | None
361
362     Scenario: POIs with own address do not inherit building address
363         Given the scene building-on-street-corner
364         And the named place nodes
365          | osm_id | class   | type       | street | geometry
366          | 1      | amenity | bank       | bar    | :n-inner
367         And the named place nodes
368          | osm_id | class   | type       | housenumber | geometry
369          | 2      | shop    | bakery     | 4           | :n-edge-NS
370         And the named place nodes
371          | osm_id | class   | type       | addr_place  | geometry
372          | 3      | shop    | supermarket| nowhere     | :n-edge-WE
373         And the place nodes
374          | osm_id | class | type              | name     | geometry
375          | 4      | place | isolated_dwelling | theplace | :n-outer
376         And the place ways
377          | osm_id | class    | type | addr_place | housenumber | geometry
378          | 1      | building | yes  | theplace   | 3           | :w-building
379         And the place ways
380          | osm_id | class    | type        | name | geometry
381          | 2      | highway  | primary     | bar  | :w-WE
382          | 3      | highway  | residential | foo  | :w-NS
383         When importing
384         Then table placex contains
385          | object | parent_place_id | street | addr_place | housenumber
386          | W1     | N4              | None   | theplace   | 3
387          | N1     | W2              | bar    | None       | None
388          | N2     | W3              | None   | None       | 4
389          | N3     | W2              | None   | nowhere    | None
390
391     ### Scenario 20
392     Scenario: POIs parent a road if they are attached to it
393         Given the scene points-on-roads
394         And the named place nodes
395          | osm_id | class   | type     | street   | geometry
396          | 1      | highway | bus_stop | North St | :n-SE
397          | 2      | highway | bus_stop | South St | :n-NW
398          | 3      | highway | bus_stop | North St | :n-S-unglued
399          | 4      | highway | bus_stop | South St | :n-N-unglued
400         And the place ways
401          | osm_id | class   | type         | name     | geometry
402          | 1      | highway | secondary    | North St | :w-north
403          | 2      | highway | unclassified | South St | :w-south
404         And the ways
405          | id | nodes
406          | 1  | 100,101,2,103,104
407          | 2  | 200,201,1,202,203
408         When importing
409         Then table placex contains
410          | object | parent_place_id
411          | N1     | W1
412          | N2     | W2
413          | N3     | W1
414          | N4     | W2
415
416     Scenario: POIs do not parent non-roads they are attached to
417         Given the scene points-on-roads
418         And the named place nodes
419          | osm_id | class   | type     | street   | geometry
420          | 1      | highway | bus_stop | North St | :n-SE
421          | 2      | highway | bus_stop | South St | :n-NW
422         And the place ways
423          | osm_id | class   | type         | name     | geometry
424          | 1      | landuse | residential  | North St | :w-north
425          | 2      | waterway| river        | South St | :w-south
426         And the ways
427          | id | nodes
428          | 1  | 100,101,2,103,104
429          | 2  | 200,201,1,202,203
430         When importing
431         Then table placex contains
432          | object | parent_place_id
433          | N1     | 0
434          | N2     | 0
435
436     Scenario: POIs on building outlines inherit associated street relation
437         Given the scene building-on-street-corner
438         And the named place nodes
439          | osm_id | class  | type  | geometry
440          | 1      | place  | house | :n-edge-NS
441         And the named place ways
442          | osm_id | class    | type | geometry
443          | 1      | building | yes  | :w-building
444         And the place ways
445          | osm_id | class    | type        | name | geometry
446          | 2      | highway  | primary     | bar  | :w-WE
447          | 3      | highway  | residential | foo  | :w-NS
448         And the relations
449          | id | members            | tags
450          | 1  | W1:house,W2:street | 'type' : 'associatedStreet'
451         And the ways
452          | id | nodes
453          | 1  | 100,1,101,102,100
454         When importing
455         Then table placex contains
456          | object | parent_place_id
457          | N1     | W2
458