From 6d81609804cf96639d5ba2f8d60b6df59e73ca0f Mon Sep 17 00:00:00 2001 From: Paul Ramsey Date: Wed, 1 Feb 2012 23:18:19 +0000 Subject: [PATCH] Add lwcollection_homogenize and ST_Homogenize (#375) git-svn-id: http://svn.osgeo.org/postgis/trunk@9009 b70326c6-7e19-0410-871a-916f4a2858ee --- liblwgeom/lwhomogenize.c | 2 ++ postgis/lwgeom_functions_basic.c | 21 +++++++++++++++++++++ postgis/postgis.sql.in.c | 6 ++++++ 3 files changed, 29 insertions(+) diff --git a/liblwgeom/lwhomogenize.c b/liblwgeom/lwhomogenize.c index 104f6c053..a074b68e2 100644 --- a/liblwgeom/lwhomogenize.c +++ b/liblwgeom/lwhomogenize.c @@ -31,6 +31,7 @@ init_homogenizebuffer(HomogenizeBuffer *buffer) } } +/* static void free_homogenizebuffer(HomogenizeBuffer *buffer) { @@ -43,6 +44,7 @@ free_homogenizebuffer(HomogenizeBuffer *buffer) } } } +*/ /* ** Given a generic collection, return the "simplest" form. diff --git a/postgis/lwgeom_functions_basic.c b/postgis/lwgeom_functions_basic.c index 9fdfcc8f0..f90de7fcb 100644 --- a/postgis/lwgeom_functions_basic.c +++ b/postgis/lwgeom_functions_basic.c @@ -2558,6 +2558,27 @@ Datum ST_CollectionExtract(PG_FUNCTION_ARGS) PG_RETURN_POINTER(output); } +PG_FUNCTION_INFO_V1(ST_CollectionHomogenize); +Datum ST_CollectionHomogenize(PG_FUNCTION_ARGS) +{ + GSERIALIZED *input = (GSERIALIZED *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0)); + GSERIALIZED *output; + LWGEOM *lwgeom = lwgeom_from_gserialized(input); + LWGEOM *lwoutput = NULL; + + lwoutput = lwgeom_homogenize(lwgeom); + lwgeom_free(lwgeom); + PG_FREE_IF_COPY(input, 0); + + if ( ! lwoutput ) + PG_RETURN_NULL(); + + output = geometry_serialize(lwoutput); + lwgeom_free(lwoutput); + + PG_RETURN_POINTER(output); +} + Datum ST_RemoveRepeatedPoints(PG_FUNCTION_ARGS); PG_FUNCTION_INFO_V1(ST_RemoveRepeatedPoints); Datum ST_RemoveRepeatedPoints(PG_FUNCTION_ARGS) diff --git a/postgis/postgis.sql.in.c b/postgis/postgis.sql.in.c index 5db961d93..92e8d6c76 100644 --- a/postgis/postgis.sql.in.c +++ b/postgis/postgis.sql.in.c @@ -1102,6 +1102,12 @@ CREATE OR REPLACE FUNCTION ST_CollectionExtract(geometry, integer) AS 'MODULE_PATHNAME', 'ST_CollectionExtract' LANGUAGE 'C' IMMUTABLE STRICT; +-- Availability: 2.0.0 +CREATE OR REPLACE FUNCTION ST_CollectionHomogenize(geometry) + RETURNS geometry + AS 'MODULE_PATHNAME', 'ST_CollectionHomogenize' + LANGUAGE 'C' IMMUTABLE STRICT; + -- Availability: 1.2.2 CREATE OR REPLACE FUNCTION ST_Multi(geometry) RETURNS geometry -- 2.40.0