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