[postgis-commits] svn - r2736 - in trunk: . lwgeom
postgis-commits at postgis.refractions.net
postgis-commits at postgis.refractions.net
Tue Feb 12 07:03:27 PST 2008
Author: pramsey
Date: 2008-02-12 07:03:25 -0800 (Tue, 12 Feb 2008)
New Revision: 2736
Modified:
trunk/ChangeLog
trunk/lwgeom/lwgeom_geos_c.c
trunk/lwgeom/lwpostgis.sql.in
Log:
Added hook to GEOSTopologyPreserveSimplify
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2008-01-29 01:24:34 UTC (rev 2735)
+++ trunk/ChangeLog 2008-02-12 15:03:25 UTC (rev 2736)
@@ -1,3 +1,8 @@
+2008-02-12 Paul Ramsey <pramsey at cleverelephant.ca>
+
+ * lwgeom/lwgeom_geos_c.c, lwgeom/lwpostgis.sql.in: Add in hook to
+ GEOSTopologyPreserveSimplify
+
--------- PostGIS-1.3.2 release [2007-12-01] --------------------------
2007-11-30 Mark Cave-Ayland <mark.cave-ayland at ilande.co.uk>
Modified: trunk/lwgeom/lwgeom_geos_c.c
===================================================================
--- trunk/lwgeom/lwgeom_geos_c.c 2008-01-29 01:24:34 UTC (rev 2735)
+++ trunk/lwgeom/lwgeom_geos_c.c 2008-02-12 15:03:25 UTC (rev 2736)
@@ -60,6 +60,7 @@
Datum buffer(PG_FUNCTION_ARGS);
Datum intersection(PG_FUNCTION_ARGS);
Datum convexhull(PG_FUNCTION_ARGS);
+Datum topologypreservesimplify(PG_FUNCTION_ARGS);
Datum difference(PG_FUNCTION_ARGS);
Datum boundary(PG_FUNCTION_ARGS);
Datum symdifference(PG_FUNCTION_ARGS);
@@ -751,6 +752,83 @@
}
+PG_FUNCTION_INFO_V1(topologypreservesimplify);
+Datum topologypreservesimplify(PG_FUNCTION_ARGS)
+{
+ PG_LWGEOM *geom1;
+ double tolerance;
+ GEOSGeom g1,g3;
+ PG_LWGEOM *result;
+
+#ifdef PROFILE
+ profstart(PROF_QRUN);
+#endif
+
+ geom1 = (PG_LWGEOM *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
+ tolerance = PG_GETARG_FLOAT8(1);
+
+ initGEOS(lwnotice, lwnotice);
+
+#ifdef PROFILE
+ profstart(PROF_P2G1);
+#endif
+ g1 = POSTGIS2GEOS(geom1);
+#ifdef PROFILE
+ profstop(PROF_P2G1);
+#endif
+
+#ifdef PROFILE
+ profstart(PROF_GRUN);
+#endif
+ g3 = GEOSTopologyPreserveSimplify(g1,tolerance);
+#ifdef PROFILE
+ profstop(PROF_GRUN);
+#endif
+
+ if (g3 == NULL)
+ {
+ elog(ERROR,"GEOS topologypreservesimplify() threw an error!");
+ GEOSGeom_destroy(g1);
+ PG_RETURN_NULL(); /* never get here */
+ }
+
+
+#ifdef PGIS_DEBUG
+ elog(NOTICE,"result: %s", GEOSGeomToWKT(g3));
+#endif
+
+ GEOSSetSRID(g3, pglwgeom_getSRID(geom1));
+
+#ifdef PROFILE
+ profstart(PROF_G2P);
+#endif
+ result = GEOS2POSTGIS(g3, TYPE_HASZ(geom1->type));
+#ifdef PROFILE
+ profstop(PROF_G2P);
+#endif
+ if (result == NULL)
+ {
+ GEOSGeom_destroy(g1);
+ GEOSGeom_destroy(g3);
+ elog(ERROR,"GEOS topologypreservesimplify() threw an error (result postgis geometry formation)!");
+ PG_RETURN_NULL(); /* never get here */
+ }
+ GEOSGeom_destroy(g1);
+ GEOSGeom_destroy(g3);
+
+
+ /* compressType(result); */
+
+#ifdef PROFILE
+ profstop(PROF_QRUN);
+ profreport("geos",geom1, NULL, result);
+#endif
+
+ PG_FREE_IF_COPY(geom1, 0);
+
+ PG_RETURN_POINTER(result);
+}
+
PG_FUNCTION_INFO_V1(buffer);
Datum buffer(PG_FUNCTION_ARGS)
{
Modified: trunk/lwgeom/lwpostgis.sql.in
===================================================================
--- trunk/lwgeom/lwpostgis.sql.in 2008-01-29 01:24:34 UTC (rev 2735)
+++ trunk/lwgeom/lwpostgis.sql.in 2008-02-12 15:03:25 UTC (rev 2736)
@@ -4264,6 +4264,12 @@
AS '@MODULE_FILENAME@','convexhull'
LANGUAGE 'C' _IMMUTABLE_STRICT; -- WITH (isstrict,iscachable);
+-- Availability: 1.3.3
+CREATEFUNCTION ST_SimplifyPreserveTopology(geometry, float8)
+ RETURNS geometry
+ AS '@MODULE_FILENAME@','topologypreservesimplify'
+ LANGUAGE 'C' _IMMUTABLE_STRICT; -- WITH (isstrict,iscachable);
+
-- Deprecation in 1.2.3
CREATEFUNCTION difference(geometry,geometry)
RETURNS geometry
More information about the postgis-commits
mailing list