]> git.openstreetmap.org Git - nominatim.git/blob - tests/features/db/import/placex.feature
sMoreURL now includes countrycodes values
[nominatim.git] / tests / features / db / import / placex.feature
1 @DB
2 Feature: Import into placex
3     Tests that data in placex is completed correctly.
4
5     Scenario: No country code tag is available
6         Given the place nodes
7           | osm_id | class   | type     | name           | geometry
8           | 1      | highway | primary  | 'name' : 'A1'  | country:us
9         When importing
10         Then table placex contains
11           | object | country_code | calculated_country_code |
12           | N1     | None         | us                      |
13
14     Scenario: Location overwrites country code tag
15         Given the scene country
16         And the place nodes
17           | osm_id | class   | type     | name           | country_code | geometry
18           | 1      | highway | primary  | 'name' : 'A1'  | de           | :us
19         When importing
20         Then table placex contains
21           | object | country_code | calculated_country_code |
22           | N1     | de           | us                      |
23
24     Scenario: Country code tag overwrites location for countries
25         Given the place areas
26           | osm_type | osm_id | class    | type            | admin_level | name            | country_code | geometry
27           | R        | 1      | boundary | administrative  | 2           | 'name' : 'foo'  | de           | (-100 40, -101 40, -101 41, -100 41, -100 40)
28         When importing
29         Then table placex contains
30           | object | country_code | calculated_country_code |
31           | R1     | de           | de                      |
32
33     Scenario: Illegal country code tag for countries is ignored
34         And the place areas
35           | osm_type | osm_id | class    | type            | admin_level | name            | country_code | geometry
36           | R        | 1      | boundary | administrative  | 2           | 'name' : 'foo'  | xx          | (-100 40, -101 40, -101 41, -100 41, -100 40)
37         When importing
38         Then table placex contains
39           | object | country_code | calculated_country_code |
40           | R1     | xx           | us                      |
41
42     Scenario: admin level is copied over
43         Given the place nodes
44           | osm_id | class | type      | admin_level | name
45           | 1      | place | state     | 3           | 'name' : 'foo'
46         When importing
47         Then table placex contains
48           | object | admin_level |
49           | N1     | 3           |
50
51     Scenario: admin level is default 15
52         Given the place nodes
53           | osm_id | class   | type      | name
54           | 1      | amenity | prison    | 'name' : 'foo'
55         When importing
56         Then table placex contains
57           | object | admin_level |
58           | N1     | 15          |
59
60     Scenario: admin level is never larger than 15
61         Given the place nodes
62           | osm_id | class   | type      | name           | admin_level
63           | 1      | amenity | prison    | 'name' : 'foo' | 16
64         When importing
65         Then table placex contains
66           | object | admin_level |
67           | N1     | 15          |
68
69
70     Scenario: postcode node without postcode is dropped
71         Given the place nodes
72           | osm_id | class   | type
73           | 1      | place   | postcode
74         When importing
75         Then table placex has no entry for N1
76
77     Scenario: postcode boundary without postcode is dropped
78         Given the place areas
79           | osm_type | osm_id | class    | type        | geometry
80           | R        | 1      | boundary | postal_code | poly-area:0.1
81         When importing
82         Then table placex has no entry for R1
83
84     Scenario: search and address ranks for GB post codes correctly assigned
85         Given the place nodes
86          | osm_id  | class | type     | postcode | geometry
87          | 1       | place | postcode | E45 2CD  | country:gb
88          | 2       | place | postcode | E45 2    | country:gb
89          | 3       | place | postcode | Y45      | country:gb
90         When importing
91         Then table placex contains
92          | object | postcode | calculated_country_code | rank_search | rank_address
93          | N1     | E45 2CD  | gb                      | 25          | 5
94          | N2     | E45 2    | gb                      | 23          | 5
95          | N3     | Y45      | gb                      | 21          | 5
96
97     Scenario: wrongly formatted GB postcodes are down-ranked
98         Given the place nodes
99          | osm_id  | class | type     | postcode | geometry
100          | 1       | place | postcode | EA452CD  | country:gb
101          | 2       | place | postcode | E45 23   | country:gb
102          | 3       | place | postcode | y45      | country:gb
103         When importing
104         Then table placex contains
105          | object | calculated_country_code | rank_search | rank_address
106          | N1     | gb                      | 30          | 30
107          | N2     | gb                      | 30          | 30
108          | N3     | gb                      | 30          | 30
109
110     Scenario: search and address rank for DE postcodes correctly assigned
111         Given the place nodes
112          | osm_id  | class | type     | postcode | geometry
113          | 1       | place | postcode | 56427    | country:de
114          | 2       | place | postcode | 5642     | country:de
115          | 3       | place | postcode | 5642A    | country:de
116          | 4       | place | postcode | 564276   | country:de
117         When importing
118         Then table placex contains
119          | object | calculated_country_code | rank_search | rank_address
120          | N1     | de                      | 21          | 11
121          | N2     | de                      | 30          | 30
122          | N3     | de                      | 30          | 30
123          | N4     | de                      | 30          | 30
124
125     Scenario: search and address rank for other postcodes are correctly assigned
126         Given the place nodes
127          | osm_id  | class | type     | postcode | geometry
128          | 1       | place | postcode | 1        | country:ca
129          | 2       | place | postcode | X3       | country:ca
130          | 3       | place | postcode | 543      | country:ca
131          | 4       | place | postcode | 54dc     | country:ca
132          | 5       | place | postcode | 12345    | country:ca
133          | 6       | place | postcode | 55TT667  | country:ca
134          | 7       | place | postcode | 123-65   | country:ca
135          | 8       | place | postcode | 12 445 4 | country:ca
136          | 9       | place | postcode | A1:bc10  | country:ca
137         When importing
138         Then table placex contains
139          | object | calculated_country_code | rank_search | rank_address
140          | N1     | ca                      | 21          | 11
141          | N2     | ca                      | 21          | 11
142          | N3     | ca                      | 21          | 11
143          | N4     | ca                      | 21          | 11
144          | N5     | ca                      | 21          | 11
145          | N6     | ca                      | 21          | 11
146          | N7     | ca                      | 25          | 11
147          | N8     | ca                      | 25          | 11
148          | N9     | ca                      | 25          | 11
149
150
151     Scenario: search and address ranks for places are correctly assigned
152         Given the named place nodes
153           | osm_id | class     | type      | 
154           | 1      | foo       | bar       |
155           | 11     | place     | Continent |
156           | 12     | place     | continent |
157           | 13     | place     | sea       |
158           | 14     | place     | country   |
159           | 15     | place     | state     |
160           | 16     | place     | region    |
161           | 17     | place     | county    |
162           | 18     | place     | city      |
163           | 19     | place     | island    |
164           | 20     | place     | town      |
165           | 21     | place     | village   |
166           | 22     | place     | hamlet    |
167           | 23     | place     | municipality |
168           | 24     | place     | district     |
169           | 25     | place     | unincorporated_area |
170           | 26     | place     | borough             |
171           | 27     | place     | suburb              |
172           | 28     | place     | croft               |
173           | 29     | place     | subdivision         |
174           | 30     | place     | isolated_dwelling   |
175           | 31     | place     | farm                |
176           | 32     | place     | locality            |
177           | 33     | place     | islet               |
178           | 34     | place     | mountain_pass       |
179           | 35     | place     | neighbourhood       |
180           | 36     | place     | house               |
181           | 37     | place     | building            |
182           | 38     | place     | houses              |
183         And the named place nodes
184           | osm_id | class     | type      | extratags
185           | 100    | place     | locality  | 'locality' : 'townland'
186           | 101    | place     | city      | 'capital' : 'yes'
187         When importing
188         Then table placex contains
189           | object | rank_search | rank_address |
190           | N1     | 30          | 30 |
191           | N11    | 30          | 30 |
192           | N12    | 2           | 2 |
193           | N13    | 2           | 0 |
194           | N14    | 4           | 4 |
195           | N15    | 8           | 8 |
196           | N16    | 18          | 0 |
197           | N17    | 12          | 12 |
198           | N18    | 16          | 16 |
199           | N19    | 17          | 0 |
200           | N20    | 18          | 16 |
201           | N21    | 19          | 16 |
202           | N22    | 19          | 16 |
203           | N23    | 19          | 16 |
204           | N24    | 19          | 16 |
205           | N25    | 19          | 16 |
206           | N26    | 19          | 16 |
207           | N27    | 20          | 20 |
208           | N28    | 20          | 20 |
209           | N29    | 20          | 20 |
210           | N30    | 20          | 20 |
211           | N31    | 20          | 0 |
212           | N32    | 20          | 0 |
213           | N33    | 20          | 0 |
214           | N34    | 20          | 0 |
215           | N100   | 20          | 20 |
216           | N101   | 15          | 16 |
217           | N35    | 22          | 22 |
218           | N36    | 30          | 30 |
219           | N37    | 30          | 30 |
220           | N38    | 28          | 0 |
221
222     Scenario: search and address ranks for boundaries are correctly assigned
223         Given the named place nodes
224           | osm_id | class    | type
225           | 1      | boundary | administrative
226         And the named place ways
227           | osm_id | class    | type           | geometry
228           | 10     | boundary | administrative | 10 10, 11 11
229         And the named place areas
230           | osm_type | osm_id | class    | type           | admin_level | geometry
231           | R        | 20     | boundary | administrative | 2           | (1 1, 2 2, 1 2, 1 1)
232           | R        | 21     | boundary | administrative | 32          | (3 3, 4 4, 3 4, 3 3)
233           | R        | 22     | boundary | nature_park    | 6           | (0 0, 1 0, 0 1, 0 0)
234           | R        | 23     | boundary | natural_reserve| 10          | (0 0, 1 1, 1 0, 0 0)
235         When importing
236         Then table placex has no entry for N1
237         And table placex has no entry for W10
238         And table placex contains
239           | object | rank_search | rank_address
240           | R20    | 4           | 4
241           | R21    | 30          | 30
242           | R22    | 12          | 0
243           | R23    | 20          | 0
244
245     Scenario: search and address ranks for highways correctly assigned
246         Given the scene roads-with-pois
247         And the place nodes
248           | osm_id | class    | type 
249           | 1      | highway  | bus_stop
250         And the place ways
251           | osm_id | class    | type         | geometry
252           | 1      | highway  | primary      | :w-south
253           | 2      | highway  | secondary    | :w-south
254           | 3      | highway  | tertiary     | :w-south
255           | 4      | highway  | residential  | :w-north
256           | 5      | highway  | unclassified | :w-north
257           | 6      | highway  | something    | :w-north
258         When importing
259         Then table placex contains
260           | object | rank_search | rank_address
261           | N1     | 30          | 30
262           | W1     | 26          | 26
263           | W2     | 26          | 26
264           | W3     | 26          | 26
265           | W4     | 26          | 26
266           | W5     | 26          | 26
267           | W6     | 26          | 26
268
269     Scenario: rank and inclusion of landuses
270         And the named place nodes
271           | osm_id | class   | type
272           | 2      | landuse | residential
273         And the named place ways
274           | osm_id | class   | type        | geometry
275           | 2      | landuse | residential | 1 1, 1 1.1
276         And the named place areas
277           | osm_type | osm_id | class   | type        | geometry
278           | W        | 4      | landuse | residential | poly-area:0.1
279           | R        | 2      | landuse | residential | poly-area:0.05
280           | R        | 3      | landuse | forrest     | poly-area:0.5
281         When importing
282         And table placex contains
283           | object | rank_search | rank_address
284           | N2     | 30          | 30
285           | W2     | 30          | 30
286           | W4     | 22          | 22
287           | R2     | 22          | 22
288           | R3     | 22          | 0
289
290     Scenario: rank and inclusion of naturals
291        And the named place nodes
292           | osm_id | class   | type
293           | 2      | natural | peak
294           | 4      | natural | volcano
295           | 5      | natural | foobar
296        And the named place ways
297           | osm_id | class   | type           | geometry
298           | 2      | natural | mountain_range | 12 12,11 11
299           | 3      | natural | foobar         | 13 13,13.1 13
300        And the named place areas
301           | osm_type | osm_id | class   | type           | geometry
302           | R        | 3      | natural | volcano        | poly-area:0.1
303           | R        | 4      | natural | foobar         | poly-area:0.5
304           | R        | 5      | natural | sea            | poly-area:5.0
305           | R        | 6      | natural | sea            | poly-area:0.01
306        When importing
307        And table placex contains
308           | object | rank_search | rank_address
309           | N2     | 18          | 0
310           | N4     | 18          | 0
311           | N5     | 30          | 30
312           | W2     | 18          | 0
313           | R3     | 18          | 0
314           | R4     | 22          | 0
315           | R5     | 4           | 4
316           | R6     | 4           | 4
317           | W3     | 30          | 30
318