Skip to content

Commit 9627352

Browse files
committed
search postcodes for highway areas around the area
So far the code would only accept postcodes that are inside the area. Fixes #3304.
1 parent bfc7acb commit 9627352

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

lib-sql/functions/placex_triggers.sql

+3-1
Original file line numberDiff line numberDiff line change
@@ -1241,7 +1241,9 @@ BEGIN
12411241
OR ST_GeometryType(NEW.geometry) not in ('ST_LineString','ST_MultiLineString')
12421242
OR ST_Length(NEW.geometry) < 0.02)
12431243
THEN
1244-
NEW.postcode := get_nearest_postcode(NEW.country_code, NEW.geometry);
1244+
NEW.postcode := get_nearest_postcode(NEW.country_code,
1245+
CASE WHEN NEW.rank_address > 25
1246+
THEN NEW.centroid ELSE NEW.geometry END);
12451247
END IF;
12461248

12471249
{% if debug %}RAISE WARNING 'place update % % finished.', NEW.osm_type, NEW.osm_id;{% endif %}

test/bdd/api/reverse/queries.feature

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Feature: Reverse geocoding
3939
| way | highway |
4040
And result addresses contain
4141
| road | postcode | country_code |
42-
| Upper Kingston Road | 30607 | us |
42+
| Upper Kingston Road | 36067 | us |
4343

4444
Scenario: Interpolated house number
4545
When sending v1/reverse at 47.118533,9.57056562

test/bdd/db/import/postcodes.feature

+17
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,23 @@ Feature: Import of postcodes
115115
| object | postcode |
116116
| W93 | 45023 |
117117

118+
Scenario: Road areas get postcodes from nearby named buildings without other info
119+
Given the grid with origin US
120+
| 10 | | | | 11 |
121+
| 13 | | | | 12 |
122+
| | 1 | 2 | | |
123+
| | 4 | 3 | | |
124+
And the named places
125+
| osm | class | type | geometry |
126+
| W93 | highway | pedestriant | (10,11,12,13,10) |
127+
And the named places
128+
| osm | class | type | addr+postcode | geometry |
129+
| W22 | building | yes | 45023 | (1,2,3,4,1) |
130+
When importing
131+
Then placex contains
132+
| object | postcode |
133+
| W93 | 45023 |
134+
118135
Scenario: Roads get postcodes from nearby unnamed buildings without other info
119136
Given the grid with origin US
120137
| 10 | | | | 11 |

0 commit comments

Comments
 (0)