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