[geos-commits] r3322 - in trunk: capi src/geom/prep

svn_geos at osgeo.org svn_geos at osgeo.org
Mon May 2 22:27:00 EDT 2011


Author: sgillies
Date: 2011-05-02 19:27:00 -0700 (Mon, 02 May 2011)
New Revision: 3322

Modified:
   trunk/capi/geos_c.cpp
   trunk/capi/geos_c.h.in
   trunk/capi/geos_ts_c.cpp
   trunk/src/geom/prep/AbstractPreparedPolygonContains.cpp
   trunk/src/geom/prep/PreparedPolygon.cpp
Log:
Add missing prepared geometry predicates to C API (#436)

Modified: trunk/capi/geos_c.cpp
===================================================================
--- trunk/capi/geos_c.cpp	2011-04-28 16:39:02 UTC (rev 3321)
+++ trunk/capi/geos_c.cpp	2011-05-03 02:27:00 UTC (rev 3322)
@@ -1012,17 +1012,53 @@
 }
 
 char
+GEOSPreparedCoveredBy(const geos::geom::prep::PreparedGeometry *pg1, const Geometry *g2)
+{
+    return GEOSPreparedCoveredBy_r( handle, pg1, g2 );
+}
+
+char
 GEOSPreparedCovers(const geos::geom::prep::PreparedGeometry *pg1, const Geometry *g2)
 {
     return GEOSPreparedCovers_r( handle, pg1, g2 );
 }
 
 char
+GEOSPreparedCrosses(const geos::geom::prep::PreparedGeometry *pg1, const Geometry *g2)
+{
+    return GEOSPreparedCrosses_r( handle, pg1, g2 );
+}
+
+char
+GEOSPreparedDisjoint(const geos::geom::prep::PreparedGeometry *pg1, const Geometry *g2)
+{
+    return GEOSPreparedDisjoint_r( handle, pg1, g2 );
+}
+
+char
 GEOSPreparedIntersects(const geos::geom::prep::PreparedGeometry *pg1, const Geometry *g2)
 {
     return GEOSPreparedIntersects_r( handle, pg1, g2 );
 }
 
+char
+GEOSPreparedOverlaps(const geos::geom::prep::PreparedGeometry *pg1, const Geometry *g2)
+{
+    return GEOSPreparedOverlaps_r( handle, pg1, g2 );
+}
+
+char
+GEOSPreparedTouches(const geos::geom::prep::PreparedGeometry *pg1, const Geometry *g2)
+{
+    return GEOSPreparedTouches_r( handle, pg1, g2 );
+}
+
+char
+GEOSPreparedWithin(const geos::geom::prep::PreparedGeometry *pg1, const Geometry *g2)
+{
+    return GEOSPreparedWithin_r( handle, pg1, g2 );
+}
+
 STRtree *
 GEOSSTRtree_create (size_t nodeCapacity)
 {

Modified: trunk/capi/geos_c.h.in
===================================================================
--- trunk/capi/geos_c.h.in	2011-04-28 16:39:02 UTC (rev 3321)
+++ trunk/capi/geos_c.h.in	2011-05-03 02:27:00 UTC (rev 3322)
@@ -772,8 +772,14 @@
 
 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 GEOSPreparedCoveredBy(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
 extern char GEOS_DLL GEOSPreparedCovers(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
+extern char GEOS_DLL GEOSPreparedCrosses(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
+extern char GEOS_DLL GEOSPreparedDisjoint(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
 extern char GEOS_DLL GEOSPreparedIntersects(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
+extern char GEOS_DLL GEOSPreparedOverlaps(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
+extern char GEOS_DLL GEOSPreparedTouches(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
+extern char GEOS_DLL GEOSPreparedWithin(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
 
 /* 
  * GEOSGeometry ownership is retained by caller
@@ -791,12 +797,30 @@
 extern char GEOS_DLL GEOSPreparedContainsProperly_r(GEOSContextHandle_t handle,
                                          const GEOSPreparedGeometry* pg1,
                                          const GEOSGeometry* g2);
+extern char GEOS_DLL GEOSPreparedCoveredBy_r(GEOSContextHandle_t handle,
+                                          const GEOSPreparedGeometry* pg1,
+                                          const GEOSGeometry* g2);
 extern char GEOS_DLL GEOSPreparedCovers_r(GEOSContextHandle_t handle,
                                           const GEOSPreparedGeometry* pg1,
                                           const GEOSGeometry* g2);
+extern char GEOS_DLL GEOSPreparedCrosses_r(GEOSContextHandle_t handle,
+                                          const GEOSPreparedGeometry* pg1,
+                                          const GEOSGeometry* g2);
+extern char GEOS_DLL GEOSPreparedDisjoint_r(GEOSContextHandle_t handle,
+                                          const GEOSPreparedGeometry* pg1,
+                                          const GEOSGeometry* g2);
 extern char GEOS_DLL GEOSPreparedIntersects_r(GEOSContextHandle_t handle,
                                               const GEOSPreparedGeometry* pg1,
                                               const GEOSGeometry* g2);
+extern char GEOS_DLL GEOSPreparedOverlaps_r(GEOSContextHandle_t handle,
+                                          const GEOSPreparedGeometry* pg1,
+                                          const GEOSGeometry* g2);
+extern char GEOS_DLL GEOSPreparedTouches_r(GEOSContextHandle_t handle,
+                                          const GEOSPreparedGeometry* pg1,
+                                          const GEOSGeometry* g2);
+extern char GEOS_DLL GEOSPreparedWithin_r(GEOSContextHandle_t handle,
+                                          const GEOSPreparedGeometry* pg1,
+                                          const GEOSGeometry* g2);
 
 /************************************************************************
  *

Modified: trunk/capi/geos_ts_c.cpp
===================================================================
--- trunk/capi/geos_ts_c.cpp	2011-04-28 16:39:02 UTC (rev 3321)
+++ trunk/capi/geos_ts_c.cpp	2011-05-03 02:27:00 UTC (rev 3322)
@@ -5096,6 +5096,42 @@
 }
 
 char
+GEOSPreparedCoveredBy_r(GEOSContextHandle_t extHandle,
+        const geos::geom::prep::PreparedGeometry *pg, const Geometry *g)
+{
+    assert(0 != pg);
+    assert(0 != g);
+
+    if ( 0 == extHandle )
+    {
+        return 2;
+    }
+
+    GEOSContextHandleInternal_t *handle = 0;
+    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+    if ( 0 == handle->initialized )
+    {
+        return 2;
+    }
+
+    try 
+    {
+        bool result = pg->coveredBy(g);
+        return result;
+    }
+    catch (const std::exception &e)
+    {
+        handle->ERROR_MESSAGE("%s", e.what());
+    }
+    catch (...)
+    {
+        handle->ERROR_MESSAGE("Unknown exception thrown");
+    }
+    
+    return 2;
+}
+
+char
 GEOSPreparedCovers_r(GEOSContextHandle_t extHandle,
         const geos::geom::prep::PreparedGeometry *pg, const Geometry *g)
 {
@@ -5132,6 +5168,78 @@
 }
 
 char
+GEOSPreparedCrosses_r(GEOSContextHandle_t extHandle,
+        const geos::geom::prep::PreparedGeometry *pg, const Geometry *g)
+{
+    assert(0 != pg);
+    assert(0 != g);
+
+    if ( 0 == extHandle )
+    {
+        return 2;
+    }
+
+    GEOSContextHandleInternal_t *handle = 0;
+    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+    if ( 0 == handle->initialized )
+    {
+        return 2;
+    }
+
+    try 
+    {
+        bool result = pg->crosses(g);
+        return result;
+    }
+    catch (const std::exception &e)
+    {
+        handle->ERROR_MESSAGE("%s", e.what());
+    }
+    catch (...)
+    {
+        handle->ERROR_MESSAGE("Unknown exception thrown");
+    }
+    
+    return 2;
+}
+
+char
+GEOSPreparedDisjoint_r(GEOSContextHandle_t extHandle,
+        const geos::geom::prep::PreparedGeometry *pg, const Geometry *g)
+{
+    assert(0 != pg);
+    assert(0 != g);
+
+    if ( 0 == extHandle )
+    {
+        return 2;
+    }
+
+    GEOSContextHandleInternal_t *handle = 0;
+    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+    if ( 0 == handle->initialized )
+    {
+        return 2;
+    }
+
+    try 
+    {
+        bool result = pg->disjoint(g);
+        return result;
+    }
+    catch (const std::exception &e)
+    {
+        handle->ERROR_MESSAGE("%s", e.what());
+    }
+    catch (...)
+    {
+        handle->ERROR_MESSAGE("Unknown exception thrown");
+    }
+    
+    return 2;
+}
+
+char
 GEOSPreparedIntersects_r(GEOSContextHandle_t extHandle,
         const geos::geom::prep::PreparedGeometry *pg, const Geometry *g)
 {
@@ -5167,6 +5275,114 @@
     return 2;
 }
 
+char
+GEOSPreparedOverlaps_r(GEOSContextHandle_t extHandle,
+        const geos::geom::prep::PreparedGeometry *pg, const Geometry *g)
+{
+    assert(0 != pg);
+    assert(0 != g);
+
+    if ( 0 == extHandle )
+    {
+        return 2;
+    }
+
+    GEOSContextHandleInternal_t *handle = 0;
+    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+    if ( 0 == handle->initialized )
+    {
+        return 2;
+    }
+
+    try 
+    {
+        bool result = pg->overlaps(g);
+        return result;
+    }
+    catch (const std::exception &e)
+    {
+        handle->ERROR_MESSAGE("%s", e.what());
+    }
+    catch (...)
+    {
+        handle->ERROR_MESSAGE("Unknown exception thrown");
+    }
+    
+    return 2;
+}
+
+char
+GEOSPreparedTouches_r(GEOSContextHandle_t extHandle,
+        const geos::geom::prep::PreparedGeometry *pg, const Geometry *g)
+{
+    assert(0 != pg);
+    assert(0 != g);
+
+    if ( 0 == extHandle )
+    {
+        return 2;
+    }
+
+    GEOSContextHandleInternal_t *handle = 0;
+    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+    if ( 0 == handle->initialized )
+    {
+        return 2;
+    }
+
+    try 
+    {
+        bool result = pg->touches(g);
+        return result;
+    }
+    catch (const std::exception &e)
+    {
+        handle->ERROR_MESSAGE("%s", e.what());
+    }
+    catch (...)
+    {
+        handle->ERROR_MESSAGE("Unknown exception thrown");
+    }
+    
+    return 2;
+}
+
+char
+GEOSPreparedWithin_r(GEOSContextHandle_t extHandle,
+        const geos::geom::prep::PreparedGeometry *pg, const Geometry *g)
+{
+    assert(0 != pg);
+    assert(0 != g);
+
+    if ( 0 == extHandle )
+    {
+        return 2;
+    }
+
+    GEOSContextHandleInternal_t *handle = 0;
+    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+    if ( 0 == handle->initialized )
+    {
+        return 2;
+    }
+
+    try 
+    {
+        bool result = pg->within(g);
+        return result;
+    }
+    catch (const std::exception &e)
+    {
+        handle->ERROR_MESSAGE("%s", e.what());
+    }
+    catch (...)
+    {
+        handle->ERROR_MESSAGE("Unknown exception thrown");
+    }
+    
+    return 2;
+}
+
 //-----------------------------------------------------------------
 // STRtree
 //-----------------------------------------------------------------

Modified: trunk/src/geom/prep/AbstractPreparedPolygonContains.cpp
===================================================================
--- trunk/src/geom/prep/AbstractPreparedPolygonContains.cpp	2011-04-28 16:39:02 UTC (rev 3321)
+++ trunk/src/geom/prep/AbstractPreparedPolygonContains.cpp	2011-05-03 02:27:00 UTC (rev 3322)
@@ -92,12 +92,12 @@
 	intDetector = new noding::SegmentIntersectionDetector(li);
 
 	intDetector->setFindAllIntersectionTypes( true);
-
 	prepPoly->getIntersectionFinder()->intersects(&lineSegStr, intDetector);
-		
+  /*
 	hasSegmentIntersection = intDetector->hasIntersection();
 	hasProperIntersection = intDetector->hasProperIntersection();
 	hasNonProperIntersection = intDetector->hasNonProperIntersection();
+  */
 
 	delete intDetector;
 	delete li;
@@ -149,7 +149,7 @@
 	bool properIntersectionImpliesNotContained = isProperIntersectionImpliesNotContainedSituation( geom);
 
 	// find all intersection types which exist
-	findAndClassifyIntersections( geom);
+  findAndClassifyIntersections( geom);
 
 	if ( properIntersectionImpliesNotContained && hasProperIntersection )
 		return false;

Modified: trunk/src/geom/prep/PreparedPolygon.cpp
===================================================================
--- trunk/src/geom/prep/PreparedPolygon.cpp	2011-04-28 16:39:02 UTC (rev 3321)
+++ trunk/src/geom/prep/PreparedPolygon.cpp	2011-05-03 02:27:00 UTC (rev 3322)
@@ -93,11 +93,11 @@
     {
         geom::Geometry const& geom = getGeometry();
         geom::Polygon const& poly = dynamic_cast<geom::Polygon const&>(geom);
-        
+       
         return operation::predicate::RectangleContains::contains(poly, *g);
     }
 
-	return PreparedPolygonContains::contains( this, g);
+	  return PreparedPolygonContains::contains(this, g);
 }
 
 bool 



More information about the geos-commits mailing list