Merge remote-tracking branch 'origin/release-v-1.3.3' into faster-autotest

Conflicts:
	src/pg/sql/40_observatory_utility.sql
This commit is contained in:
John Krauss
2017-03-08 20:52:31 +00:00
7 changed files with 226 additions and 36 deletions

View File

@@ -246,3 +246,25 @@ RETURNS BOOLEAN LANGUAGE SQL IMMUTABLE STRICT AS $$
'double precision'
)
$$;
-- 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(Geometry, 4326),
geom_b Geometry(Geometry, 4326)
)
RETURNS Geometry(Geometry, 4326) AS
$$
BEGIN
RETURN ST_MakeValid(ST_Intersection(geom_a, geom_b));
EXCEPTION
WHEN OTHERS THEN
BEGIN
RETURN ST_MakeValid(ST_Intersection(ST_Buffer(geom_a, 0.0000001), ST_Buffer(geom_b, 0.0000001)));
EXCEPTION
WHEN OTHERS THEN
RETURN NULL;
END;
END
$$
LANGUAGE 'plpgsql' STABLE STRICT;