2 Feature: Import of postcodes
3 Tests for postcode estimation
5 Scenario: Postcodes on the object are preferred over those on the address
6 Given the scene admin-areas
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 |
13 | osm | class | type | addr+postcode | geometry |
14 | W93 | highway | residential | 112 DE 344 | :w2N |
15 | W22 | building | yes | 112 DE 344N | :building:w2N |
25 Scenario: Postcodes from a road are inherited by an attached building
26 Given the scene admin-areas
28 | osm | class | type | addr+postcode | geometry |
29 | W93 | highway | residential | 86034 | :w2N |
31 | osm | class | type | geometry |
32 | W22 | building | yes | :building:w2N |
35 | object | postcode | parent_place_id |
38 Scenario: Postcodes from the lowest admin area are inherited by ways
39 Given the scene admin-areas
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 |
46 | osm | class | type | geometry |
47 | W93 | highway | residential | :w2N |
53 Scenario: Postcodes from the lowest admin area with postcode are inherited by ways
54 Given the scene admin-areas
56 | osm | class | type | admin | addr+postcode | geometry |
57 | R1 | boundary | administrative | 6 | 112 | :b0 |
58 | R34 | boundary | administrative | 8 | 112 DE | :b1:E |
60 | osm | class | type | admin | geometry |
61 | R4 | boundary | administrative | 10 | :b2:N |
63 | osm | class | type | geometry |
64 | W93 | highway | residential | :w2N |
67 | object | postcode | parent_place_id |
70 Scenario: Postcodes from the lowest admin area are inherited by buildings
71 Given the scene admin-areas
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 |
78 | osm | class | type | geometry |
79 | W22 | building | yes | :building:w2N |
85 Scenario: Roads get postcodes from nearby named buildings without other info
86 Given the scene admin-areas
88 | osm | class | type | geometry |
89 | W93 | highway | residential | :w2N |
91 | osm | class | type | addr+postcode | geometry |
92 | W22 | building | yes | 445023 | :building:w2N |
98 Scenario: Roads get postcodes from nearby unnamed buildings without other info
99 Given the scene admin-areas
101 | osm | class | type | geometry |
102 | W93 | highway | residential | :w2N |
104 | osm | class | type | addr+postcode | geometry |
105 | W22 | place | postcode | 445023 | :building:w2N |
108 | object | postcode |
111 Scenario: Postcodes from admin boundaries are preferred over estimated postcodes
112 Given the scene admin-areas
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 |
119 | osm | class | type | geometry |
120 | W93 | highway | residential | :w2N |
122 | osm | class | type | addr+postcode | geometry |
123 | W22 | building | yes | 445023 | :building:w2N |
126 | object | postcode |
129 Scenario: Postcodes are added to the postcode and word table
131 | osm | class | type | addr+postcode | addr+housenumber | geometry |
132 | N34 | place | house | 01982 | 111 |country:de |
134 Then location_postcode contains exactly
135 | country | postcode | geometry |
136 | de | 01982 | country:de |
137 And there are word tokens for postcodes 01982
139 Scenario: Different postcodes with the same normalization can both be found
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 |
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"
151 | type | display_name |
152 | postcode | EH4 7EA |
153 When sending search query "E4 7EA"
155 | type | display_name |
156 | postcode | E4 7EA |
158 Scenario: search and address ranks for GB post codes correctly assigned
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 |
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 |
171 Scenario: wrongly formatted GB postcodes are down-ranked
173 | osm | class | type | postcode | geometry |
174 | N1 | place | postcode | EA452CD | country:gb |
175 | N2 | place | postcode | E45 23 | country:gb |
177 Then location_postcode contains exactly
178 | postcode | country | rank_search | rank_address |
179 | EA452CD | gb | 30 | 30 |
180 | E45 23 | gb | 30 | 30 |
182 Scenario: search and address rank for DE postcodes correctly assigned
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 |
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 |
197 Scenario: search and address rank for other postcodes are correctly assigned
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 |
210 Then location_postcode contains exactly
211 | postcode | country | rank_search | rank_address |
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 |