]> git.openstreetmap.org Git - nominatim.git/commitdiff
search postcodes for highway areas around the area
authorSarah Hoffmann <lonvia@denofr.de>
Fri, 26 Jan 2024 16:26:29 +0000 (17:26 +0100)
committerSarah Hoffmann <lonvia@denofr.de>
Fri, 26 Jan 2024 17:14:11 +0000 (18:14 +0100)
So far the code would only accept postcodes that are inside the area.

Fixes #3304.

lib-sql/functions/placex_triggers.sql
test/bdd/api/reverse/queries.feature
test/bdd/db/import/postcodes.feature

index 58e5f2a88097cb632b0c6b39a2894eafa27fe0f4..841b7fd627196718de1c9e8067afb99e868c64ed 100644 (file)
@@ -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 %}
index 37abb22d4095317a397c2bf35fff71924efdbd63..f154b18debb7a99ec845ea67d4c8a5159986d6d2 100644 (file)
@@ -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
index 4d146d18c191e95a4cad025bf5c823818072b7f6..57f90d98d07443f22b543810dcf864f724e83c33 100644 (file)
@@ -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 |