This solves a bug with updating large invalid geometries. These
geometries have an entry in place but not in placex. Thus, place_insert
tries to delete the place entry and reinsert it on update. Deletion would
fail because self-intersecting polygons still have an area and large
areas are not deleted.
--DEBUG: RAISE WARNING 'delete: % % % %',OLD.osm_type,OLD.osm_id,OLD.class,OLD.type;
- -- deleting large polygons can have a massive effect ont he system - require manual intervention to let them through
- IF st_area(OLD.geometry) > 2 THEN
+ -- deleting large polygons can have a massive effect on the system - require manual intervention to let them through
+ IF st_area(OLD.geometry) > 2 and st_isvalid(OLD.geometry) THEN
insert into import_polygon_delete values (OLD.osm_type,OLD.osm_id,OLD.class,OLD.type);
RETURN NULL;
END IF;