]> granicus.if.org Git - postgis/commitdiff
Add lwcollection_homogenize and ST_Homogenize (#375)
authorPaul Ramsey <pramsey@cleverelephant.ca>
Wed, 1 Feb 2012 23:18:19 +0000 (23:18 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Wed, 1 Feb 2012 23:18:19 +0000 (23:18 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@9009 b70326c6-7e19-0410-871a-916f4a2858ee

liblwgeom/lwhomogenize.c
postgis/lwgeom_functions_basic.c
postgis/postgis.sql.in.c

index 104f6c0536589afdf92d9c8aa43de6cc8e6fb049..a074b68e2cde56329ea99057885aade039cc8193 100644 (file)
@@ -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.
index 9fdfcc8f0762573f2e58167405fe2ca860e20bd9..f90de7fcb5dbaf50946d081aea743ddb08eb6278 100644 (file)
@@ -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)
index 5db961d93a10cab9e7b924c0aaf14f578c7cca0c..92e8d6c767c3f8b0f7b99415cf992dce4a1bcbb2 100644 (file)
@@ -1102,6 +1102,12 @@ CREATE OR REPLACE FUNCTION ST_CollectionExtract(geometry, integer)
        AS 'MODULE_PATHNAME', 'ST_CollectionExtract'\r
        LANGUAGE 'C' IMMUTABLE STRICT;\r
 \r
+-- Availability: 2.0.0\r
+CREATE OR REPLACE FUNCTION ST_CollectionHomogenize(geometry)\r
+       RETURNS geometry\r
+       AS 'MODULE_PATHNAME', 'ST_CollectionHomogenize'\r
+       LANGUAGE 'C' IMMUTABLE STRICT;\r
+\r
 -- Availability: 1.2.2\r
 CREATE OR REPLACE FUNCTION ST_Multi(geometry)\r
        RETURNS geometry\r