[postgis-tickets] r17727 - postgis_sfcgal_noop().

Darafei komzpa at gmail.com
Sun Aug 18 05:18:59 PDT 2019


Author: komzpa
Date: 2019-08-18 05:18:59 -0700 (Sun, 18 Aug 2019)
New Revision: 17727

Modified:
   trunk/NEWS
   trunk/postgis/lwgeom_sfcgal.c
   trunk/postgis/sfcgal.sql.in
   trunk/regress/sfcgal/regress_sfcgal.sql
   trunk/regress/sfcgal/regress_sfcgal_expected
Log:
postgis_sfcgal_noop().

Patch by Lucas C. Villa Real <lucasvr at br.ibm.com>, tweaks by Darafei Praliaskouski

Closes #3979



Modified: trunk/NEWS
===================================================================
--- trunk/NEWS	2019-08-18 11:27:31 UTC (rev 17726)
+++ trunk/NEWS	2019-08-18 12:18:59 UTC (rev 17727)
@@ -203,6 +203,7 @@
   - #4277, ST_GeomFromGeoJSON now marks SRID=4326 by default as per RFC7946,
            ST_AsGeoJSON sets SRID in JSON output if it differs from 4326.
            (Darafei Praliaskouski)
+  - #3979, postgis_sfcgal_noop() round trip function (Lucas C. Villa Real)
 
 * Fixes *
   - #4342, Move deprecated functions into legacy.sql file

Modified: trunk/postgis/lwgeom_sfcgal.c
===================================================================
--- trunk/postgis/lwgeom_sfcgal.c	2019-08-18 11:27:31 UTC (rev 17726)
+++ trunk/postgis/lwgeom_sfcgal.c	2019-08-18 12:18:59 UTC (rev 17727)
@@ -50,6 +50,7 @@
 Datum sfcgal_minkowski_sum(PG_FUNCTION_ARGS);
 Datum sfcgal_make_solid(PG_FUNCTION_ARGS);
 Datum sfcgal_is_solid(PG_FUNCTION_ARGS);
+Datum postgis_sfcgal_noop(PG_FUNCTION_ARGS);
 
 GSERIALIZED *geometry_serialize(LWGEOM *lwgeom);
 char *text_to_cstring(const text *textptr);
@@ -526,3 +527,26 @@
 	PG_FREE_IF_COPY(input, 0);
 	PG_RETURN_POINTER(output);
 }
+
+PG_FUNCTION_INFO_V1(postgis_sfcgal_noop);
+Datum postgis_sfcgal_noop(PG_FUNCTION_ARGS)
+{
+	GSERIALIZED *input, *output;
+	LWGEOM *geom, *result;
+
+	sfcgal_postgis_init();
+
+	input = PG_GETARG_GSERIALIZED_P(0);
+	geom = lwgeom_from_gserialized(input);
+	if (!geom)
+		elog(ERROR, "sfcgal_noop: Unable to deserialize input");
+
+	result = lwgeom_sfcgal_noop(geom);
+	lwgeom_free(geom);
+	if (!result)
+		elog(ERROR, "sfcgal_noop: Unable to deserialize lwgeom");
+
+	output = geometry_serialize(result);
+	PG_FREE_IF_COPY(input, 0);
+	PG_RETURN_POINTER(output);
+}

Modified: trunk/postgis/sfcgal.sql.in
===================================================================
--- trunk/postgis/sfcgal.sql.in	2019-08-18 11:27:31 UTC (rev 17726)
+++ trunk/postgis/sfcgal.sql.in	2019-08-18 12:18:59 UTC (rev 17727)
@@ -27,6 +27,13 @@
         AS 'MODULE_PATHNAME'
         LANGUAGE 'c' IMMUTABLE;
 
+-- Availability: 3.0.0
+CREATE OR REPLACE FUNCTION postgis_sfcgal_noop(geometry)
+        RETURNS geometry
+        AS 'MODULE_PATHNAME', 'postgis_sfcgal_noop'
+        LANGUAGE 'c' IMMUTABLE STRICT _PARALLEL
+        COST 1;
+
 -- Availability: 2.1.0
 CREATE OR REPLACE FUNCTION ST_3DIntersection(geom1 geometry, geom2 geometry)
        RETURNS geometry

Modified: trunk/regress/sfcgal/regress_sfcgal.sql
===================================================================
--- trunk/regress/sfcgal/regress_sfcgal.sql	2019-08-18 11:27:31 UTC (rev 17726)
+++ trunk/regress/sfcgal/regress_sfcgal.sql	2019-08-18 12:18:59 UTC (rev 17727)
@@ -30,3 +30,4 @@
 SELECT 'ST_MinkowskiSum', ST_AsText(ST_MinkowskiSum('LINESTRING(0 0,4 0)','POLYGON((0 0,1 0,1 1,0 1,0 0))'));
 SELECT 'ST_StraightSkeleton', ST_AsText(ST_StraightSkeleton('POLYGON((1 1,2 1,2 2,1 2,1 1))'));
 SELECT 'ST_ConstrainedDelaunayTriangles', ST_AsText(ST_ConstrainedDelaunayTriangles('GEOMETRYCOLLECTION(POINT(0 0), POLYGON((2 2, 2 -2, 4 0, 2 2)))'));
+SELECT 'postgis_sfcgal_noop', ST_NPoints(postgis_sfcgal_noop(ST_Buffer('POINT(0 0)', 5)));

Modified: trunk/regress/sfcgal/regress_sfcgal_expected
===================================================================
--- trunk/regress/sfcgal/regress_sfcgal_expected	2019-08-18 11:27:31 UTC (rev 17726)
+++ trunk/regress/sfcgal/regress_sfcgal_expected	2019-08-18 12:18:59 UTC (rev 17727)
@@ -10,3 +10,4 @@
 ST_MinkowskiSum|MULTIPOLYGON(((0 0,1 0,5 0,5 1,4 1,0 1,0 0)))
 ST_StraightSkeleton|MULTILINESTRING((1 1,1.5 1.5),(2 1,1.5 1.5),(2 2,1.5 1.5),(1 2,1.5 1.5))
 ST_ConstrainedDelaunayTriangles|TIN(((4 0,2 2,2 -2,4 0)),((2 2,0 0,2 -2,2 2)))
+postgis_sfcgal_noop|33



More information about the postgis-tickets mailing list