]> git.openstreetmap.org Git - nominatim.git/blob - test/bdd/features/db/import/postcodes.feature
release 5.1.0.post6
[nominatim.git] / test / bdd / features / db / import / postcodes.feature
1 Feature: Import of postcodes
2     Tests for postcode estimation
3
4     Scenario: Postcodes on the object are preferred over those on the address
5         Given the grid with origin FR
6             | 1 |    |    |    | 4 |  | 6 | | 8 |
7             |   | 10 |    | 11 |   |  |   | |   |
8             |   |    | 22 |    |   |  |   | |   |
9             | 2 |    |    |    | 3 |  | 5 | | 7 |
10         And the named places
11             | osm | class    | type           | admin | addr+postcode | geometry    |
12             | R1  | boundary | administrative | 6     | 10000         | (1,8,7,2,1) |
13             | R34 | boundary | administrative | 8     | 11000         | (1,6,5,2,1) |
14             | R4  | boundary | administrative | 10    | 11200         | (1,4,3,2,1) |
15         And the named places
16             | osm | class    | type        | addr+postcode | geometry |
17             | W93 | highway  | residential | 11250         | 10,11    |
18             | N22 | building | yes         | 11254         | 22       |
19         When importing
20         Then placex contains
21             | object | postcode |
22             | N22    | 11254    |
23             | W93    | 11250    |
24             | R4     | 11200    |
25             | R34    | 11000    |
26             | R1     | 10000    |
27
28     Scenario: Postcodes from a road are inherited by an attached building
29         Given the grid with origin DE
30             | 10 |   |   |   | 11 |
31             |    | 1 | 2 |   |    |
32             |    | 4 | 3 |   |    |
33         And the named places
34             | osm | class    | type        | addr+postcode | geometry |
35             | W93 | highway  | residential | 86034         | 10,11    |
36         And the named places
37             | osm | class    | type  | geometry    |
38             | W22 | building | yes   | (1,2,3,4,1) |
39         When importing
40         Then placex contains
41             | object | postcode | parent_place_id |
42             | W22    | 86034    | W93 |
43
44     Scenario: Postcodes from the lowest admin area are inherited by ways
45         Given the grid with origin FR
46             | 1 |    |    |    | 4 |  | 6 | | 8 |
47             |   | 10 |    | 11 |   |  |   | |   |
48             | 2 |    |    |    | 3 |  | 5 | | 7 |
49         And the named places
50             | osm | class    | type           | admin | addr+postcode | geometry |
51             | R1  | boundary | administrative | 6     | 10000         | (1,8,7,2,1) |
52             | R34 | boundary | administrative | 8     | 11000         | (1,6,5,2,1) |
53             | R4  | boundary | administrative | 10    | 11200         | (1,4,3,2,1) |
54         And the named places
55             | osm | class    | type           | geometry |
56             | W93 | highway  | residential    | 10,11    |
57         When importing
58         Then placex contains
59             | object | postcode |
60             | W93    | 11200    |
61
62     Scenario: Postcodes from the lowest admin area with postcode are inherited by ways
63         Given the grid with origin FR
64             | 1 |    |    |    | 4 |  | 6 | | 8 |
65             |   | 10 |    | 11 |   |  |   | |   |
66             | 2 |    |    |    | 3 |  | 5 | | 7 |
67         And the named places
68             | osm | class    | type           | admin | addr+postcode | geometry |
69             | R1  | boundary | administrative | 6     | 10000         | (1,8,7,2,1) |
70             | R34 | boundary | administrative | 8     | 11000         | (1,6,5,2,1) |
71         And the named places
72             | osm | class    | type           | admin | geometry    |
73             | R4  | boundary | administrative | 10    | (1,4,3,2,1) |
74         And the named places
75             | osm | class    | type           | geometry |
76             | W93 | highway  | residential    | 10,11    |
77         When importing
78         Then placex contains
79             | object | postcode | parent_place_id |
80             | W93    | 11000    | R4 |
81
82     Scenario: Postcodes from the lowest admin area are inherited by buildings
83         Given the grid with origin FR
84             | 1 |    |    |    | 4 |  | 6 | | 8 |
85             |   | 10 |    | 11 |   |  |   | |   |
86             |   | 13 |    | 12 |   |  |   | |   |
87             | 2 |    |    |    | 3 |  | 5 | | 7 |
88         And the named places
89             | osm | class    | type           | admin | addr+postcode | geometry |
90             | R1  | boundary | administrative | 6     | 10000         | (1,8,7,2,1) |
91             | R34 | boundary | administrative | 8     | 11000         | (1,6,5,2,1) |
92             | R4  | boundary | administrative | 10    | 11200         | (1,4,3,2,1) |
93         And the named places
94             | osm | class    | type  | geometry |
95             | W22 | building | yes   | (10,11,12,13,10) |
96         When importing
97         Then placex contains
98             | object | postcode |
99             | W22    | 11200    |
100
101     Scenario: Roads get postcodes from nearby named buildings without other info
102         Given the grid with origin US
103             | 10 |   |   |   | 11 |
104             |    | 1 | 2 |   |    |
105             |    | 4 | 3 |   |    |
106         And the named places
107             | osm | class    | type           | geometry |
108             | W93 | highway  | residential    | 10,11    |
109         And the named places
110             | osm | class    | type        | addr+postcode | geometry    |
111             | W22 | building | yes         | 45023         | (1,2,3,4,1) |
112         When importing
113         Then placex contains
114             | object | postcode |
115             | W93    | 45023    |
116
117     Scenario: Road areas get postcodes from nearby named buildings without other info
118         Given the grid with origin US
119             | 10 |   |   |   | 11 |
120             | 13 |   |   |   | 12 |
121             |    | 1 | 2 |   |    |
122             |    | 4 | 3 |   |    |
123         And the named places
124             | osm | class    | type           | geometry         |
125             | W93 | highway  | pedestriant    | (10,11,12,13,10) |
126         And the named places
127             | osm | class    | type        | addr+postcode | geometry    |
128             | W22 | building | yes         | 45023         | (1,2,3,4,1) |
129         When importing
130         Then placex contains
131             | object | postcode |
132             | W93    | 45023    |
133
134     Scenario: Roads get postcodes from nearby unnamed buildings without other info
135         Given the grid with origin US
136             | 10 |   |   |   | 11 |
137             |    | 1 | 2 |   |    |
138             |    | 4 | 3 |   |    |
139         And the named places
140             | osm | class    | type           | geometry |
141             | W93 | highway  | residential    | 10,11    |
142         And the places
143             | osm | class    | type        | addr+postcode | geometry    |
144             | W22 | place    | postcode    | 45023         | (1,2,3,4,1) |
145         When importing
146         Then placex contains
147             | object | postcode |
148             | W93    | 45023    |
149
150     Scenario: Postcodes from admin boundaries are preferred over estimated postcodes
151         Given the grid with origin FR
152             | 1 |    |    |    | 4 |  | 6 | | 8 |
153             |   | 10 |    | 11 |   |  |   | |   |
154             |   |    | 22 |    |   |  |   | |   |
155             | 2 |    |    |    | 3 |  | 5 | | 7 |
156         And the named places
157             | osm | class    | type           | admin | addr+postcode | geometry |
158             | R1  | boundary | administrative | 6     | 10000         | (1,8,7,2,1) |
159             | R34 | boundary | administrative | 8     | 11000         | (1,6,5,2,1) |
160             | R4  | boundary | administrative | 10    | 11200         | (1,4,3,2,1) |
161         And the named places
162             | osm | class    | type           | geometry |
163             | W93 | highway  | residential    | 10,1     |
164         And the named places
165             | osm | class    | type        | addr+postcode |
166             | N22 | building | yes         | 45023         |
167         When importing
168         Then placex contains
169             | object | postcode |
170             | W93    | 11200    |
171
172     Scenario: Postcodes are added to the postcode
173         Given the places
174            | osm | class | type  | addr+postcode | addr+housenumber | geometry |
175            | N34 | place | house | 01982         | 111              |country:de |
176         When importing
177         Then location_postcode contains exactly
178            | country_code | postcode | geometry!wkt |
179            | de           | 01982    | country:de |
180
181     @skip
182     Scenario: search and address ranks for GB post codes correctly assigned
183         Given the places
184          | osm  | class | type     | postcode | geometry |
185          | N1   | place | postcode | E45 2CD  | country:gb |
186          | N2   | place | postcode | E45 2    | country:gb |
187          | N3   | place | postcode | Y45      | country:gb |
188         When importing
189         Then location_postcode contains exactly
190          | postcode | country_code | rank_search | rank_address |
191          | E45 2CD  | gb           | 25          | 5 |
192          | E45 2    | gb           | 23          | 5 |
193          | Y45      | gb           | 21          | 5 |
194
195     Scenario: Postcodes outside all countries are not added to the postcode table
196         Given the places
197             | osm | class | type  | addr+postcode | addr+housenumber | addr+place  | geometry  |
198             | N34 | place | house | 01982         | 111              | Null Island | 0 0.00001 |
199         And the places
200             | osm | class | type   | name        | geometry |
201             | N1  | place | hamlet | Null Island | 0 0      |
202         When importing
203         Then location_postcode contains exactly
204             | place_id |
205         When geocoding "111, 01982 Null Island"
206         Then the result set contains
207             | object | display_name |
208             | N34    | 111, Null Island, 01982 |