]> git.openstreetmap.org Git - nominatim.git/blob - tests/features/db/import/placex.feature
add functional tests
[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 Outline: minor highways droped without name, included with
246         Given the scene roads-with-pois
247         And a wiped database
248         And the place ways
249           | osm_id | class    | type   | geometry
250           | 1      | highway  | <type> | :w-south
251         And the named place ways
252           | osm_id | class    | type   | geometry
253           | 2      | highway  | <type> | :w-north
254         When importing
255         Then table placex has no entry for W1
256         And table placex contains
257           | object | rank_search | rank_address
258           | W2     | <rank>      | <rank>
259           
260     Examples:
261           | type          | rank
262           | service       | 27
263           | cycleway      | 27
264           | path          | 27
265           | footway       | 27
266           | steps         | 27
267           | bridleway     | 27
268           | track         | 26
269           | byway         | 26
270           | motorway_link | 27
271           | primary_link  | 27
272           | trunk_link    | 27
273           | secondary_link| 27
274           | tertiary_link | 27
275
276     Scenario: search and address ranks for highways correctly assigned
277         Given the scene roads-with-pois
278         And the place nodes
279           | osm_id | class    | type 
280           | 1      | highway  | bus_stop
281         And the place ways
282           | osm_id | class    | type         | geometry
283           | 1      | highway  | primary      | :w-south
284           | 2      | highway  | secondary    | :w-south
285           | 3      | highway  | tertiary     | :w-south
286           | 4      | highway  | residential  | :w-north
287           | 5      | highway  | unclassified | :w-north
288           | 6      | highway  | something    | :w-north
289         When importing
290         Then table placex contains
291           | object | rank_search | rank_address
292           | N1     | 30          | 30
293           | W1     | 26          | 26
294           | W2     | 26          | 26
295           | W3     | 26          | 26
296           | W4     | 26          | 26
297           | W5     | 26          | 26
298           | W6     | 26          | 26
299
300     Scenario: rank and inclusion of landuses
301         Given the place nodes
302           | osm_id | class   | type       
303           | 1      | landuse | residential
304         And the named place nodes
305           | osm_id | class   | type       
306           | 2      | landuse | residential
307         And the place ways
308           | osm_id | class   | type        | geometry
309           | 1      | landuse | residential | 0 0, 0 1
310         And the named place ways
311           | osm_id | class   | type        | geometry
312           | 2      | landuse | residential | 1 1, 1 1.1
313         And the place areas
314           | osm_type | osm_id | class   | type        | geometry
315           | W        | 3      | landuse | residential | poly-area:0.1
316           | R        | 1      | landuse | residential | poly-area:0.01
317           | R        | 10     | landuse | residential | poly-area:0.5
318         And the named place areas
319           | osm_type | osm_id | class   | type        | geometry
320           | W        | 4      | landuse | residential | poly-area:0.1
321           | R        | 2      | landuse | residential | poly-area:0.05
322         When importing
323         Then table placex has no entry for N1
324         And table placex has no entry for W1
325         And table placex has no entry for W3
326         And table placex has no entry for R1
327         And table placex has no entry for R10
328         And table placex contains
329           | object | rank_search | rank_address
330           | N2     | 30          | 30
331           | W2     | 30          | 30
332           | W4     | 22          | 22
333           | R2     | 22          | 22
334
335     Scenario: rank and inclusion of naturals
336        Given the place nodes
337           | osm_id | class   | type
338           | 1      | natural | peak
339           | 3      | natural | volcano
340        And the named place nodes
341           | osm_id | class   | type
342           | 2      | natural | peak
343           | 4      | natural | volcano
344           | 5      | natural | foobar
345        And the place ways
346           | osm_id | class   | type           | geometry
347           | 1      | natural | mountain_range | 10 10,11 11
348        And the named place ways
349           | osm_id | class   | type           | geometry
350           | 2      | natural | mountain_range | 12 12,11 11
351           | 3      | natural | foobar         | 13 13,13.1 13
352           | 4      | natural | coastline      | 14 14,14.1 14
353        And the place areas
354           | osm_type | osm_id | class   | type           | geometry
355           | R        | 1      | natural | volcano        | poly-area:0.1
356           | R        | 2      | natural | volcano        | poly-area:1.0
357        And the named place areas
358           | osm_type | osm_id | class   | type           | geometry
359           | R        | 3      | natural | volcano        | poly-area:0.1
360           | R        | 4      | natural | foobar         | poly-area:0.5
361           | R        | 5      | natural | sea            | poly-area:5.0
362           | R        | 6      | natural | sea            | poly-area:0.01
363           | R        | 7      | natural | coastline      | poly-area:1.0
364        When importing
365        Then table placex has no entry for N1
366        And table placex has no entry for N3
367        And table placex has no entry for W1
368        And table placex has no entry for R1
369        And table placex has no entry for R2
370        And table placex has no entry for R7
371        And table placex has no entry for W4
372        And table placex contains
373           | object | rank_search | rank_address
374           | N2     | 18          | 0
375           | N4     | 18          | 0
376           | N5     | 30          | 30
377           | W2     | 18          | 0
378           | R3     | 18          | 0
379           | R4     | 22          | 22
380           | R5     | 4           | 4
381           | R6     | 4           | 4
382           | W3     | 30          | 30
383