-
-
Save ErshKUS/90fb658660c9ccecd4b3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Function: ershkus_fn_geompoly(geometry[]) | |
-- DROP FUNCTION ershkus_fn_geompoly(geometry[]); | |
CREATE OR REPLACE FUNCTION ershkus_fn_geompoly(geometry[]) | |
RETURNS geometry AS | |
$BODY$ | |
BEGIN | |
-- RETURN (SELECT ST_Polygonize(c2) FROM (SELECT ST_GeomFromText(astext(ST_Collect(c1)),4326) as c2 FROM (SELECT unnest($1) as c1) as t1) as t2); | |
RETURN (SELECT ST_BuildArea(ST_GeomFromText(astext(ST_Collect(c1)),4326)) as c2 FROM (SELECT unnest($1) as c1) as t1); | |
EXCEPTION | |
WHEN SQLSTATE 'XX000' THEN | |
RETURN null; | |
WHEN SQLSTATE '21000' THEN | |
RETURN null; | |
END; | |
$BODY$ | |
LANGUAGE plpgsql VOLATILE | |
COST 100; | |
ALTER FUNCTION ershkus_fn_geompoly(geometry[]) | |
OWNER TO ershkus; | |
GRANT EXECUTE ON FUNCTION ershkus_fn_geompoly(geometry[]) TO public; | |
GRANT EXECUTE ON FUNCTION ershkus_fn_geompoly(geometry[]) TO ershkus; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment