Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search postcodes for highway areas around the area #3317

Merged
merged 1 commit into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib-sql/functions/placex_triggers.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1241,7 +1241,9 @@ BEGIN
OR ST_GeometryType(NEW.geometry) not in ('ST_LineString','ST_MultiLineString')
OR ST_Length(NEW.geometry) < 0.02)
THEN
NEW.postcode := get_nearest_postcode(NEW.country_code, NEW.geometry);
NEW.postcode := get_nearest_postcode(NEW.country_code,
CASE WHEN NEW.rank_address > 25
THEN NEW.centroid ELSE NEW.geometry END);
END IF;

{% if debug %}RAISE WARNING 'place update % % finished.', NEW.osm_type, NEW.osm_id;{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion test/bdd/api/reverse/queries.feature
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Feature: Reverse geocoding
| way | highway |
And result addresses contain
| road | postcode | country_code |
| Upper Kingston Road | 30607 | us |
| Upper Kingston Road | 36067 | us |

Scenario: Interpolated house number
When sending v1/reverse at 47.118533,9.57056562
Expand Down
17 changes: 17 additions & 0 deletions test/bdd/db/import/postcodes.feature
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,23 @@ Feature: Import of postcodes
| object | postcode |
| W93 | 45023 |

Scenario: Road areas get postcodes from nearby named buildings without other info
Given the grid with origin US
| 10 | | | | 11 |
| 13 | | | | 12 |
| | 1 | 2 | | |
| | 4 | 3 | | |
And the named places
| osm | class | type | geometry |
| W93 | highway | pedestriant | (10,11,12,13,10) |
And the named places
| osm | class | type | addr+postcode | geometry |
| W22 | building | yes | 45023 | (1,2,3,4,1) |
When importing
Then placex contains
| object | postcode |
| W93 | 45023 |

Scenario: Roads get postcodes from nearby unnamed buildings without other info
Given the grid with origin US
| 10 | | | | 11 |
Expand Down
Loading