+ -- If an address node is part of a interpolation line and changes or is
+ -- newly inserted (happens when the node already existed but now gets address
+ -- information), then mark the interpolation 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
+ FOR interpol IN
+ SELECT DISTINCT osm_id, address, geometry FROM place, planet_osm_ways w
+ WHERE NEW.geometry && place.geometry
+ and place.osm_type = 'W'
+ and place.address ? 'interpolation'
+ and exists (SELECT * FROM location_property_osmline
+ WHERE osm_id = place.osm_id
+ and indexed_status in (0, 2))
+ and w.id = place.osm_id and NEW.osm_id = any (w.nodes)
+ LOOP
+ PERFORM reinsert_interpolation(interpol.osm_id, interpol.address,
+ interpol.geometry);
+ END LOOP;
+ END IF;
+