]> git.openstreetmap.org Git - nominatim.git/blob - test/bdd/db/import/linking.feature
fa96e5b31e94b12ba1b0399e05b8d4d4e864b756
[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 scene way-area-with-center
7         And the places
8          | osm  | class   | type   | name  | geometry |
9          | R13  | landuse | forest | Garbo | :area |
10          | N256 | natural | peak   | Garbo | :inner-C |
11         When importing
12         Then placex contains
13          | object  | linked_place_id |
14          | R13     | - |
15          | N256    | - |
16
17     Scenario: Waterways are linked when in waterway relations
18         Given the scene split-road
19         And the places
20          | osm | class    | type  | name  | geometry |
21          | W1  | waterway | river | Rhein | :w-2 |
22          | W2  | waterway | river | Rhein | :w-3 |
23          | R13 | waterway | river | Rhein | :w-1 + :w-2 + :w-3 |
24          | R23 | waterway | river | Limmat| :w-4a |
25         And the relations
26          | id | members                          | tags+type |
27          | 13 | R23:tributary,W1,W2:main_stream  | waterway |
28         When importing
29         Then placex contains
30          | object | linked_place_id |
31          | W1     | R13 |
32          | W2     | R13 |
33          | R13    | -   |
34          | R23    | -   |
35         When searching for "rhein"
36         Then results contain
37          | osm_type |
38          | R |
39
40     Scenario: Relations are not linked when in waterway relations
41         Given the scene split-road
42         And the places
43          | osm | class    | type   | name  | geometry |
44          | W1  | waterway | stream | Rhein | :w-2 |
45          | W2  | waterway | river  | Rhein | :w-3 |
46          | R1  | waterway | river  | Rhein | :w-1 + :w-2 + :w-3 |
47          | R2  | waterway | river  | Limmat| :w-4a |
48         And the relations
49          | id | members                          | tags+type |
50          | 1  | R2                               | waterway  |
51         When importing
52         Then placex contains
53          | object | linked_place_id |
54          | W1     | - |
55          | W2     | - |
56          | R1     | - |
57          | R2     | - |
58
59     Scenario: Empty waterway relations are handled correctly
60         Given the scene split-road
61         And the places
62          | osm | class    | type  | name  | geometry |
63          | R1  | waterway | river | Rhein | :w-1 + :w-2 + :w-3 |
64         And the relations
65          | id | members  | tags+type |
66          | 1  |          | waterway |
67         When importing
68         Then placex contains
69          | object | linked_place_id |
70          | R1     | - |
71
72     Scenario: Waterways are not linked when the way type is not a river feature
73         Given the scene split-road
74         And the places
75          | osm | class    | type     | name  | geometry |
76          | W1  | waterway | lock     | Rhein | :w-2 |
77          | R1  | waterway | river    | Rhein | :w-1 + :w-2 + :w-3 |
78         And the relations
79          | id | members               | tags+type |
80          | 1  | N23,N34,W1,R45        | multipolygon |
81         When importing
82         Then placex contains
83          | object | linked_place_id |
84          | W1     | - |
85          | R1     | - |
86         When searching for "rhein"
87         Then results contain
88           | ID | osm_type |
89           |  0 | R |
90           |  1 | W |
91
92     Scenario: Side streams are linked only when they have the same name
93         Given the scene split-road
94         And the places
95          | osm | class    | type  | name   | geometry |
96          | W1  | waterway | river | Rhein2 | :w-2 |
97          | W2  | waterway | river | Rhein  | :w-3 |
98          | R1  | waterway | river | Rhein  | :w-1 + :w-2 + :w-3 |
99         And the relations
100          | id | members                           | tags+type |
101          | 1  | W1:side_stream,W2:side_stream     | waterway |
102         When importing
103         Then placex contains
104          | object | linked_place_id |
105          | W1     | -  |
106          | W2     | R1 |
107         When searching for "rhein2"
108         Then results contain
109          | osm_type |
110          | W |
111
112     # github #573
113     Scenario: Boundaries should only be linked to places
114         Given the named places
115          | osm | class    | type           | extra+wikidata | admin | geometry |
116          | R1  | boundary | administrative | 34             | 8     | poly-area:0.1 |
117         And the named places
118          | osm | class    | type           | geometry |
119          | N3  | natural  | island         | 0.00001 0 |
120          | N3  | place    | city           | 0.00001 0 |
121         And the relations
122          | id | members  |
123          | 1  | N3:label |
124         When importing
125         Then placex contains
126          | object     | linked_place_id |
127          | N3:natural | -               |
128          | N3:place   | R1              |
129
130     Scenario: Nodes with 'role' label are always linked
131         Given the places
132          | osm  | class    | type           | admin | name  | geometry |
133          | R13  | boundary | administrative | 6     | Garbo | poly-area:0.1 |
134          | N2   | place    | hamlet         | 15    | Vario | 0.006 0.00001 |
135         And the relations
136          | id | members       | tags+type |
137          | 13 | N2:label      | boundary |
138         When importing
139         Then placex contains
140          | object  | linked_place_id |
141          | N2      | R13 |
142         And placex contains
143          | object | centroid      | name+name | extratags+linked_place |
144          | R13    | 0.006 0.00001 | Garbo     | hamlet |
145
146     Scenario: Boundaries with place tags are linked against places with same type
147         Given the places
148          | osm  | class    | type           | admin | name   | extra+place | geometry |
149          | R13  | boundary | administrative | 4     | Berlin | city        |poly-area:0.1 |
150         And the places
151          | osm  | class    | type           | name   | geometry |
152          | N2   | place    | city           | Berlin | 0.006 0.00001 |
153         When importing
154         Then placex contains
155          | object  | linked_place_id |
156          | N2      | R13             |
157         And placex contains
158          | object | rank_address |
159          | R13    | 16 |
160         When searching for ""
161          | city |
162          | Berlin |
163         Then results contain
164           | ID | osm_type | osm_id |
165           |  0 | R | 13 |
166         When searching for ""
167          | state |
168          | Berlin |
169         Then results contain
170           | ID | osm_type | osm_id |
171           |  0 | R | 13 |
172
173
174     Scenario: Boundaries without place tags only link against same admin level
175         Given the places
176          | osm  | class    | type           | admin | name   | geometry |
177          | R13  | boundary | administrative | 4     | Berlin |poly-area:0.1 |
178         And the places
179          | osm  | class    | type           | name   | geometry |
180          | N2   | place    | city           | Berlin | 0.006 0.00001 |
181         When importing
182         Then placex contains
183          | object  | linked_place_id |
184          | N2      | -               |
185         And placex contains
186          | object | rank_address |
187          | R13    | 8 |
188         When searching for ""
189          | state |
190          | Berlin |
191         Then results contain
192           | ID | osm_type | osm_id |
193           |  0 | R | 13 |
194         When searching for ""
195          | city |
196          | Berlin |
197         Then results contain
198           | ID | osm_type | osm_id |
199           |  0 | N | 2 |
200
201     # github #1352
202     Scenario: Do not use linked centroid when it is outside the area
203         Given the named places
204          | osm  | class    | type           | admin | geometry |
205          | R13  | boundary | administrative | 4     | poly-area:0.01 |
206         And the named places
207          | osm  | class    | type           | geometry |
208          | N2   | place    | city           | 0.1 0.1 |
209         And the relations
210          | id | members       | tags+type |
211          | 13 | N2:label      | boundary |
212         When importing
213         Then placex contains
214          | object | linked_place_id |
215          | N2     | R13             |
216         And placex contains
217          | object | centroid |
218          | R13    | in geometry  |