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