From 5b9f61cff87403fc4253b5c534487822bdfd209e Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Thu, 6 Aug 2020 09:20:42 +0200 Subject: [PATCH] also take place tags into account for address rank 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 | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/sql/functions/placex_triggers.sql b/sql/functions/placex_triggers.sql index d9a65ecf..3faed24b 100644 --- a/sql/functions/placex_triggers.sql +++ b/sql/functions/placex_triggers.sql @@ -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 -- 2.39.5