fix non-noded intersection between shoreline clipped and non-shoreline clipped geometries by using a safe_intersection function
This commit is contained in:
@@ -231,3 +231,22 @@ CREATE AGGREGATE cdb_observatory.FIRST (
|
||||
basetype = anyelement,
|
||||
stype = anyelement
|
||||
);
|
||||
|
||||
-- Attempt to perform intersection, if there's an exception then buffer
|
||||
-- https://gis.stackexchange.com/questions/50399/how-best-to-fix-a-non-noded-intersection-problem-in-postgis
|
||||
CREATE OR REPLACE FUNCTION cdb_observatory.safe_intersection(geom_a geometry, geom_b geometry)
|
||||
RETURNS geometry AS
|
||||
$$
|
||||
BEGIN
|
||||
RETURN ST_Intersection(geom_a, geom_b);
|
||||
EXCEPTION
|
||||
WHEN OTHERS THEN
|
||||
BEGIN
|
||||
RETURN ST_Intersection(ST_Buffer(geom_a, 0.0000001), ST_Buffer(geom_b, 0.0000001));
|
||||
EXCEPTION
|
||||
WHEN OTHERS THEN
|
||||
RETURN ST_GeomFromText('POLYGON EMPTY');
|
||||
END;
|
||||
END
|
||||
$$
|
||||
LANGUAGE 'plpgsql' STABLE STRICT;
|
||||
|
||||
Reference in New Issue
Block a user