From: Sarah Hoffmann Date: Wed, 7 Oct 2020 15:33:52 +0000 (+0200) Subject: demote place nodes in admin areas X-Git-Tag: v3.6.0~53^2~2 X-Git-Url: https://git.openstreetmap.org./nominatim.git/commitdiff_plain/b04463bb2d522d37de3ac4e56f2553144ff83604 demote place nodes in admin areas If a place node of city rank and above finds itself in an administrative boundary of the same address rank, then increase the address rank by 2. This catches the rather frequent case where city suburbs are tagged for historical reasons as towns or villages. --- diff --git a/sql/functions/placex_triggers.sql b/sql/functions/placex_triggers.sql index 9ef83b82..8c9cfae1 100644 --- a/sql/functions/placex_triggers.sql +++ b/sql/functions/placex_triggers.sql @@ -624,6 +624,21 @@ BEGIN NEW.rank_address := parent_address_level + 2; END IF; END IF; + -- If a place node is contained in a admin boundary with the same address level + -- and has not been linked, then make the node a subpart by increasing the + -- address rank (city level and above). + ELSEIF NEW.class = 'place' and NEW.osm_type = 'N' + and NEW.rank_address between 16 and 23 + THEN + FOR location IN + SELECT rank_address FROM placex + WHERE osm_type = 'R' and class = 'boundary' and type = 'administrative' + and rank_address = NEW.rank_address + and geometry && NEW.centroid and _ST_Covers(geometry, NEW.centroid) + LIMIT 1 + LOOP + NEW.rank_address = NEW.rank_address + 2; + END LOOP; ELSE parent_address_level := 3; END IF;