]> git.openstreetmap.org Git - nominatim.git/blob - test/bdd/features/db/import/rank_computation.feature
release 5.1.0.post6
[nominatim.git] / test / bdd / features / db / import / rank_computation.feature
1 Feature: Rank assignment
2     Tests for assignment of search and address ranks.
3
4     Scenario: Ranks for place nodes are assigned according to their type
5         Given the named places
6           | osm  | class     | type      | geometry |
7           | N1   | foo       | bar       | 0 0 |
8           | N11  | place     | Continent | 0 0 |
9           | N12  | place     | continent | 0 0 |
10           | N13  | place     | sea       | 0 0 |
11           | N14  | place     | country   | 0 0 |
12           | N15  | place     | state     | 0 0 |
13           | N16  | place     | region    | 0 0 |
14           | N17  | place     | county    | 0 0 |
15           | N18  | place     | city      | 0 0 |
16           | N19  | place     | island    | 0 0 |
17           | N36  | place     | house     | 0 0 |
18         And the named places
19           | osm  | class     | type      | extra+capital | geometry |
20           | N101 | place     | city      | yes           | 0 0 |
21         When importing
22         Then placex contains
23           | object | rank_search | rank_address |
24           | N1     | 30          | 30 |
25           | N11    | 22          | 0 |
26           | N12    | 2           | 0 |
27           | N13    | 2           | 0 |
28           | N14    | 4           | 0 |
29           | N15    | 8           | 0 |
30           | N16    | 18          | 0 |
31           | N17    | 12          | 12 |
32           | N18    | 16          | 16 |
33           | N19    | 17          | 0 |
34           | N101   | 15          | 16 |
35           | N36    | 30          | 30 |
36
37     Scenario: Ranks for boundaries are assigned according to admin level
38         Given the named places
39           | osm | class    | type           | admin | geometry |
40           | R20 | boundary | administrative | 2     | (1 1, 2 2, 1 2, 1 1) |
41           | R21 | boundary | administrative | 32    | (3 3, 4 4, 3 4, 3 3) |
42           | R22 | boundary | administrative | 6     | (0 0, 1 0, 0 1, 0 0) |
43           | R23 | boundary | administrative | 10    | (0 0, 1 1, 1 0, 0 0) |
44         When importing
45         Then placex contains
46           | object | rank_search | rank_address |
47           | R20    | 4           | 4 |
48           | R21    | 25          | 0 |
49           | R22    | 12          | 12 |
50           | R23    | 20          | 20 |
51
52     Scenario: Ranks for addressable boundaries with place assignment go with place address ranks if available
53         Given the named places
54           | osm | class    | type           | admin | extra+place | geometry |
55           | R20 | boundary | administrative | 3     | state       | (1 1, 2 2, 1 2, 1 1) |
56           | R21 | boundary | administrative | 32    | suburb      | (3 3, 4 4, 3 4, 3 3) |
57           | R22 | boundary | administrative | 6     | town        | (0 0, 1 0, 0 1, 0 0) |
58           | R23 | boundary | administrative | 10    | village     | (0 0, 1 1, 1 0, 0 0) |
59         When importing
60         Then placex contains
61           | object | rank_search | rank_address |
62           | R20    | 6           | 6  |
63           | R21    | 25          | 0  |
64           | R22    | 12          | 16 |
65           | R23    | 20          | 16 |
66
67     Scenario: Place address ranks cannot overtake a parent address rank
68         Given the named places
69           | osm | class    | type           | admin | extra+place  | geometry |
70           | R20 | boundary | administrative | 8     | town         | (0 0, 0 2, 2 2, 2 0, 0 0) |
71           | R21 | boundary | administrative | 9     | municipality | (0 0, 0 1, 1 1, 1 0, 0 0) |
72           | R22 | boundary | administrative | 9     | suburb       | (0 0, 0 1, 1 1, 1 0, 0 0) |
73         When importing
74         Then placex contains
75           | object | rank_search | rank_address |
76           | R20    | 16          | 16 |
77           | R21    | 18          | 18 |
78           | R22    | 18          | 20 |
79         Then place_addressline contains
80             | object | address | cached_rank_address |
81             | R21    | R20     | 16                  |
82             | R22    | R20     | 16                  |
83
84     Scenario: Admin levels cannot overtake each other due to place address ranks
85         Given the named places
86           | osm | class    | type           | admin | extra+place  | geometry |
87           | R20 | boundary | administrative | 6     | town         | (0 0, 0 2, 2 2, 2 0, 0 0) |
88           | R21 | boundary | administrative | 8     |              | (0 0, 0 1, 1 1, 1 0, 0 0) |
89           | R22 | boundary | administrative | 8     | suburb       | (0 0, 0 1, 1 1, 1 0, 0 0) |
90         When importing
91         Then placex contains
92           | object | rank_search | rank_address |
93           | R20    | 12          | 16 |
94           | R21    | 16          | 18 |
95           | R22    | 16          | 20 |
96         Then place_addressline contains
97             | object | address | cached_rank_address |
98             | R21    | R20     | 16                  |
99             | R22    | R20     | 16                  |
100
101     Scenario: Admin levels cannot overtake each other due to place address ranks even when slightly misaligned
102         Given the named places
103           | osm | class    | type           | admin | extra+place  | geometry |
104           | R20 | boundary | administrative | 6     | town         | (0 0, 0 2, 2 2, 2 0, 0 0) |
105           | R21 | boundary | administrative | 8     |              | (0 0, -0.0001 1, 1 1, 1 0, 0 0) |
106         When importing
107         Then placex contains
108           | object | rank_search | rank_address |
109           | R20    | 12          | 16 |
110           | R21    | 16          | 18 |
111         Then place_addressline contains
112             | object | address | cached_rank_address |
113             | R21    | R20     | 16                  |
114
115     Scenario: Admin levels must not be larger than 25
116         Given the named places
117           | osm | class    | type           | admin | extra+place   | geometry |
118           | R20 | boundary | administrative | 6     | neighbourhood | (0 0, 0 2, 2 2, 2 0, 0 0) |
119           | R21 | boundary | administrative | 7     |               | (0 0, 0 1, 1 1, 1 0, 0 0) |
120           | R22 | boundary | administrative | 8     |               | (0 0, 0 0.5, 0.5 0.5, 0.5 0, 0 0) |
121         When importing
122         Then placex contains
123           | object | rank_search | rank_address |
124           | R20    | 12          | 22 |
125           | R21    | 14          | 24 |
126           | R22    | 16          | 25 |
127
128     Scenario: admin levels contained in a place area must not overtake address ranks
129         Given the named places
130             | osm | class    | type           | admin | geometry |
131             | R10 | place    | city           | 15    | (0 0, 0 2, 2 0, 0 0) |
132             | R20 | boundary | administrative | 6     | (0 0, 0 1, 1 0, 0 0) |
133         When importing
134         Then placex contains
135             | object | rank_search | rank_address |
136             | R10    | 16          | 16           |
137             | R20    | 12          | 18           |
138
139     Scenario: admin levels overlapping a place area are not demoted
140         Given the named places
141             | osm | class    | type           | admin | geometry |
142             | R10 | place    | city           | 15    | (0 0, 0 2, 2 0, 0 0) |
143             | R20 | boundary | administrative | 6     | (-1 0, 0 1, 1 0, -1 0) |
144         When importing
145         Then placex contains
146             | object | rank_search | rank_address |
147             | R10    | 16          | 16           |
148             | R20    | 12          | 12           |
149
150     Scenario: admin levels with equal area as a place area are not demoted
151         Given the named places
152             | osm | class    | type           | admin | geometry |
153             | R10 | place    | city           | 15    | (0 0, 0 2, 2 0, 0 0) |
154             | R20 | boundary | administrative | 6     | (0 0, 0 2, 2 0, 0 0) |
155         When importing
156         Then placex contains
157             | object | rank_search | rank_address |
158             | R10    | 16          | 16           |
159             | R20    | 12          | 12           |
160
161
162     Scenario: adjacent admin_levels are considered the same object when they have the same wikidata
163         Given the named places
164           | osm | class    | type           | admin | extra+wikidata | geometry |
165           | N20 | place    | square         | 15    | Q123           | 0.1 0.1  |
166           | R23 | boundary | administrative | 10    | Q444           | (0 0, 0 1, 1 1, 1 0, 0 0) |
167           | R21 | boundary | administrative | 9     | Q444           | (0 0, 0 1, 1 1, 1 0, 0 0) |
168           | R22 | boundary | administrative | 8     | Q444           | (0 0, 0 1, 1 1, 1 0, 0 0) |
169         When importing
170         Then placex contains
171           | object | rank_search | rank_address |
172           | R23    | 20          | 0  |
173           | R21    | 18          | 0  |
174           | R22    | 16          | 16 |
175         Then place_addressline contains exactly
176             | object | address | cached_rank_address |
177             | N20    | R22     | 16                  |
178
179     Scenario: adjacent admin_levels are considered different objects when they have different wikidata
180         Given the named places
181           | osm | class    | type           | admin | extra+wikidata | geometry |
182           | N20 | place    | square         | 15    | Q123           | 0.1 0.1  |
183           | R21 | boundary | administrative | 9     | Q4441          | (0 0, 0 1, 1 1, 1 0, 0 0) |
184           | R22 | boundary | administrative | 8     | Q444           | (0 0, 0 1, 1 1, 1 0, 0 0) |
185         When importing
186         Then placex contains
187           | object | rank_search | rank_address |
188           | R21    | 18          | 18 |
189           | R22    | 16          | 16 |
190         Then place_addressline contains
191             | object | address | cached_rank_address |
192             | N20    | R22     | 16                  |
193             | N20    | R21     | 18                  |
194
195     Scenario: Mixes of admin boundaries and place areas I
196         Given the grid
197           | 1 |   | 10 |  |  | 2 |
198           |   | 9 |    |  |  |   |
199           | 20|   | 21 |  |  |   |
200           | 4 |   | 11 |  |  | 3 |
201         And the places
202           | osm | class    | type           | admin | name           | geometry      |
203           | R1  | boundary | administrative | 5     | Greater London | (1,2,3,4,1)   |
204           | R2  | boundary | administrative | 8     | Kensington     | (1,10,11,4,1) |
205         And the places
206           | osm | class    | type           | name           | geometry    |
207           | R10 | place    | city           | London         | (1,2,3,4,1) |
208           | N9  | place    | town           | Fulham         | 9           |
209           | W1  | highway  | residential    | Lots Grove     | 20,21       |
210         When importing
211         Then placex contains
212          | object | rank_search | rank_address |
213          | R1     | 10          | 10           |
214          | R10    | 16          | 16           |
215          | R2     | 16          | 18           |
216          | N9     | 18          | 18           |
217         And place_addressline contains
218          | object | address | isaddress | cached_rank_address |
219          | W1     | R1      | True      | 10                  |
220          | W1     | R10     | True      | 16                  |
221          | W1     | R2      | True      | 18                  |
222          | W1     | N9      | False     | 18                  |
223
224
225     Scenario: Mixes of admin boundaries and place areas II
226         Given the grid
227           | 1 |   | 10 |  | 5 | 2 |
228           |   | 9 |    |  |   |   |
229           | 20|   | 21 |  |   |   |
230           | 4 |   | 11 |  | 6 | 3 |
231         And the places
232           | osm | class    | type           | admin | name           | geometry    |
233           | R1  | boundary | administrative | 5     | Greater London | (1,2,3,4,1) |
234           | R2  | boundary | administrative | 8     | London         | (1,5,6,4,1) |
235         And the places
236           | osm | class    | type           | name           | geometry      |
237           | R10 | place    | city           | Westminster    | (1,10,11,4,1) |
238           | N9  | place    | town           | Fulham         | 9             |
239           | W1  | highway  | residential    | Lots Grove     | 20,21         |
240         When importing
241         Then placex contains
242          | object | rank_search | rank_address |
243          | R1     | 10          | 10           |
244          | R2     | 16          | 16           |
245          | R10    | 16          | 18           |
246          | N9     | 18          | 18           |
247         And place_addressline contains
248          | object | address | isaddress | cached_rank_address |
249          | W1     | R1      | True      | 10                  |
250          | W1     | R10     | True      | 18                  |
251          | W1     | R2      | True      | 16                  |
252          | W1     | N9      | False     | 18                  |
253
254
255     Scenario: POI nodes with place tags
256         Given the places
257           | osm | class   | type       | name | extratags       |
258           | N23 | amenity | playground | AB   | "place": "city" |
259           | N23 | place   | city       | AB   | "amenity": "playground" |
260         When importing
261         Then placex contains exactly
262           | object      | rank_search | rank_address |
263           | N23:amenity | 30          | 30           |
264           | N23:place   | 16          | 16           |
265
266     Scenario: Address rank 25 is only used for addr:place
267         Given the grid
268            | 10 | 33 | 34 | 11 |
269         Given the places
270           | osm | class | type    | name |
271           | N10 | place | village | vil  |
272           | N11 | place | farm    | farm |
273         And the places
274           | osm | class   | type        | name | geometry |
275           | W1  | highway | residential | RD   | 33,11    |
276         And the places
277           | osm | class   | type        | name | addr+farm | geometry |
278           | W2  | highway | residential | RD2  | farm       | 34,11    |
279         And the places
280           | osm | class | type  | housenr |
281           | N33 | place | house | 23      |
282         And the places
283           | osm | class | type  | housenr | addr+place |
284           | N34 | place | house | 23      | farm       |
285         When importing
286         Then placex contains
287           | object | parent_place_id |
288           | N11    | N10             |
289           | N33    | W1              |
290           | N34    | N11             |
291         And place_addressline contains
292           | object | address |
293           | W1     | N10     |
294           | W2     | N10     |
295           | W2     | N11     |