]> git.openstreetmap.org Git - nominatim.git/commitdiff
update ref for postcode boundaries
authorSarah Hoffmann <lonvia@denofr.de>
Mon, 24 Mar 2014 12:01:20 +0000 (13:01 +0100)
committerSarah Hoffmann <lonvia@denofr.de>
Mon, 24 Mar 2014 12:01:20 +0000 (13:01 +0100)
Fixes https://trac.openstreetmap.org/ticket/5140

sql/functions.sql

index 62847e39a1b79dc1f8399e8ce8d97207ad7dba95..a102078ee0fee47c036f904be4b003183f83d419 100644 (file)
@@ -2258,6 +2258,16 @@ BEGIN
       geometry = NEW.geometry
       where osm_type = NEW.osm_type and osm_id = NEW.osm_id and class = NEW.class and type = NEW.type;
 
+    IF NEW.class in ('place','boundary') AND NEW.type in ('postcode','postal_code') THEN
+        IF NEW.postcode IS NULL THEN
+            -- postcode was deleted, no longer retain in placex
+            DELETE FROM placex where place_id = existingplacex.place_id;
+            RETURN NULL;
+        END IF;
+
+        NEW.name := hstore('ref', NEW.postcode);
+    END IF;
+
     update placex set 
       name = NEW.name,
       housenumber = NEW.housenumber,