[geos-commits] r2106 - trunk/capi

svn_geos at osgeo.org svn_geos at osgeo.org
Wed Jan 9 18:49:31 EST 2008


Author: benjubb
Date: 2008-01-09 18:49:31 -0500 (Wed, 09 Jan 2008)
New Revision: 2106

Modified:
   trunk/capi/geos_c.cpp
   trunk/capi/geos_c.h.in
Log:
Added support for prepared geometry

Modified: trunk/capi/geos_c.cpp
===================================================================
--- trunk/capi/geos_c.cpp	2008-01-09 23:48:27 UTC (rev 2105)
+++ trunk/capi/geos_c.cpp	2008-01-09 23:49:31 UTC (rev 2106)
@@ -16,6 +16,8 @@
  ***********************************************************************/
 
 #include <geos/geom/Geometry.h> 
+#include <geos/geom/prep/PreparedGeometry.h> 
+#include <geos/geom/prep/PreparedGeometryFactory.h> 
 #include <geos/geom/GeometryCollection.h> 
 #include <geos/geom/Polygon.h> 
 #include <geos/geom/Point.h> 
@@ -53,6 +55,7 @@
 
 // Some extra magic to make type declarations in geos_c.h work - for cross-checking of types in header.
 #define GEOSGeometry geos::geom::Geometry
+#define GEOSPreparedGeometry geos::geom::prep::PreparedGeometry
 #define GEOSCoordSequence geos::geom::CoordinateSequence
 #define GEOSWKTReader_t geos::io::WKTReader
 #define GEOSWKTWriter_t geos::io::WKTWriter
@@ -2281,4 +2284,128 @@
 }
 
 
+//-----------------------------------------------------------------
+// Prepared Geometry 
+//-----------------------------------------------------------------
+
+const geos::geom::prep::PreparedGeometry*
+GEOSPrepare(const Geometry *g)
+{
+	try
+	{
+		const geos::geom::prep::PreparedGeometry* prep;
+		prep = geos::geom::prep::PreparedGeometryFactory::prepare( g);
+		return prep;
+	}
+	catch (const std::exception &e)
+	{
+		ERROR_MESSAGE("%s", e.what());
+	}
+	catch (...)
+	{
+		ERROR_MESSAGE("Unknown exception thrown");
+	}
+}
+
+void
+GEOSPreparedGeom_destroy(geos::geom::prep::PreparedGeometry *a)
+{
+	try
+	{
+		delete a;
+	}
+	catch (const std::exception &e)
+	{
+		ERROR_MESSAGE("%s", e.what());
+	}
+	catch (...)
+	{
+		ERROR_MESSAGE("Unknown exception thrown");
+	}
+}
+
+char
+GEOSPreparedContains(const geos::geom::prep::PreparedGeometry *pg1, const Geometry *g2)
+{
+	try 
+	{
+		bool result;
+		result = pg1->contains(g2);
+		return result;
+	}
+	catch (const std::exception &e)
+	{
+		ERROR_MESSAGE("%s", e.what());
+		return 2;
+	}
+	catch (...)
+	{
+		ERROR_MESSAGE("Unknown exception thrown");
+		return 2;
+	}
+}
+
+char
+GEOSPreparedContainsProperty(const geos::geom::prep::PreparedGeometry *pg1, const Geometry *g2)
+{
+	try 
+	{
+		bool result;
+		result = pg1->containsProperly(g2);
+		return result;
+	}
+	catch (const std::exception &e)
+	{
+		ERROR_MESSAGE("%s", e.what());
+		return 2;
+	}
+	catch (...)
+	{
+		ERROR_MESSAGE("Unknown exception thrown");
+		return 2;
+	}
+}
+
+char
+GEOSPreparedCovers(const geos::geom::prep::PreparedGeometry *pg1, const Geometry *g2)
+{
+	try 
+	{
+		bool result;
+		result = pg1->covers(g2);
+		return result;
+	}
+	catch (const std::exception &e)
+	{
+		ERROR_MESSAGE("%s", e.what());
+		return 2;
+	}
+	catch (...)
+	{
+		ERROR_MESSAGE("Unknown exception thrown");
+		return 2;
+	}
+}
+
+char
+GEOSPreparedIntersects(const geos::geom::prep::PreparedGeometry *pg1, const Geometry *g2)
+{
+	try 
+	{
+		bool result;
+		result = pg1->intersects(g2);
+		return result;
+	}
+	catch (const std::exception &e)
+	{
+		ERROR_MESSAGE("%s", e.what());
+		return 2;
+	}
+	catch (...)
+	{
+		ERROR_MESSAGE("Unknown exception thrown");
+		return 2;
+	}
+}
+
 } //extern "C"

Modified: trunk/capi/geos_c.h.in
===================================================================
--- trunk/capi/geos_c.h.in	2008-01-09 23:48:27 UTC (rev 2105)
+++ trunk/capi/geos_c.h.in	2008-01-09 23:49:31 UTC (rev 2106)
@@ -86,6 +86,7 @@
  */
 #ifndef GEOSGeometry
 typedef struct GEOSGeom_t GEOSGeometry;
+typedef struct GEOSPrepGeom_t GEOSPreparedGeometry;
 typedef struct GEOSCoordSeq_t GEOSCoordSequence;
 #endif
 
@@ -312,6 +313,25 @@
 
 /************************************************************************
  *
+ *  Prepared Geometry Binary predicates - return 2 on exception, 1 on true, 0 on false
+ *
+ ***********************************************************************/
+
+/* 
+ * Argument ownership is taken by prepared geometry
+ */
+extern const GEOSPreparedGeometry GEOS_DLL *GEOSPrepare(const GEOSGeometry* g);
+
+extern void GEOS_DLL GEOSPreparedGeom_destroy(GEOSPreparedGeometry* g);
+
+extern char GEOS_DLL GEOSPreparedContains(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
+extern char GEOS_DLL GEOSPreparedContainsProperly(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
+extern char GEOS_DLL GEOSPreparedCovers(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
+extern char GEOS_DLL GEOSPreparedIntersects(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
+
+
+/************************************************************************
+ *
  *  Unary predicate - return 2 on exception, 1 on true, 0 on false
  *
  ***********************************************************************/



More information about the geos-commits mailing list