]> git.openstreetmap.org Git - nominatim.git/blob - test/bdd/features/db/import/linking.feature
release 5.1.0.post8
[nominatim.git] / test / bdd / features / db / import / linking.feature
1 Feature: Linking of places
2     Tests for correctly determining linked places
3
4     Scenario: Only address-describing places can be linked
5         Given the grid
6          | 1 |  |   |  | 2 |
7          |   |  | 9 |  |   |
8          | 4 |  |   |  | 3 |
9         And the places
10          | osm  | class   | type   | name  | geometry |
11          | R13  | landuse | forest | Garbo | (1,2,3,4,1) |
12          | N256 | natural | peak   | Garbo | 9 |
13         When importing
14         Then placex contains
15          | object  | linked_place_id |
16          | R13     | - |
17          | N256    | - |
18
19     Scenario: Postcode areas cannot be linked
20         Given the grid with origin US
21          | 1 |   | 2 |
22          |   | 9 |   |
23          | 4 |   | 3 |
24         And the named places
25          | osm | class    | type        | addr+postcode  | extra+wikidata | geometry    |
26          | R13 | boundary | postal_code | 12345          | Q87493         | (1,2,3,4,1) |
27          | N25 | place    | suburb      | 12345          | Q87493         | 9 |
28         When importing
29         Then placex contains
30          | object | linked_place_id |
31          | R13    | - |
32          | N25    | - |
33
34      Scenario: Waterways are linked when in waterway relations
35         Given the grid
36          | 1 |  |   |  | 3 | 4  |  |   |  | 6 |
37          |   |  | 2 |  |   | 10 |  | 5 |  |   |
38          |   |  |   |  |   | 11 |  |   |  |   |
39         And the places
40          | osm | class    | type  | name  | geometry |
41          | W1  | waterway | river | Rhein | 1,2,3    |
42          | W2  | waterway | river | Rhein | 3,4,5    |
43          | R13 | waterway | river | Rhein | 1,2,3,4,5,6 |
44          | R23 | waterway | river | Limmat| 4,10,11  |
45         And the relations
46          | id | members                          | tags+type |
47          | 13 | R23:tributary,W1,W2:main_stream  | waterway |
48         When importing
49         Then placex contains
50          | object | linked_place_id |
51          | W1     | R13 |
52          | W2     | R13 |
53          | R13    | -   |
54          | R23    | -   |
55         When geocoding "rhein"
56         Then the result set contains
57          | object |
58          | R13    |
59
60     Scenario: Relations are not linked when in waterway relations
61         Given the grid
62          | 1 |  |   |  | 3 | 4  |  |   |  | 6 |
63          |   |  | 2 |  |   | 10 |  | 5 |  |   |
64          |   |  |   |  |   | 11 |  |   |  |   |
65         And the places
66          | osm | class    | type   | name  | geometry |
67          | W1  | waterway | stream | Rhein | 1,2,3,4 |
68          | W2  | waterway | river  | Rhein | 4,5,6 |
69          | R1  | waterway | river  | Rhein | 1,2,3,4 |
70          | R2  | waterway | river  | Limmat| 4,10,11 |
71         And the relations
72          | id | members                          | tags+type |
73          | 1  | R2                               | waterway  |
74         When importing
75         Then placex contains
76          | object | linked_place_id |
77          | W1     | - |
78          | W2     | - |
79          | R1     | - |
80          | R2     | - |
81         When geocoding "rhein"
82         Then result 0 contains
83           | object |
84           | R1  |
85         And result 1 contains
86           | object |
87           | W2  |
88
89
90     Scenario: Empty waterway relations are handled correctly
91         Given the grid
92          | 1 |  |   |  | 3 |
93         And the places
94          | osm | class    | type  | name  | geometry |
95          | R1  | waterway | river | Rhein | 1,3 |
96         And the relations
97          | id | members  | tags+type |
98          | 1  |          | waterway |
99         When importing
100         Then placex contains
101          | object | linked_place_id |
102          | R1     | - |
103
104     Scenario: Waterways are not linked when the way type is not a river feature
105         Given the grid
106          | 1 |   | 2 |
107          |   |   |   |
108          | 3 |   | 4 |
109         And the places
110          | osm | class    | type     | name  | geometry |
111          | W1  | waterway | lock     | Rhein | 3,4 |
112          | R1  | landuse  | meadow   | Rhein | (3,1,2,4,3) |
113         And the relations
114          | id | members      | tags+type |
115          | 1  | W1,W2        | multipolygon |
116         When importing
117         Then placex contains
118          | object | linked_place_id |
119          | W1     | - |
120          | R1     | - |
121
122     Scenario: Side streams are linked only when they have the same name
123         Given the grid
124          |   |  |   |   | 8 |   |   |  |
125          | 1 |  | 2 | 3 |   | 4 | 5 | 6|
126          |   |  |   |   |   | 9 |   |  |
127         And the places
128          | osm | class    | type  | name   | geometry |
129          | W1  | waterway | river | Rhein2 | 2,8,4 |
130          | W2  | waterway | river | Rhein  | 3,9,5 |
131          | R1  | waterway | river | Rhein  | 1,2,3,4,5,6 |
132         And the relations
133          | id | members                           | tags+type |
134          | 1  | W1:side_stream,W2:side_stream,W3  | waterway |
135         When importing
136         Then placex contains
137          | object | linked_place_id |
138          | W1     | -  |
139          | W2     | R1 |
140         When geocoding "rhein2"
141         Then the result set contains
142          | object |
143          | W1  |
144
145     # github #573
146     Scenario: Boundaries should only be linked to places
147         Given the 0.05 grid
148          | 1 |   | 2 |
149          |   | 9 |   |
150          | 4 |   | 3 |
151         Given the named places
152          | osm | class    | type           | extra+wikidata | admin | geometry    |
153          | R1  | boundary | administrative | 34             | 8     | (1,2,3,4,1) |
154         And the named places
155          | osm | class    | type           |
156          | N9  | natural  | island         |
157          | N9  | place    | city           |
158         And the relations
159          | id | members  |
160          | 1  | N9:label |
161         When importing
162         Then placex contains
163          | object     | linked_place_id |
164          | N9:natural | -               |
165          | N9:place   | R1              |
166
167     Scenario: Nodes with 'role' label are always linked
168         Given the 0.05 grid
169          | 1 |   | 2 |
170          |   | 9 |   |
171          | 4 |   | 3 |
172         Given the places
173          | osm  | class    | type           | admin | name  | geometry    |
174          | R13  | boundary | administrative | 6     | Garbo | (1,2,3,4,1) |
175          | N2   | place    | hamlet         | 15    | Vario | 9           |
176         And the relations
177          | id | members       | tags+type |
178          | 13 | N2:label      | boundary |
179         When importing
180         Then placex contains
181          | object  | linked_place_id |
182          | N2      | R13 |
183         And placex contains
184          | object | centroid!wkt | name+name | extratags+linked_place |
185          | R13    | 9            | Garbo     | hamlet |
186
187     Scenario: Boundaries with place tags are linked against places with same type
188         Given the 0.01 grid
189          | 1 |   | 2 |
190          |   | 9 |   |
191          | 4 |   | 3 |
192         Given the places
193          | osm  | class    | type           | admin | name   | extra+place | geometry    |
194          | R13  | boundary | administrative | 4     | Berlin | city        | (1,2,3,4,1) |
195         And the places
196          | osm  | class    | type           | name   | geometry |
197          | N2   | place    | city           | Berlin | 9 |
198         When importing
199         Then placex contains
200          | object  | linked_place_id |
201          | N2      | R13             |
202         And placex contains
203          | object | rank_address |
204          | R13    | 16 |
205         When geocoding ""
206          | city |
207          | Berlin |
208         Then result 0 contains
209           | object |
210           | R13 |
211         When geocoding ""
212          | state |
213          | Berlin |
214         Then result 0 contains
215           | object |
216           | R13 |
217
218
219     Scenario: Boundaries without place tags only link against same admin level
220         Given the 0.05 grid
221          | 1 |   | 2 |
222          |   | 9 |   |
223          | 4 |   | 3 |
224         Given the places
225          | osm  | class    | type           | admin | name   | geometry |
226          | R13  | boundary | administrative | 4     | Berlin | (1,2,3,4,1) |
227         And the places
228          | osm  | class    | type           | name   | geometry |
229          | N2   | place    | city           | Berlin | 9 |
230         When importing
231         Then placex contains
232          | object  | linked_place_id |
233          | N2      | -               |
234         And placex contains
235          | object | rank_address |
236          | R13    | 8 |
237         When geocoding ""
238          | state |
239          | Berlin |
240         Then result 0 contains
241           | object |
242           | R13 |
243         When geocoding ""
244          | city |
245          | Berlin |
246         Then result 0 contains
247           | object |
248           | N2  |
249
250     # github #1352
251     Scenario: Do not use linked centroid when it is outside the area
252         Given the 0.05 grid
253          | 1 |   | 2 |   |
254          |   |   |   | 9 |
255          | 4 |   | 3 |   |
256         Given the named places
257          | osm  | class    | type           | admin | geometry |
258          | R13  | boundary | administrative | 4     | (1,2,3,4,1) |
259         And the named places
260          | osm  | class    | type           | geometry |
261          | N2   | place    | city           | 9 |
262         And the relations
263          | id | members       | tags+type |
264          | 13 | N2:label      | boundary |
265         When importing
266         Then placex contains
267          | object | linked_place_id |
268          | N2     | R13             |
269         And placex contains
270          | object | centroid!in_box |
271          | R13    | 0,0,0.1,0.1      |
272
273     Scenario: Place nodes can only be linked once
274         Given the 0.02 grid
275          | 1 |   | 2 |   | 5 |
276          |   | 9 |   |   |   |
277          | 4 |   | 3 |   | 6 |
278         Given the named places
279          | osm  | class    | type | extra+wikidata | geometry |
280          | N2   | place    | city | Q1234          | 9        |
281         And the named places
282          | osm  | class    | type           | extra+wikidata | admin | geometry        |
283          | R1   | boundary | administrative | Q1234          | 8     | (1,2,5,6,3,4,1) |
284          | R2   | boundary | administrative | Q1234          | 9     | (1,2,3,4,1)     |
285         When importing
286         Then placex contains
287          | object | linked_place_id |
288          | N2     | R1              |
289         And placex contains
290          | object | extratags!dict                |
291          | R1     | 'linked_place' : 'city', 'wikidata': 'Q1234'  |
292          | R2     | 'wikidata': 'Q1234'                     |
293
294
295     Scenario: Boundaries without names inherit names from linked places
296         Given the 0.05 grid
297          | 1 |   | 2 |
298          |   | 9 |   |
299          | 4 |   | 3 |
300         Given the places
301          | osm | class    | type           | extra+wikidata | admin | geometry    |
302          | R1  | boundary | administrative | 34             | 8     | (1,2,3,4,1) |
303         And the places
304          | osm | class    | type           | name+name  |
305          | N9  | place    | city           | LabelPlace |
306         And the relations
307          | id | members  |
308          | 1  | N9:label |
309         When importing
310         Then placex contains
311          | object     | name+_place_name  |
312          | R1         | LabelPlace |
313
314
315     @skip
316     Scenario: Linked places expand default language names
317         Given the grid
318             | 1 |   | 2 |
319             |   | 9 |   |
320             | 4 |   | 3 |
321         Given the places
322             | osm | class    | type           | name+name                | geometry    |
323             | N9  | place    | city           | Popayán                  | 9           |
324             | R1  | boundary | administrative | Perímetro Urbano Popayán | (1,2,3,4,1) |
325         And the relations
326             | id | members  |
327             | 1  | N9:label |
328         When importing
329         Then placex contains
330             | object | name+_place_name | name+_place_name:es |
331             | R1     | Popayán          | Popayán             |
332