]> git.openstreetmap.org Git - nominatim.git/commitdiff
also take place tags into account for address rank
authorSarah Hoffmann <lonvia@denofr.de>
Thu, 6 Aug 2020 07:20:42 +0000 (09:20 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Wed, 12 Aug 2020 20:22:24 +0000 (22:22 +0200)
An admin boundary might have a place tag but no matching place node.
We still should use the place value as indicator for the address
rank in this case.

sql/functions/placex_triggers.sql

index d9a65ecf6d1276981255691607466457f203d366..3faed24bb3cc31e951df20ccf8257c2a9fec2443 100644 (file)
@@ -534,6 +534,7 @@ DECLARE
 
   centroid GEOMETRY;
   parent_address_level SMALLINT;
+  place_address_level SMALLINT;
 
   addr_street TEXT;
   addr_place TEXT;
@@ -828,6 +829,17 @@ BEGIN
     THEN
       NEW.importance = linked_importance;
     END IF;
+  ELSE
+    -- No linked place? As a last resort check if the boundary is tagged with
+    -- a place type and adapt the rank address.
+    IF NEW.rank_address > 0 and NEW.extratags ? 'place' THEN
+      SELECT address_rank INTO place_address_level
+        FROM compute_place_rank(NEW.country_code, 'A', 'place',
+                                NEW.extratags->'place', 0::SMALLINT, False, null);
+      IF place_address_level > parent_address_level THEN
+        NEW.rank_address := place_address_level;
+      END IF;
+    END IF;
   END IF;
 
   -- Initialise the name vector using our name