2 Feature: Parenting of objects
3 Tests that the correct parent is choosen
5 Scenario: Address inherits postcode from its street unless it has a postcode
6 Given the scene roads-with-pois
8 | osm_id | class | type | housenumber | geometry
9 | 1 | place | house | 4 | :p-N1
11 | osm_id | class | type | housenumber | postcode | geometry
12 | 2 | place | house | 5 | 99999 | :p-N1
14 | osm_id | class | type | name | postcode | geometry
15 | 1 | highway | residential | galoo | 12345 | :w-north
17 Then table placex contains
18 | object | parent_place_id
21 When sending query "4 galoo"
23 | ID | osm_type | osm_id | langaddress
24 | 0 | N | 1 | 4, galoo, 12345
25 When sending query "5 galoo"
27 | ID | osm_type | osm_id | langaddress
28 | 0 | N | 2 | 5, galoo, 99999
31 Scenario: Address without tags, closest street
32 Given the scene roads-with-pois
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
44 Then table placex contains
45 | object | parent_place_id
51 Scenario: Address without tags avoids unnamed streets
52 Given the scene roads-with-pois
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
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
66 Then table placex contains
67 | object | parent_place_id
73 Scenario: addr:street tag parents to appropriately named street
74 Given the scene roads-with-pois
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
82 | osm_id | class | type | name | geometry
83 | 1 | highway | residential | north | :w-north
84 | 2 | highway | residential | south | :w-south
86 Then table placex contains
87 | object | parent_place_id
93 Scenario: addr:street tag parents to next named street
94 Given the scene roads-with-pois
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
102 | osm_id | class | type | name | geometry
103 | 1 | highway | residential | abcdef | :w-north
104 | 2 | highway | residential | abcdef | :w-south
106 Then table placex contains
107 | object | parent_place_id
113 Scenario: addr:street tag without appropriately named street
114 Given the scene roads-with-pois
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
122 | osm_id | class | type | name | geometry
123 | 1 | highway | residential | abcde | :w-north
124 | 2 | highway | residential | abcde | :w-south
126 Then table placex contains
127 | object | parent_place_id
133 Scenario: addr:place address
134 Given the scene road-with-alley
136 | osm_id | class | type | addr_place | geometry
137 | 1 | place | house | myhamlet | :n-alley
139 | osm_id | class | type | name | geometry
140 | 2 | place | hamlet | myhamlet | :n-main-west
142 | osm_id | class | type | name | geometry
143 | 1 | highway | residential | myhamlet | :w-main
145 Then table placex contains
146 | object | parent_place_id
149 Scenario: addr:street is preferred over addr:place
150 Given the scene road-with-alley
152 | osm_id | class | type | addr_place | street | geometry
153 | 1 | place | house | myhamlet | mystreet| :n-alley
155 | osm_id | class | type | name | geometry
156 | 2 | place | hamlet | myhamlet | :n-main-west
158 | osm_id | class | type | name | geometry
159 | 1 | highway | residential | mystreet | :w-main
161 Then table placex contains
162 | object | parent_place_id
165 Scenario: Untagged address in simple associated street relation
166 Given the scene road-with-alley
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
173 | osm_id | class | type | name | geometry
174 | 1 | highway | residential | foo | :w-main
175 | 2 | highway | service | bar | :w-alley
177 | id | members | tags
178 | 1 | W1:street,N1,N2,N3 | 'type' : 'associatedStreet'
180 Then table placex contains
181 | object | parent_place_id
186 Scenario: Avoid unnamed streets in simple associated street relation
187 Given the scene road-with-alley
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
197 | osm_id | class | type | geometry
198 | 2 | highway | residential | :w-alley
200 | id | members | tags
201 | 1 | N1,N2,N3,W2:street,W1:street | 'type' : 'associatedStreet'
203 Then table placex contains
204 | object | parent_place_id
210 Scenario: Associated street relation overrides addr:street
211 Given the scene road-with-alley
213 | osm_id | class | type | street | geometry
214 | 1 | place | house | bar | :n-alley
216 | osm_id | class | type | name | geometry
217 | 1 | highway | residential | foo | :w-main
218 | 2 | highway | residential | bar | :w-alley
220 | id | members | tags
221 | 1 | W1:street,N1,N2,N3 | 'type' : 'associatedStreet'
223 Then table placex contains
224 | object | parent_place_id
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
235 Then table placex contains
236 | object | parent_place_id
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
245 | osm_id | class | type | name | geometry
246 | 2 | highway | primary | bar | :w-WE
247 | 3 | highway | residential | foo | :w-NS
249 Then table placex contains
250 | object | parent_place_id
253 Scenario: Building with addr:place tags
254 Given the scene building-on-street-corner
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
262 | osm_id | class | type | name | geometry
263 | 2 | highway | primary | bar | :w-WE
264 | 3 | highway | residential | foo | :w-NS
266 Then table placex contains
267 | object | parent_place_id
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
276 | osm_id | class | type | name | geometry
277 | 2 | highway | primary | bar | :w-WE
278 | 3 | highway | residential | foo | :w-NS
280 | id | members | tags
281 | 1 | W1:house,W2:street | 'type' : 'associatedStreet'
283 Then table placex contains
284 | object | parent_place_id
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
293 | osm_id | class | type | name | geometry
294 | 2 | highway | primary | bar | :w-WE
295 | 3 | highway | residential | foo | :w-NS
297 | id | members | tags
298 | 1 | W1:house,W2:street | 'type' : 'associatedStreet'
300 Then table placex contains
301 | object | parent_place_id
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
313 | osm_id | class | type | name | geometry
314 | 2 | highway | primary | bar | :w-WE
315 | 3 | highway | residential | foo | :w-NS
317 | id | members | tags
318 | 1 | N1:house,W1:street,W3:street | 'type' : 'associatedStreet'
320 Then table placex contains
321 | object | parent_place_id
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
332 | osm_id | class | type | street | addr_place | housenumber | geometry
333 | 1 | building | yes | foo | nowhere | 3 | :w-building
335 | osm_id | class | type | name | geometry
336 | 2 | highway | primary | bar | :w-WE
337 | 3 | highway | residential | foo | :w-NS
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
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
352 | osm_id | class | type | street | addr_place | housenumber | geometry
353 | 1 | highway | path | foo | nowhere | 3 | :w-building
355 | osm_id | class | type | name | geometry
356 | 3 | highway | residential | foo | :w-NS
358 Then table placex contains
359 | object | parent_place_id | street | addr_place | housenumber
360 | N1 | W3 | None | None | None
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
374 | osm_id | class | type | name | geometry
375 | 4 | place | isolated_dwelling | theplace | :n-outer
377 | osm_id | class | type | addr_place | housenumber | geometry
378 | 1 | building | yes | theplace | 3 | :w-building
380 | osm_id | class | type | name | geometry
381 | 2 | highway | primary | bar | :w-WE
382 | 3 | highway | residential | foo | :w-NS
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
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
401 | osm_id | class | type | name | geometry
402 | 1 | highway | secondary | North St | :w-north
403 | 2 | highway | unclassified | South St | :w-south
406 | 1 | 100,101,2,103,104
407 | 2 | 200,201,1,202,203
409 Then table placex contains
410 | object | parent_place_id
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
423 | osm_id | class | type | name | geometry
424 | 1 | landuse | residential | North St | :w-north
425 | 2 | waterway| river | South St | :w-south
428 | 1 | 100,101,2,103,104
429 | 2 | 200,201,1,202,203
431 Then table placex contains
432 | object | parent_place_id
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
445 | osm_id | class | type | name | geometry
446 | 2 | highway | primary | bar | :w-WE
447 | 3 | highway | residential | foo | :w-NS
449 | id | members | tags
450 | 1 | W1:house,W2:street | 'type' : 'associatedStreet'
453 | 1 | 100,1,101,102,100
455 Then table placex contains
456 | object | parent_place_id