[geos-commits] r3145 - trunk/capi

svn_geos at osgeo.org svn_geos at osgeo.org
Thu Dec 2 09:52:20 EST 2010


Author: strk
Date: 2010-12-02 06:52:20 -0800 (Thu, 02 Dec 2010)
New Revision: 3145

Modified:
   trunk/capi/geos_c.cpp
   trunk/capi/geos_c.h.in
   trunk/capi/geos_ts_c.cpp
Log:
Expose snapping to the C-API

Modified: trunk/capi/geos_c.cpp
===================================================================
--- trunk/capi/geos_c.cpp	2010-12-02 14:29:32 UTC (rev 3144)
+++ trunk/capi/geos_c.cpp	2010-12-02 14:52:20 UTC (rev 3145)
@@ -1100,7 +1100,10 @@
     return GEOSSharedPaths_r(handle, g1, g2);
 }
 
-extern GEOSGeometry GEOS_DLL *GEOSSharedPaths_r(GEOSContextHandle_t handle,
-  const GEOSGeometry* g1, const GEOSGeometry* g2);
+GEOSGeometry *
+GEOSSnap(const GEOSGeometry* g1, const GEOSGeometry* g2, double tolerance)
+{
+  return GEOSSnap(handle, g1, g2);
+}
 
 } /* extern "C" */

Modified: trunk/capi/geos_c.h.in
===================================================================
--- trunk/capi/geos_c.h.in	2010-12-02 14:29:32 UTC (rev 3144)
+++ trunk/capi/geos_c.h.in	2010-12-02 14:52:20 UTC (rev 3145)
@@ -613,6 +613,15 @@
 extern GEOSGeometry GEOS_DLL *GEOSSharedPaths_r(GEOSContextHandle_t handle,
   const GEOSGeometry* g1, const GEOSGeometry* g2);
 
+/*
+ * Snap first geometry on to second with given tolerance
+ * Returns a newly allocated geometry, or NULL on exception
+ */
+extern GEOSGeometry GEOS_DLL *GEOSSnap(const GEOSGeometry* g1,
+  const GEOSGeometry* g2, double tolerance);
+extern GEOSGeometry GEOS_DLL *GEOSSnap_r(GEOSContextHandle_t handle,
+  const GEOSGeometry* g1, const GEOSGeometry* g2, double tolerance);
+
 /************************************************************************
  *
  *  Binary predicates - return 2 on exception, 1 on true, 0 on false

Modified: trunk/capi/geos_ts_c.cpp
===================================================================
--- trunk/capi/geos_ts_c.cpp	2010-12-02 14:29:32 UTC (rev 3144)
+++ trunk/capi/geos_ts_c.cpp	2010-12-02 14:52:20 UTC (rev 3145)
@@ -5402,5 +5402,33 @@
 
 }
 
+GEOSGeometry *
+GEOSSnap_r(GEOSContextHandle_t handle, const GEOSGeometry* g1,
+           const GEOSGeometry* g2, double tolerance)
+{
+    using namespace geos::operation::overlay::snap;
+
+    if ( 0 == extHandle ) return 0;
+    GEOSContextHandleInternal_t *handle =
+      reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+    if ( handle->initialized == 0 ) return 0;
+
+    try{
+      GeometrySnapper snapper( g1 );
+      std::auto_ptr<Geometry*> ret = snapper.snapTo(*g2, tolerance);
+      return ret.release();
+    }
+    catch (const std::exception &e)
+    {
+        handle->ERROR_MESSAGE("%s", e.what());
+        return 0;
+    }
+    catch (...)
+    {
+        handle->ERROR_MESSAGE("Unknown exception thrown");
+        return 0;
+    }
+}
+
 } /* extern "C" */
 



More information about the geos-commits mailing list