[geos-commits] r4025 - in trunk: src/operation/intersection tests/unit/operation/intersection

svn_geos at osgeo.org svn_geos at osgeo.org
Thu Sep 25 08:32:25 PDT 2014


Author: strk
Date: 2014-09-25 08:32:25 -0700 (Thu, 25 Sep 2014)
New Revision: 4025

Modified:
   trunk/src/operation/intersection/RectangleIntersection.cpp
   trunk/tests/unit/operation/intersection/RectangleIntersectionTest.cpp
Log:
Fix another boundary bug in RectangleIntersection

Modified: trunk/src/operation/intersection/RectangleIntersection.cpp
===================================================================
--- trunk/src/operation/intersection/RectangleIntersection.cpp	2014-09-25 15:21:56 UTC (rev 4024)
+++ trunk/src/operation/intersection/RectangleIntersection.cpp	2014-09-25 15:32:25 UTC (rev 4025)
@@ -519,7 +519,10 @@
 		  else
 			{
         using geos::algorithm::CGAlgorithms;
-			  if( CGAlgorithms::isPointInRing(Coordinate(rect.xmin(), rect.ymin()),
+        Coordinate rectCenter(rect.xmin(), rect.ymin());
+        rectCenter.x += (rect.xmax()-rect.xmin())/2;
+        rectCenter.y += (rect.ymax()-rect.ymin())/2;
+			  if( CGAlgorithms::isPointInRing(rectCenter,
             g->getInteriorRingN(i)->getCoordinatesRO()) )
 				{
 				  // Completely inside the hole

Modified: trunk/tests/unit/operation/intersection/RectangleIntersectionTest.cpp
===================================================================
--- trunk/tests/unit/operation/intersection/RectangleIntersectionTest.cpp	2014-09-25 15:21:56 UTC (rev 4024)
+++ trunk/tests/unit/operation/intersection/RectangleIntersectionTest.cpp	2014-09-25 15:32:25 UTC (rev 4025)
@@ -1503,4 +1503,18 @@
         "POLYGON((0 8,8 8, 8 2, 0 2, 0 4, 5 4, 5 6, 0 6, 0 8))";
       doClipTest(inp, exp, r);
     }
+
+    // Hole outside the rect shares the lower-left corner
+    template<> template<> void object::test<207>()
+    {
+      Rectangle r(0,0,10,10);
+      const char *inp =
+        "POLYGON ("
+          "(-10 -10,-10 20,20 20,20 -10,-10 -10)," // CW
+          "(-5 -5,0 -5,0 0,-5 0,-5 -5)"     // CCW
+        ")";
+      const char *exp =
+        "POLYGON((0 0,0 10,10 10,10 0,0 0))";
+      doClipTest(inp, exp, r);
+    }
 }



More information about the geos-commits mailing list