]> git.openstreetmap.org Git - nominatim.git/blob - test/bdd/db/import/rank_computation.feature
bdd tests: fix place dependen ranking tests
[nominatim.git] / test / bdd / db / import / rank_computation.feature
1 @DB
2 Feature: Rank assignment
3     Tests for assignment of search and address ranks.
4
5     Scenario: Ranks for place nodes are assigned according to their type
6         Given the named places
7           | osm  | class     | type      | geometry |
8           | N1   | foo       | bar       | 0 0 |
9           | N11  | place     | Continent | 0 0 |
10           | N12  | place     | continent | 0 0 |
11           | N13  | place     | sea       | 0 0 |
12           | N14  | place     | country   | 0 0 |
13           | N15  | place     | state     | 0 0 |
14           | N16  | place     | region    | 0 0 |
15           | N17  | place     | county    | 0 0 |
16           | N18  | place     | city      | 0 0 |
17           | N19  | place     | island    | 0 0 |
18           | N36  | place     | house     | 0 0 |
19           | N38  | place     | houses    | 0 0 |
20         And the named places
21           | osm  | class     | type      | extra+capital | geometry |
22           | N101 | place     | city      | yes           | 0 0 |
23         When importing
24         Then placex contains
25           | object | rank_search | rank_address |
26           | N1     | 30          | 30 |
27           | N11    | 22          | 0 |
28           | N12    | 2           | 0 |
29           | N13    | 2           | 0 |
30           | N14    | 4           | 0 |
31           | N15    | 8           | 0 |
32           | N16    | 18          | 0 |
33           | N17    | 12          | 12 |
34           | N18    | 16          | 16 |
35           | N19    | 17          | 0 |
36           | N101   | 15          | 16 |
37           | N36    | 30          | 30 |
38           | N38    | 28          | 0 |
39
40     Scenario: Ranks for boundaries are assigned according to admin level
41         Given the named places
42           | osm | class    | type           | admin | geometry |
43           | R20 | boundary | administrative | 2     | (1 1, 2 2, 1 2, 1 1) |
44           | R21 | boundary | administrative | 32    | (3 3, 4 4, 3 4, 3 3) |
45           | R22 | boundary | administrative | 6     | (0 0, 1 0, 0 1, 0 0) |
46           | R23 | boundary | administrative | 10    | (0 0, 1 1, 1 0, 0 0) |
47         When importing
48         Then placex contains
49           | object | rank_search | rank_address |
50           | R20    | 4           | 4 |
51           | R21    | 25          | 0 |
52           | R22    | 12          | 12 |
53           | R23    | 20          | 20 |
54
55     Scenario: Ranks for addressable boundaries with place assignment go with place address ranks if available
56         Given the named places
57           | osm | class    | type           | admin | extra+place | geometry |
58           | R20 | boundary | administrative | 3     | state       | (1 1, 2 2, 1 2, 1 1) |
59           | R21 | boundary | administrative | 32    | suburb      | (3 3, 4 4, 3 4, 3 3) |
60           | R22 | boundary | administrative | 6     | town        | (0 0, 1 0, 0 1, 0 0) |
61           | R23 | boundary | administrative | 10    | village     | (0 0, 1 1, 1 0, 0 0) |
62         When importing
63         Then placex contains
64           | object | rank_search | rank_address |
65           | R20    | 6           | 6  |
66           | R21    | 25          | 0  |
67           | R22    | 12          | 16 |
68           | R23    | 20          | 16 |
69
70     Scenario: Place address ranks cannot overtake a parent address rank
71         Given the named places
72           | osm | class    | type           | admin | extra+place  | geometry |
73           | R20 | boundary | administrative | 8     | town         | (0 0, 0 2, 2 2, 2 0, 0 0) |
74           | R21 | boundary | administrative | 9     | municipality | (0 0, 0 1, 1 1, 1 0, 0 0) |
75           | R22 | boundary | administrative | 9     | suburb       | (0 0, 0 1, 1 1, 1 0, 0 0) |
76         When importing
77         Then placex contains
78           | object | rank_search | rank_address |
79           | R20    | 16          | 16 |
80           | R21    | 18          | 18 |
81           | R22    | 18          | 20 |
82         Then place_addressline contains
83             | object | address | cached_rank_address |
84             | R21    | R20     | 16                  |
85             | R22    | R20     | 16                  |
86
87     Scenario: Admin levels cannot overtake each other due to place address ranks
88         Given the named places
89           | osm | class    | type           | admin | extra+place  | geometry |
90           | R20 | boundary | administrative | 6     | town         | (0 0, 0 2, 2 2, 2 0, 0 0) |
91           | R21 | boundary | administrative | 8     |              | (0 0, 0 1, 1 1, 1 0, 0 0) |
92           | R22 | boundary | administrative | 8     | suburb       | (0 0, 0 1, 1 1, 1 0, 0 0) |
93         When importing
94         Then placex contains
95           | object | rank_search | rank_address |
96           | R20    | 12          | 16 |
97           | R21    | 16          | 18 |
98           | R22    | 16          | 20 |
99         Then place_addressline contains
100             | object | address | cached_rank_address |
101             | R21    | R20     | 16                  |
102             | R22    | R20     | 16                  |
103
104     Scenario: Admin levels cannot overtake each other due to place address ranks even when slightly misaligned
105         Given the named places
106           | osm | class    | type           | admin | extra+place  | geometry |
107           | R20 | boundary | administrative | 6     | town         | (0 0, 0 2, 2 2, 2 0, 0 0) |
108           | R21 | boundary | administrative | 8     |              | (0 0, -0.0001 1, 1 1, 1 0, 0 0) |
109         When importing
110         Then placex contains
111           | object | rank_search | rank_address |
112           | R20    | 12          | 16 |
113           | R21    | 16          | 18 |
114         Then place_addressline contains
115             | object | address | cached_rank_address |
116             | R21    | R20     | 16                  |
117
118     Scenario: Admin levels must not be larger than 25
119         Given the named places
120           | osm | class    | type           | admin | extra+place   | geometry |
121           | R20 | boundary | administrative | 6     | neighbourhood | (0 0, 0 2, 2 2, 2 0, 0 0) |
122           | R21 | boundary | administrative | 7     |               | (0 0, 0 1, 1 1, 1 0, 0 0) |
123           | R22 | boundary | administrative | 8     |               | (0 0, 0 0.5, 0.5 0.5, 0.5 0, 0 0) |
124         When importing
125         Then placex contains
126           | object | rank_search | rank_address |
127           | R20    | 12          | 22 |
128           | R21    | 14          | 24 |
129           | R22    | 16          | 25 |
130
131     Scenario: admin levels contained in a place area must not overtake address ranks
132         Given the named places
133             | osm | class    | type           | admin | geometry |
134             | R10 | place    | city           | 15    | (0 0, 0 2, 2 0, 0 0) |
135             | R20 | boundary | administrative | 6     | (0 0, 0 1, 1 0, 0 0) |
136         When importing
137         Then placex contains
138             | object | rank_search | rank_address |
139             | R10    | 16          | 16           |
140             | R20    | 12          | 18           |
141
142     Scenario: admin levels overlapping a place area are not demoted
143         Given the named places
144             | osm | class    | type           | admin | geometry |
145             | R10 | place    | city           | 15    | (0 0, 0 2, 2 0, 0 0) |
146             | R20 | boundary | administrative | 6     | (-1 0, 0 1, 1 0, -1 0) |
147         When importing
148         Then placex contains
149             | object | rank_search | rank_address |
150             | R10    | 16          | 16           |
151             | R20    | 12          | 12           |
152
153     Scenario: admin levels with equal area as a place area are not demoted
154         Given the named places
155             | osm | class    | type           | admin | geometry |
156             | R10 | place    | city           | 15    | (0 0, 0 2, 2 0, 0 0) |
157             | R20 | boundary | administrative | 6     | (0 0, 0 2, 2 0, 0 0) |
158         When importing
159         Then placex contains
160             | object | rank_search | rank_address |
161             | R10    | 16          | 16           |
162             | R20    | 12          | 12           |
163
164
165     Scenario: adjacent admin_levels are considered the same object when they have the same wikidata
166         Given the named places
167           | osm | class    | type           | admin | extra+wikidata | geometry |
168           | N20 | place    | square         | 15    | Q123           | 0.1 0.1  |
169           | R23 | boundary | administrative | 10    | Q444           | (0 0, 0 1, 1 1, 1 0, 0 0) |
170           | R21 | boundary | administrative | 9     | Q444           | (0 0, 0 1, 1 1, 1 0, 0 0) |
171           | R22 | boundary | administrative | 8     | Q444           | (0 0, 0 1, 1 1, 1 0, 0 0) |
172         When importing
173         Then placex contains
174           | object | rank_search | rank_address |
175           | R23    | 20          | 0  |
176           | R21    | 18          | 0  |
177           | R22    | 16          | 16 |
178         Then place_addressline contains
179             | object | address | cached_rank_address |
180             | N20    | R22     | 16                  |
181         Then place_addressline doesn't contain
182             | object | address |
183             | N20    | R21     |
184             | N20    | R23     |
185
186     Scenario: adjacent admin_levels are considered different objects when they have different wikidata
187         Given the named places
188           | osm | class    | type           | admin | extra+wikidata | geometry |
189           | N20 | place    | square         | 15    | Q123           | 0.1 0.1  |
190           | R21 | boundary | administrative | 9     | Q4441          | (0 0, 0 1, 1 1, 1 0, 0 0) |
191           | R22 | boundary | administrative | 8     | Q444           | (0 0, 0 1, 1 1, 1 0, 0 0) |
192         When importing
193         Then placex contains
194           | object | rank_search | rank_address |
195           | R21    | 18          | 18 |
196           | R22    | 16          | 16 |
197         Then place_addressline contains
198             | object | address | cached_rank_address |
199             | N20    | R22     | 16                  |
200             | N20    | R21     | 18                  |
201