]> git.openstreetmap.org Git - nominatim.git/blob - test/bdd/db/import/postcodes.feature
Merge pull request #2746 from bgo-eiu/patch-2
[nominatim.git] / test / bdd / db / import / postcodes.feature
1 @DB
2 Feature: Import of postcodes
3     Tests for postcode estimation
4
5     Scenario: Postcodes on the object are preferred over those on the address
6         Given the grid with origin FR
7             | 1 |    |    |    | 4 |  | 6 | | 8 |
8             |   | 10 |    | 11 |   |  |   | |   |
9             |   |    | 22 |    |   |  |   | |   |
10             | 2 |    |    |    | 3 |  | 5 | | 7 |
11         And the named places
12             | osm | class    | type           | admin | addr+postcode | geometry    |
13             | R1  | boundary | administrative | 6     | 10000         | (1,8,7,2,1) |
14             | R34 | boundary | administrative | 8     | 11000         | (1,6,5,2,1) |
15             | R4  | boundary | administrative | 10    | 11200         | (1,4,3,2,1) |
16         And the named places
17             | osm | class    | type        | addr+postcode | geometry |
18             | W93 | highway  | residential | 11250         | 10,11    |
19             | N22 | building | yes         | 11254         | 22       |
20         When importing
21         Then placex contains
22             | object | postcode |
23             | N22    | 11254    |
24             | W93    | 11250    |
25             | R4     | 11200    |
26             | R34    | 11000    |
27             | R1     | 10000    |
28
29     Scenario: Postcodes from a road are inherited by an attached building
30         Given the grid with origin DE
31             | 10 |   |   |   | 11 |
32             |    | 1 | 2 |   |    |
33             |    | 4 | 3 |   |    |
34         And the named places
35             | osm | class    | type        | addr+postcode | geometry |
36             | W93 | highway  | residential | 86034         | 10,11    |
37         And the named places
38             | osm | class    | type  | geometry    |
39             | W22 | building | yes   | (1,2,3,4,1) |
40         When importing
41         Then placex contains
42             | object | postcode | parent_place_id |
43             | W22    | 86034    | W93 |
44
45     Scenario: Postcodes from the lowest admin area are inherited by ways
46         Given the grid with origin FR
47             | 1 |    |    |    | 4 |  | 6 | | 8 |
48             |   | 10 |    | 11 |   |  |   | |   |
49             | 2 |    |    |    | 3 |  | 5 | | 7 |
50         And the named places
51             | osm | class    | type           | admin | addr+postcode | geometry |
52             | R1  | boundary | administrative | 6     | 10000         | (1,8,7,2,1) |
53             | R34 | boundary | administrative | 8     | 11000         | (1,6,5,2,1) |
54             | R4  | boundary | administrative | 10    | 11200         | (1,4,3,2,1) |
55         And the named places
56             | osm | class    | type           | geometry |
57             | W93 | highway  | residential    | 10,11    |
58         When importing
59         Then placex contains
60             | object | postcode |
61             | W93    | 11200    |
62
63     Scenario: Postcodes from the lowest admin area with postcode are inherited by ways
64         Given the grid with origin FR
65             | 1 |    |    |    | 4 |  | 6 | | 8 |
66             |   | 10 |    | 11 |   |  |   | |   |
67             | 2 |    |    |    | 3 |  | 5 | | 7 |
68         And the named places
69             | osm | class    | type           | admin | addr+postcode | geometry |
70             | R1  | boundary | administrative | 6     | 10000         | (1,8,7,2,1) |
71             | R34 | boundary | administrative | 8     | 11000         | (1,6,5,2,1) |
72         And the named places
73             | osm | class    | type           | admin | geometry    |
74             | R4  | boundary | administrative | 10    | (1,4,3,2,1) |
75         And the named places
76             | osm | class    | type           | geometry |
77             | W93 | highway  | residential    | 10,11    |
78         When importing
79         Then placex contains
80             | object | postcode | parent_place_id |
81             | W93    | 11000    | R4 |
82
83     Scenario: Postcodes from the lowest admin area are inherited by buildings
84         Given the grid with origin FR
85             | 1 |    |    |    | 4 |  | 6 | | 8 |
86             |   | 10 |    | 11 |   |  |   | |   |
87             |   | 13 |    | 12 |   |  |   | |   |
88             | 2 |    |    |    | 3 |  | 5 | | 7 |
89         And the named places
90             | osm | class    | type           | admin | addr+postcode | geometry |
91             | R1  | boundary | administrative | 6     | 10000         | (1,8,7,2,1) |
92             | R34 | boundary | administrative | 8     | 11000         | (1,6,5,2,1) |
93             | R4  | boundary | administrative | 10    | 11200         | (1,4,3,2,1) |
94         And the named places
95             | osm | class    | type  | geometry |
96             | W22 | building | yes   | (10,11,12,13,10) |
97         When importing
98         Then placex contains
99             | object | postcode |
100             | W22    | 11200    |
101
102     Scenario: Roads get postcodes from nearby named buildings without other info
103         Given the grid with origin US
104             | 10 |   |   |   | 11 |
105             |    | 1 | 2 |   |    |
106             |    | 4 | 3 |   |    |
107         And the named places
108             | osm | class    | type           | geometry |
109             | W93 | highway  | residential    | 10,11    |
110         And the named places
111             | osm | class    | type        | addr+postcode | geometry    |
112             | W22 | building | yes         | 45023         | (1,2,3,4,1) |
113         When importing
114         Then placex contains
115             | object | postcode |
116             | W93    | 45023    |
117
118     Scenario: Roads get postcodes from nearby unnamed buildings without other info
119         Given the grid with origin US
120             | 10 |   |   |   | 11 |
121             |    | 1 | 2 |   |    |
122             |    | 4 | 3 |   |    |
123         And the named places
124             | osm | class    | type           | geometry |
125             | W93 | highway  | residential    | 10,11    |
126         And the places
127             | osm | class    | type        | addr+postcode | geometry    |
128             | W22 | place    | postcode    | 45023         | (1,2,3,4,1) |
129         When importing
130         Then placex contains
131             | object | postcode |
132             | W93    | 45023    |
133
134     Scenario: Postcodes from admin boundaries are preferred over estimated postcodes
135         Given the grid with origin FR
136             | 1 |    |    |    | 4 |  | 6 | | 8 |
137             |   | 10 |    | 11 |   |  |   | |   |
138             |   |    | 22 |    |   |  |   | |   |
139             | 2 |    |    |    | 3 |  | 5 | | 7 |
140         And the named places
141             | osm | class    | type           | admin | addr+postcode | geometry |
142             | R1  | boundary | administrative | 6     | 10000         | (1,8,7,2,1) |
143             | R34 | boundary | administrative | 8     | 11000         | (1,6,5,2,1) |
144             | R4  | boundary | administrative | 10    | 11200         | (1,4,3,2,1) |
145         And the named places
146             | osm | class    | type           | geometry |
147             | W93 | highway  | residential    | 10,1     |
148         And the named places
149             | osm | class    | type        | addr+postcode |
150             | N22 | building | yes         | 45023         |
151         When importing
152         Then placex contains
153             | object | postcode |
154             | W93    | 11200    |
155
156     Scenario: Postcodes are added to the postcode and word table
157         Given the places
158            | osm | class | type  | addr+postcode | addr+housenumber | geometry |
159            | N34 | place | house | 01982         | 111              |country:de |
160         When importing
161         Then location_postcode contains exactly
162            | country | postcode | geometry |
163            | de      | 01982    | country:de |
164         And there are word tokens for postcodes 01982
165
166     Scenario: Different postcodes with the same normalization can both be found
167         Given the places
168            | osm | class | type  | addr+postcode | addr+housenumber | geometry |
169            | N34 | place | house | EH4 7EA       | 111              | country:gb |
170            | N35 | place | house | E4 7EA        | 111              | country:gb |
171         When importing
172         Then location_postcode contains exactly
173            | country | postcode | geometry |
174            | gb      | EH4 7EA  | country:gb |
175            | gb      | E4 7EA   | country:gb |
176         When sending search query "EH4 7EA"
177         Then results contain
178            | type     | display_name |
179            | postcode | EH4 7EA      |
180         When sending search query "E4 7EA"
181         Then results contain
182            | type     | display_name |
183            | postcode | E4 7EA       |
184
185     Scenario: search and address ranks for GB post codes correctly assigned
186         Given the places
187          | osm  | class | type     | postcode | geometry |
188          | N1   | place | postcode | E45 2CD  | country:gb |
189          | N2   | place | postcode | E45 2    | country:gb |
190          | N3   | place | postcode | Y45      | country:gb |
191         When importing
192         Then location_postcode contains exactly
193          | postcode | country | rank_search | rank_address |
194          | E45 2CD  | gb      | 25          | 5 |
195          | E45 2    | gb      | 23          | 5 |
196          | Y45      | gb      | 21          | 5 |
197
198     Scenario: wrongly formatted GB postcodes are down-ranked
199         Given the places
200          | osm  | class | type     | postcode | geometry |
201          | N1   | place | postcode | EA452CD  | country:gb |
202          | N2   | place | postcode | E45 23   | country:gb |
203         When importing
204         Then location_postcode contains exactly
205          | postcode | country | rank_search | rank_address |
206          | EA452CD  | gb      | 30          | 30 |
207          | E45 23   | gb      | 30          | 30 |
208
209     Scenario: search and address rank for DE postcodes correctly assigned
210         Given the places
211          | osm | class | type     | postcode | geometry |
212          | N1  | place | postcode | 56427    | country:de |
213          | N2  | place | postcode | 5642     | country:de |
214          | N3  | place | postcode | 5642A    | country:de |
215          | N4  | place | postcode | 564276   | country:de |
216         When importing
217         Then location_postcode contains exactly
218          | postcode | country | rank_search | rank_address |
219          | 56427    | de      | 21          | 11 |
220          | 5642     | de      | 30          | 30 |
221          | 5642A    | de      | 30          | 30 |
222          | 564276   | de      | 30          | 30 |
223
224     Scenario: search and address rank for other postcodes are correctly assigned
225         Given the places
226          | osm | class | type     | postcode | geometry |
227          | N1  | place | postcode | 1        | country:ca |
228          | N2  | place | postcode | X3       | country:ca |
229          | N3  | place | postcode | 543      | country:ca |
230          | N4  | place | postcode | 54dc     | country:ca |
231          | N5  | place | postcode | 12345    | country:ca |
232          | N6  | place | postcode | 55TT667  | country:ca |
233          | N7  | place | postcode | 123-65   | country:ca |
234          | N8  | place | postcode | 12 445 4 | country:ca |
235          | N9  | place | postcode | A1:bc10  | country:ca |
236         When importing
237         Then location_postcode contains exactly
238          | postcode | country | rank_search | rank_address |
239          | 1        | ca      | 21          | 11 |
240          | X3       | ca      | 21          | 11 |
241          | 543      | ca      | 21          | 11 |
242          | 54DC     | ca      | 21          | 11 |
243          | 12345    | ca      | 21          | 11 |
244          | 55TT667  | ca      | 21          | 11 |
245          | 123-65   | ca      | 25          | 11 |
246          | 12 445 4 | ca      | 25          | 11 |
247          | A1:BC10  | ca      | 25          | 11 |
248
249