- IF coalesce(existing.name::text, '') != coalesce(NEW.name::text, '')
- OR coalesce(existing.extratags::text, '') != coalesce(NEW.extratags::text, '')
- OR coalesce(existing.address, ''::hstore) != coalesce(NEW.address, ''::hstore)
- OR coalesce(existing.admin_level, 15) != coalesce(NEW.admin_level, 15)
- OR existing.geometry::text != NEW.geometry::text
- THEN
-
- update place set
- name = NEW.name,
- address = NEW.address,
- extratags = NEW.extratags,
- admin_level = NEW.admin_level,
- 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 = 'boundary' AND NEW.type = 'postal_code' THEN
- IF NEW.address is NULL OR NOT NEW.address ? 'postcode' 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.address->'postcode');
- END IF;
-
- IF NEW.class in ('boundary')
- AND ST_GeometryType(NEW.geometry) not in ('ST_Polygon','ST_MultiPolygon') THEN
- DELETE FROM placex where place_id = existingplacex.place_id;
- RETURN NULL;
- END IF;
-
- update placex set
- name = NEW.name,
- address = NEW.address,
- parent_place_id = null,
- extratags = NEW.extratags,
- admin_level = NEW.admin_level,
- indexed_status = 2,
- geometry = NEW.geometry
- where place_id = existingplacex.place_id;
- -- if a node(=>house), which is part of a interpolation line, changes (e.g. the street attribute) => mark this line for reparenting
- -- (already here, because interpolation lines are reindexed before nodes, so in the second call it would be too late)
- IF NEW.osm_type='N'
- and (coalesce(existing.address, ''::hstore) != coalesce(NEW.address, ''::hstore)
- or existing.geometry::text != NEW.geometry::text)
- THEN
- result:= osmline_reinsert(NEW.osm_id, NEW.geometry);
- END IF;
+ -- Update the placex entry in-place.
+ UPDATE placex
+ SET name = NEW.name,
+ address = NEW.address,
+ parent_place_id = null,
+ extratags = NEW.extratags,
+ admin_level = NEW.admin_level,
+ indexed_status = 2,
+ geometry = NEW.geometry
+ WHERE place_id = existingplacex.place_id;
+
+ -- If an address node which is part of a interpolation line changes
+ -- mark this line for reparenting.
+ -- (Already here, because interpolation lines are reindexed before nodes,
+ -- so in the second call it would be too late.)
+ IF NEW.osm_type='N'
+ and coalesce(existing.address, ''::hstore) != coalesce(NEW.address, ''::hstore)
+ THEN
+ result:= osmline_reinsert(NEW.osm_id, NEW.geometry);
+ END IF;