[geos-commits] [SCM] GEOS branch 3.7 updated. 35280712b63b7f43af80a771b0bb35c876655ab3

git at osgeo.org git at osgeo.org
Mon Jan 28 11:28:58 PST 2019


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GEOS".

The branch, 3.7 has been updated
       via  35280712b63b7f43af80a771b0bb35c876655ab3 (commit)
      from  1c72b2e2372d4b7f2875e6841034c54aee1dc984 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 35280712b63b7f43af80a771b0bb35c876655ab3
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Mon Jan 28 11:28:40 2019 -0800

    Polygon build failure in Overlay difference
    References #789

diff --git a/NEWS b/NEWS
index 5ab05ec..9efb73b 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,7 @@ Changes in 3.7.2
 - Bug fixes / improvements
   - Envelope constructor using strtod (#875 Paul Ramsey)
   - Failure in CMake for OSX Framework (#936 Paul Ramsey)
+  - Polygon build failure in Overlay difference (#789 Paul Ramsey)
 
 
 
diff --git a/src/operation/overlay/PolygonBuilder.cpp b/src/operation/overlay/PolygonBuilder.cpp
index 8bb1bfb..583a660 100644
--- a/src/operation/overlay/PolygonBuilder.cpp
+++ b/src/operation/overlay/PolygonBuilder.cpp
@@ -21,6 +21,7 @@
 #include <geos/operation/overlay/OverlayOp.h>
 #include <geos/operation/overlay/MaximalEdgeRing.h>
 #include <geos/operation/overlay/MinimalEdgeRing.h>
+#include <geos/operation/polygonize/EdgeRing.h>
 #include <geos/geomgraph/Node.h>
 #include <geos/geomgraph/NodeMap.h>
 #include <geos/geomgraph/DirectedEdgeStar.h>
@@ -44,7 +45,6 @@ using namespace geos::geomgraph;
 using namespace geos::algorithm;
 using namespace geos::geom;
 
-
 namespace geos {
 namespace operation { // geos.operation
 namespace overlay { // geos.operation.overlay
@@ -146,9 +146,9 @@ PolygonBuilder::buildMaximalEdgeRings(const vector<DirectedEdge*> *dirEdges,
 		DirectedEdge *de=(*dirEdges)[i];
 #if GEOS_DEBUG
 	cerr << "  dirEdge " << i << endl
-	     << de->printEdge() << endl
-	     << " inResult:" << de->isInResult() << endl
-	     << " isArea:" << de->getLabel().isArea() << endl;
+		 << de->printEdge() << endl
+		 << " inResult:" << de->isInResult() << endl
+		 << " isArea:" << de->getLabel().isArea() << endl;
 #endif
 		if (de->isInResult() && de->getLabel().isArea())
 		{
@@ -305,14 +305,14 @@ PolygonBuilder::placeFreeHoles(std::vector<EdgeRing*>& newShellList,
 				{
 					geom = (*rIt)->toPolygon(geometryFactory);
 					std::cerr << "INSERT INTO shells VALUES ('"
-					          << *geom
-					          << "');" << std::endl;
+							  << *geom
+							  << "');" << std::endl;
 					delete geom;
 				}
 				geom = hole->toPolygon(geometryFactory);
 				std::cerr << "INSERT INTO hole VALUES ('"
-				          << *geom
-				          << "');" << std::endl;
+						  << *geom
+						  << "');" << std::endl;
 				delete geom;
 #endif
 				//assert(shell!=NULL); // unable to assign hole to a shell
@@ -331,30 +331,33 @@ PolygonBuilder::findEdgeRingContaining(EdgeRing *testEr,
 {
 	LinearRing *testRing=testEr->getLinearRing();
 	const Envelope *testEnv=testRing->getEnvelopeInternal();
-	const Coordinate& testPt=testRing->getCoordinateN(0);
 	EdgeRing *minShell=nullptr;
-	const Envelope *minEnv=nullptr;
-	for(size_t i=0, n=newShellList.size(); i<n; i++)
+	const Envelope *minShellEnv=nullptr;
+
+	for(auto const& tryShell: newShellList)
 	{
-		LinearRing *lr=nullptr;
-		EdgeRing *tryShell=newShellList[i];
-		LinearRing *tryRing=tryShell->getLinearRing();
-		const Envelope *tryEnv=tryRing->getEnvelopeInternal();
-		if (minShell!=nullptr) {
-			lr=minShell->getLinearRing();
-			minEnv=lr->getEnvelopeInternal();
-		}
-		bool isContained=false;
-		const CoordinateSequence *rcl = tryRing->getCoordinatesRO();
-		if (tryEnv->contains(testEnv)
-			&& CGAlgorithms::isPointInRing(testPt,rcl))
-				isContained=true;
+		LinearRing *tryShellRing = tryShell->getLinearRing();
+		const Envelope *tryShellEnv=tryShellRing->getEnvelopeInternal();
+		// hole must be contained in shell
+		// the hole envelope cannot equal the shell envelope
+		// (also guards against testing rings against themselves)
+		if (tryShellEnv->equals(testEnv)) continue;
+		// hole must be contained in shell
+		if (!tryShellEnv->contains(testEnv)) continue;
+		const CoordinateSequence *tsrcs = tryShellRing->getCoordinatesRO();
+		Coordinate testPt = geos::operation::polygonize::EdgeRing::ptNotInList(testRing->getCoordinatesRO(), tsrcs);
+
+		bool isContained = false;
+		if (CGAlgorithms::locatePointInRing(testPt, *tsrcs) != Location::EXTERIOR)
+			isContained = true;
+
 		// check if this new containing ring is smaller than
 		// the current minimum ring
 		if (isContained) {
-			if (minShell==nullptr
-				|| minEnv->contains(tryEnv)) {
-					minShell=tryShell;
+			if (minShell==nullptr ||
+			    minShellEnv->contains(tryShellEnv)) {
+				minShell = tryShell;
+				minShellEnv = minShell->getLinearRing()->getEnvelopeInternal();
 			}
 		}
 	}
diff --git a/tests/xmltester/tests/general/TestFunctionAA.xml b/tests/xmltester/tests/general/TestFunctionAA.xml
index d0d713a..5468fd8 100644
--- a/tests/xmltester/tests/general/TestFunctionAA.xml
+++ b/tests/xmltester/tests/general/TestFunctionAA.xml
@@ -33,7 +33,7 @@
   <op name="symdifference" arg1="A" arg2="B">
     MULTIPOLYGON(
       (
-        (10 10, 10 100, 50 100, 50 50, 100 50, 100 10, 10 10)), 
+        (10 10, 10 100, 50 100, 50 50, 100 50, 100 10, 10 10)),
       (
         (50 100, 50 200, 200 200, 200 50, 100 50, 100 100, 50 100)))
   </op>
@@ -44,7 +44,7 @@
   <desc>AA - A with hole intersecting B</desc>
   <a>
     POLYGON(
-      (20 20, 20 160, 160 160, 160 20, 20 20), 
+      (20 20, 20 160, 160 160, 160 20, 20 20),
       (140 140, 40 140, 40 40, 140 40, 140 140))
   </a>
   <b>
@@ -60,14 +60,14 @@
 <test>
   <op name="union" arg1="A" arg2="B">
     POLYGON(
-      (20 20, 20 160, 80 160, 80 240, 220 240, 220 100, 160 100, 160 20, 20 20), 
+      (20 20, 20 160, 80 160, 80 240, 220 240, 220 100, 160 100, 160 20, 20 20),
       (80 100, 80 140, 40 140, 40 40, 140 40, 140 100, 80 100))
   </op>
 </test>
 <test>
   <op name="difference" arg1="A" arg2="B">
     POLYGON(
-      (20 20, 20 160, 80 160, 80 140, 40 140, 40 40, 140 40, 140 100, 160 100, 
+      (20 20, 20 160, 80 160, 80 140, 40 140, 40 40, 140 40, 140 100, 160 100,
       160 20, 20 20))
   </op>
 </test>
@@ -75,10 +75,10 @@
   <op name="symdifference" arg1="A" arg2="B">
     MULTIPOLYGON(
       (
-        (20 20, 20 160, 80 160, 80 140, 40 140, 40 40, 140 40, 140 100, 160 100, 
-        160 20, 20 20)), 
+        (20 20, 20 160, 80 160, 80 140, 40 140, 40 40, 140 40, 140 100, 160 100,
+        160 20, 20 20)),
       (
-        (80 100, 80 140, 140 140, 140 100, 80 100)), 
+        (80 100, 80 140, 140 140, 140 100, 80 100)),
       (
         (80 160, 80 240, 220 240, 220 100, 160 100, 160 160, 80 160)))
   </op>
@@ -117,7 +117,7 @@
   <op name="symdifference" arg1="A" arg2="B">
     MULTIPOLYGON(
       (
-        (20 340, 330 380, 50 40, 28 260, 140 220, 210 320, 140 270, 27 270, 20 340)), 
+        (20 340, 330 380, 50 40, 28 260, 140 220, 210 320, 140 270, 27 270, 20 340)),
       (
         (27 270, 28 260, 0 270, 27 270)))
   </op>
@@ -135,8 +135,8 @@
 <test>
   <op name="intersection" arg1="A" arg2="B">
     GEOMETRYCOLLECTION(
-      POINT(110 260), 
-      LINESTRING(110 0, 110 60), 
+      POINT(110 260),
+      LINESTRING(110 0, 110 60),
       POLYGON(
         (110 100, 40 140, 110 180, 180 140, 110 100)))
   </op>
@@ -144,24 +144,24 @@
 <test>
   <op name="union" arg1="A" arg2="B">
     POLYGON(
-      (110 0, 0 0, 0 260, 110 260, 220 260, 220 0, 110 0), 
-      (110 260, 40 220, 110 180, 180 220, 110 260), 
+      (110 0, 0 0, 0 260, 110 260, 220 260, 220 0, 110 0),
+      (110 260, 40 220, 110 180, 180 220, 110 260),
       (110 100, 40 60, 110 60, 180 60, 110 100))
   </op>
 </test>
 <test>
   <op name="difference" arg1="A" arg2="B">
     POLYGON(
-      (110 0, 0 0, 0 260, 110 260, 40 220, 110 180, 40 140, 110 100, 40 60, 
+      (110 0, 0 0, 0 260, 110 260, 40 220, 110 180, 40 140, 110 100, 40 60,
       110 60, 110 0))
   </op>
 </test>
 <test>
   <op name="symdifference" arg1="A" arg2="B">
     POLYGON(
-      (110 0, 0 0, 0 260, 110 260, 220 260, 220 0, 110 0), 
-      (110 260, 40 220, 110 180, 180 220, 110 260), 
-      (110 180, 40 140, 110 100, 180 140, 110 180), 
+      (110 0, 0 0, 0 260, 110 260, 220 260, 220 0, 110 0),
+      (110 260, 40 220, 110 180, 180 220, 110 260),
+      (110 180, 40 140, 110 100, 180 140, 110 180),
       (110 100, 40 60, 110 60, 180 60, 110 100))
   </op>
 </test>
@@ -171,19 +171,19 @@
   <desc>AA - simple polygons with two touching holes in their symDifference</desc>
   <a>
     POLYGON(
-      (0 0, 120 0, 120 50, 50 50, 120 100, 50 150, 120 150, 120 190, 0 190, 
+      (0 0, 120 0, 120 50, 50 50, 120 100, 50 150, 120 150, 120 190, 0 190,
       0 0))
   </a>
   <b>
     POLYGON(
-      (230 0, 120 0, 120 50, 190 50, 120 100, 190 150, 120 150, 120 190, 230 190, 
+      (230 0, 120 0, 120 50, 190 50, 120 100, 190 150, 120 150, 120 190, 230 190,
       230 0))
   </b>
 <test>
   <op name="symdifference" arg1="A" arg2="B">
     POLYGON(
-      (120 0, 0 0, 0 190, 120 190, 230 190, 230 0, 120 0), 
-      (120 100, 50 50, 120 50, 190 50, 120 100), 
+      (120 0, 0 0, 0 190, 120 190, 230 190, 230 0, 120 0),
+      (120 100, 50 50, 120 50, 190 50, 120 100),
       (120 100, 190 150, 120 150, 50 150, 120 100))
   </op>
 </test>
@@ -198,21 +198,21 @@
   <b>
     MULTIPOLYGON(
       (
-        (40 20, 0 0, 20 40, 60 60, 40 20)), 
+        (40 20, 0 0, 20 40, 60 60, 40 20)),
       (
-        (60 90, 60 60, 90 60, 90 90, 60 90)), 
+        (60 90, 60 60, 90 60, 90 90, 60 90)),
       (
-        (70 120, 90 90, 100 120, 70 120)), 
+        (70 120, 90 90, 100 120, 70 120)),
       (
         (120 70, 90 90, 120 100, 120 70)))
   </b>
 <test>
   <op name="symdifference" arg1="A" arg2="B">
     POLYGON(
-      (0 0, 0 230, 210 230, 210 0, 0 0), 
-      (0 0, 40 20, 60 60, 20 40, 0 0), 
-      (60 60, 90 60, 90 90, 60 90, 60 60), 
-      (90 90, 120 70, 120 100, 90 90), 
+      (0 0, 0 230, 210 230, 210 0, 0 0),
+      (0 0, 40 20, 60 60, 20 40, 0 0),
+      (60 60, 90 60, 90 90, 60 90, 60 60),
+      (90 90, 120 70, 120 100, 90 90),
       (90 90, 100 120, 70 120, 90 90))
   </op>
 </test>
@@ -227,7 +227,7 @@
   <b>
     MULTIPOLYGON(
       (
-        (40 20, 0 0, 20 40, 60 60, 40 20)), 
+        (40 20, 0 0, 20 40, 60 60, 40 20)),
       (
         (60 100, 60 60, 100 60, 100 100, 60 100)))
   </b>
@@ -235,7 +235,7 @@
   <op name="intersection" arg1="A" arg2="B">
     MULTIPOLYGON(
       (
-        (40 20, 0 0, 20 40, 60 60, 40 20)), 
+        (40 20, 0 0, 20 40, 60 60, 40 20)),
       (
         (60 60, 60 100, 100 100, 100 60, 60 60)))
   </op>
@@ -243,8 +243,8 @@
 <test>
   <op name="symdifference" arg1="A" arg2="B">
     POLYGON(
-      (0 0, 0 300, 340 300, 340 0, 0 0), 
-      (0 0, 40 20, 60 60, 20 40, 0 0), 
+      (0 0, 0 300, 340 300, 340 0, 0 0),
+      (0 0, 40 20, 60 60, 20 40, 0 0),
       (60 60, 100 60, 100 100, 60 100, 60 60))
   </op>
 </test>
@@ -259,7 +259,7 @@
   <b>
     MULTIPOLYGON(
       (
-        (60 20, 0 20, 60 60, 60 20)), 
+        (60 20, 0 20, 60 60, 60 20)),
       (
         (60 100, 60 60, 100 60, 100 100, 60 100)))
   </b>
@@ -267,7 +267,7 @@
   <op name="intersection" arg1="A" arg2="B">
     MULTIPOLYGON(
       (
-        (60 20, 0 20, 60 60, 60 20)), 
+        (60 20, 0 20, 60 60, 60 20)),
       (
         (60 60, 60 100, 100 100, 100 60, 60 60)))
   </op>
@@ -281,16 +281,16 @@
 <test>
   <op name="difference" arg1="A" arg2="B">
     POLYGON(
-      (0 20, 0 120, 120 120, 120 0, 0 0, 0 20), 
-      (0 20, 60 20, 60 60, 0 20), 
+      (0 20, 0 120, 120 120, 120 0, 0 0, 0 20),
+      (0 20, 60 20, 60 60, 0 20),
       (60 60, 100 60, 100 100, 60 100, 60 60))
   </op>
 </test>
 <test>
   <op name="symdifference" arg1="A" arg2="B">
     POLYGON(
-      (0 20, 0 120, 120 120, 120 0, 0 0, 0 20), 
-      (0 20, 60 20, 60 60, 0 20), 
+      (0 20, 0 120, 120 120, 120 0, 0 0, 0 20),
+      (0 20, 60 20, 60 60, 0 20),
       (60 60, 100 60, 100 100, 60 100, 60 60))
   </op>
 </test>
@@ -300,18 +300,18 @@
   <desc>AA - simple polygons with holes</desc>
   <a>
     POLYGON(
-      (160 330, 60 260, 20 150, 60 40, 190 20, 270 130, 260 250, 160 330), 
+      (160 330, 60 260, 20 150, 60 40, 190 20, 270 130, 260 250, 160 330),
       (140 240, 80 190, 90 100, 160 70, 210 130, 210 210, 140 240))
   </a>
   <b>
     POLYGON(
-      (300 330, 190 270, 150 170, 150 110, 250 30, 380 50, 380 250, 300 330), 
+      (300 330, 190 270, 150 170, 150 110, 250 30, 380 50, 380 250, 300 330),
       (290 240, 240 200, 240 110, 290 80, 330 170, 290 240))
   </b>
 <test>
   <op name="intersection" arg1="A" arg2="B">
     POLYGON(
-      (251 104, 217 57, 176 89, 210 130, 210 210, 172 226, 190 270, 217 285, 260 250, 
+      (251 104, 217 57, 176 89, 210 130, 210 210, 172 226, 190 270, 217 285, 260 250,
       263 218, 240 200, 240 110, 251 104))
   </op>
 </test>
@@ -319,13 +319,13 @@
   <op name="symdifference" arg1="A" arg2="B">
     MULTIPOLYGON(
       (
-        (217 57, 190 20, 60 40, 20 150, 60 260, 160 330, 217 285, 190 270, 172 226, 
-        140 240, 80 190, 90 100, 160 70, 176 89, 217 57)), 
+        (217 57, 190 20, 60 40, 20 150, 60 260, 160 330, 217 285, 190 270, 172 226,
+        140 240, 80 190, 90 100, 160 70, 176 89, 217 57)),
       (
-        (217 57, 251 104, 290 80, 330 170, 290 240, 263 218, 260 250, 217 285, 300 330, 
-        380 250, 380 50, 250 30, 217 57)), 
+        (217 57, 251 104, 290 80, 330 170, 290 240, 263 218, 260 250, 217 285, 300 330,
+        380 250, 380 50, 250 30, 217 57)),
       (
-        (263 218, 270 130, 251 104, 240 110, 240 200, 263 218)), 
+        (263 218, 270 130, 251 104, 240 110, 240 200, 263 218)),
       (
         (172 226, 210 210, 210 130, 176 89, 150 110, 150 170, 172 226)))
   </op>
@@ -338,12 +338,12 @@
     POLYGON ((20 0, 20 160, 200 160, 200 0, 20 0))
   </a>
   <b>
-    POLYGON ((220 80, 0 80, 0 240, 220 240, 220 80), 
+    POLYGON ((220 80, 0 80, 0 240, 220 240, 220 80),
   	(100 80, 120 120, 80 120, 100 80))
   </b>
 <test>
   <op name="intersection" arg1="A" arg2="B">
-    POLYGON ((20 80, 20 160, 200 160, 200 80, 100 80, 20 80), 
+    POLYGON ((20 80, 20 160, 200 160, 200 80, 100 80, 20 80),
   (100 80, 120 120, 80 120, 100 80))
   </op>
 </test>
@@ -354,14 +354,14 @@
 </test>
 <test>
   <op name="difference" arg1="A" arg2="B">
-    MULTIPOLYGON (((20 0, 20 80, 100 80, 200 80, 200 0, 20 0)), 
+    MULTIPOLYGON (((20 0, 20 80, 100 80, 200 80, 200 0, 20 0)),
   ((100 80, 80 120, 120 120, 100 80)))
   </op>
 </test>
 <test>
   <op name="symdifference" arg1="A" arg2="B">
-    MULTIPOLYGON (((20 0, 20 80, 100 80, 200 80, 200 0, 20 0)), 
-  ((200 80, 200 160, 20 160, 20 80, 0 80, 0 240, 220 240, 220 80, 200 80)), 
+    MULTIPOLYGON (((20 0, 20 80, 100 80, 200 80, 200 0, 20 0)),
+  ((200 80, 200 160, 20 160, 20 80, 0 80, 0 240, 220 240, 220 80, 200 80)),
   ((100 80, 80 120, 120 120, 100 80)))
   </op>
 </test>
@@ -372,29 +372,29 @@
   <a>
     MULTIPOLYGON(
       (
-        (120 340, 120 200, 140 200, 140 280, 160 280, 160 200, 180 200, 180 280, 200 280, 
-        200 200, 220 200, 220 340, 120 340)), 
+        (120 340, 120 200, 140 200, 140 280, 160 280, 160 200, 180 200, 180 280, 200 280,
+        200 200, 220 200, 220 340, 120 340)),
       (
-        (360 200, 220 200, 220 180, 300 180, 300 160, 220 160, 220 140, 300 140, 300 120, 
+        (360 200, 220 200, 220 180, 300 180, 300 160, 220 160, 220 140, 300 140, 300 120,
         220 120, 220 100, 360 100, 360 200)))
   </a>
   <b>
     MULTIPOLYGON(
       (
-        (100 220, 100 200, 300 200, 300 220, 100 220)), 
+        (100 220, 100 200, 300 200, 300 220, 100 220)),
       (
-        (280 180, 280 160, 300 160, 300 180, 280 180)), 
+        (280 180, 280 160, 300 160, 300 180, 280 180)),
       (
-        (220 140, 220 120, 240 120, 240 140, 220 140)), 
+        (220 140, 220 120, 240 120, 240 140, 220 140)),
       (
         (180 220, 160 240, 200 240, 180 220)))
   </b>
 <test>
   <op name="getboundary" arg1="A">
     MULTILINESTRING(
-      (120 340, 120 200, 140 200, 140 280, 160 280, 160 200, 180 200, 180 280, 200 280, 
-      200 200, 220 200, 220 340, 120 340), 
-      (360 200, 220 200, 220 180, 300 180, 300 160, 220 160, 220 140, 300 140, 300 120, 
+      (120 340, 120 200, 140 200, 140 280, 160 280, 160 200, 180 200, 180 280, 200 280,
+      200 200, 220 200, 220 340, 120 340),
+      (360 200, 220 200, 220 180, 300 180, 300 160, 220 160, 220 140, 300 140, 300 120,
       220 120, 220 100, 360 100, 360 200))
   </op>
 </test>
@@ -407,19 +407,19 @@
 <test>
   <op name="intersection" arg1="A" arg2="B">
     GEOMETRYCOLLECTION(
-      POINT(200 240), 
-      LINESTRING(300 200, 220 200), 
-      LINESTRING(280 180, 300 180), 
-      LINESTRING(300 180, 300 160), 
-      LINESTRING(300 160, 280 160), 
-      LINESTRING(220 140, 240 140), 
-      LINESTRING(240 120, 220 120), 
+      POINT(200 240),
+      LINESTRING(300 200, 220 200),
+      LINESTRING(280 180, 300 180),
+      LINESTRING(300 180, 300 160),
+      LINESTRING(300 160, 280 160),
+      LINESTRING(220 140, 240 140),
+      LINESTRING(240 120, 220 120),
       POLYGON(
-        (120 200, 120 220, 140 220, 140 200, 120 200)), 
+        (120 200, 120 220, 140 220, 140 200, 120 200)),
       POLYGON(
-        (160 200, 160 220, 180 220, 180 200, 160 200)), 
+        (160 200, 160 220, 180 220, 180 200, 160 200)),
       POLYGON(
-        (180 240, 180 220, 160 240, 180 240)), 
+        (180 240, 180 220, 160 240, 180 240)),
       POLYGON(
         (200 200, 200 220, 220 220, 220 200, 200 200)))
   </op>
@@ -427,12 +427,12 @@
 <test>
   <op name="union" arg1="A" arg2="B">
     POLYGON(
-      (120 220, 120 340, 220 340, 220 220, 300 220, 300 200, 360 200, 360 100, 220 100, 
-      220 120, 220 140, 220 160, 280 160, 280 180, 220 180, 220 200, 200 200, 180 200, 160 200, 
-      140 200, 120 200, 100 200, 100 220, 120 220), 
-      (200 240, 200 280, 180 280, 180 240, 200 240), 
-      (200 240, 180 220, 200 220, 200 240), 
-      (160 240, 160 280, 140 280, 140 220, 160 220, 160 240), 
+      (120 220, 120 340, 220 340, 220 220, 300 220, 300 200, 360 200, 360 100, 220 100,
+      220 120, 220 140, 220 160, 280 160, 280 180, 220 180, 220 200, 200 200, 180 200, 160 200,
+      140 200, 120 200, 100 200, 100 220, 120 220),
+      (200 240, 200 280, 180 280, 180 240, 200 240),
+      (200 240, 180 220, 200 220, 200 240),
+      (160 240, 160 280, 140 280, 140 220, 160 220, 160 240),
       (240 120, 300 120, 300 140, 240 140, 240 120))
   </op>
 </test>
@@ -440,12 +440,12 @@
   <op name="difference" arg1="A" arg2="B">
     MULTIPOLYGON(
       (
-        (120 220, 120 340, 220 340, 220 220, 200 220, 200 240, 200 280, 180 280, 180 240, 
-        160 240, 160 280, 140 280, 140 220, 120 220)), 
+        (120 220, 120 340, 220 340, 220 220, 200 220, 200 240, 200 280, 180 280, 180 240,
+        160 240, 160 280, 140 280, 140 220, 120 220)),
       (
-        (160 220, 160 240, 180 220, 160 220)), 
+        (160 220, 160 240, 180 220, 160 220)),
       (
-        (300 200, 360 200, 360 100, 220 100, 220 120, 240 120, 300 120, 300 140, 240 140, 
+        (300 200, 360 200, 360 100, 220 100, 220 120, 240 120, 300 120, 300 140, 240 140,
         220 140, 220 160, 280 160, 300 160, 300 180, 280 180, 220 180, 220 200, 300 200)))
   </op>
 </test>
@@ -453,21 +453,21 @@
   <op name="symdifference" arg1="A" arg2="B">
     MULTIPOLYGON(
       (
-        (120 220, 120 340, 220 340, 220 220, 200 220, 200 240, 200 280, 180 280, 180 240, 
-        160 240, 160 280, 140 280, 140 220, 120 220)), 
+        (120 220, 120 340, 220 340, 220 220, 200 220, 200 240, 200 280, 180 280, 180 240,
+        160 240, 160 280, 140 280, 140 220, 120 220)),
       (
-        (120 220, 120 200, 100 200, 100 220, 120 220)), 
+        (120 220, 120 200, 100 200, 100 220, 120 220)),
       (
-        (140 200, 140 220, 160 220, 160 200, 140 200)), 
+        (140 200, 140 220, 160 220, 160 200, 140 200)),
       (
-        (160 220, 160 240, 180 220, 160 220)), 
+        (160 220, 160 240, 180 220, 160 220)),
       (
-        (180 200, 180 220, 200 220, 200 200, 180 200)), 
+        (180 200, 180 220, 200 220, 200 200, 180 200)),
       (
-        (180 220, 180 240, 200 240, 180 220)), 
+        (180 220, 180 240, 200 240, 180 220)),
       (
-        (220 200, 220 220, 300 220, 300 200, 360 200, 360 100, 220 100, 220 120, 220 140, 
-        220 160, 280 160, 280 180, 220 180, 220 200), 
+        (220 200, 220 220, 300 220, 300 200, 360 200, 360 100, 220 100, 220 120, 220 140,
+        220 160, 280 160, 280 180, 220 180, 220 200),
         (240 120, 300 120, 300 140, 240 140, 240 120)))
   </op>
 </test>
@@ -478,31 +478,31 @@
   <a>
     MULTIPOLYGON(
       (
-        (100 200, 100 180, 120 180, 120 200, 100 200)), 
+        (100 200, 100 180, 120 180, 120 200, 100 200)),
       (
-        (60 240, 60 140, 220 140, 220 160, 160 160, 160 180, 200 180, 200 200, 160 200, 
-        160 220, 220 220, 220 240, 60 240), 
-        (80 220, 80 160, 140 160, 140 220, 80 220)), 
+        (60 240, 60 140, 220 140, 220 160, 160 160, 160 180, 200 180, 200 200, 160 200,
+        160 220, 220 220, 220 240, 60 240),
+        (80 220, 80 160, 140 160, 140 220, 80 220)),
       (
         (280 220, 240 180, 260 160, 300 200, 280 220)))
   </a>
   <b>
     MULTIPOLYGON(
       (
-        (80 220, 80 160, 140 160, 140 220, 80 220), 
-        (100 200, 100 180, 120 180, 120 200, 100 200)), 
+        (80 220, 80 160, 140 160, 140 220, 80 220),
+        (100 200, 100 180, 120 180, 120 200, 100 200)),
       (
-        (220 240, 220 220, 160 220, 160 200, 220 200, 220 180, 160 180, 160 160, 220 160, 
-        220 140, 320 140, 320 240, 220 240), 
+        (220 240, 220 220, 160 220, 160 200, 220 200, 220 180, 160 180, 160 160, 220 160,
+        220 140, 320 140, 320 240, 220 240),
         (240 220, 240 160, 300 160, 300 220, 240 220)))
   </b>
 <test>
   <op name="getboundary" arg1="A">
     MULTILINESTRING(
-      (100 200, 100 180, 120 180, 120 200, 100 200), 
-      (60 240, 60 140, 220 140, 220 160, 160 160, 160 180, 200 180, 200 200, 160 200, 
-      160 220, 220 220, 220 240, 60 240), 
-      (80 220, 80 160, 140 160, 140 220, 80 220), 
+      (100 200, 100 180, 120 180, 120 200, 100 200),
+      (60 240, 60 140, 220 140, 220 160, 160 160, 160 180, 200 180, 200 200, 160 200,
+      160 220, 220 220, 220 240, 60 240),
+      (80 220, 80 160, 140 160, 140 220, 80 220),
       (280 220, 240 180, 260 160, 300 200, 280 220))
   </op>
 </test>
@@ -515,25 +515,25 @@
 <test>
   <op name="intersection" arg1="A" arg2="B">
     GEOMETRYCOLLECTION(
-      POINT(240 180), 
-      POINT(260 160), 
-      POINT(280 220), 
-      POINT(300 200), 
-      LINESTRING(100 200, 100 180), 
-      LINESTRING(100 180, 120 180), 
-      LINESTRING(120 180, 120 200), 
-      LINESTRING(120 200, 100 200), 
-      LINESTRING(220 140, 220 160), 
-      LINESTRING(220 160, 160 160), 
-      LINESTRING(160 160, 160 180), 
-      LINESTRING(160 180, 200 180), 
-      LINESTRING(200 200, 160 200), 
-      LINESTRING(160 200, 160 220), 
-      LINESTRING(160 220, 220 220), 
-      LINESTRING(220 220, 220 240), 
-      LINESTRING(80 220, 80 160), 
-      LINESTRING(80 160, 140 160), 
-      LINESTRING(140 160, 140 220), 
+      POINT(240 180),
+      POINT(260 160),
+      POINT(280 220),
+      POINT(300 200),
+      LINESTRING(100 200, 100 180),
+      LINESTRING(100 180, 120 180),
+      LINESTRING(120 180, 120 200),
+      LINESTRING(120 200, 100 200),
+      LINESTRING(220 140, 220 160),
+      LINESTRING(220 160, 160 160),
+      LINESTRING(160 160, 160 180),
+      LINESTRING(160 180, 200 180),
+      LINESTRING(200 200, 160 200),
+      LINESTRING(160 200, 160 220),
+      LINESTRING(160 220, 220 220),
+      LINESTRING(220 220, 220 240),
+      LINESTRING(80 220, 80 160),
+      LINESTRING(80 160, 140 160),
+      LINESTRING(140 160, 140 220),
       LINESTRING(140 220, 80 220))
   </op>
 </test>
@@ -541,9 +541,9 @@
   <op name="union" arg1="A" arg2="B">
     MULTIPOLYGON(
       (
-        (220 140, 60 140, 60 240, 220 240, 320 240, 320 140, 220 140), 
-        (200 200, 200 180, 220 180, 220 200, 200 200), 
-        (240 220, 240 180, 240 160, 260 160, 300 160, 300 200, 300 220, 280 220, 240 220)), 
+        (220 140, 60 140, 60 240, 220 240, 320 240, 320 140, 220 140),
+        (200 200, 200 180, 220 180, 220 200, 200 200),
+        (240 220, 240 180, 240 160, 260 160, 300 160, 300 200, 300 220, 280 220, 240 220)),
       (
         (240 180, 280 220, 300 200, 260 160, 240 180)))
   </op>
@@ -552,11 +552,11 @@
   <op name="difference" arg1="A" arg2="B">
     MULTIPOLYGON(
       (
-        (100 180, 100 200, 120 200, 120 180, 100 180)), 
+        (100 180, 100 200, 120 200, 120 180, 100 180)),
       (
-        (220 140, 60 140, 60 240, 220 240, 220 220, 160 220, 160 200, 200 200, 200 180, 
-        160 180, 160 160, 220 160, 220 140), 
-        (80 220, 80 160, 140 160, 140 220, 80 220)), 
+        (220 140, 60 140, 60 240, 220 240, 220 220, 160 220, 160 200, 200 200, 200 180,
+        160 180, 160 160, 220 160, 220 140),
+        (80 220, 80 160, 140 160, 140 220, 80 220)),
       (
         (240 180, 280 220, 300 200, 260 160, 240 180)))
   </op>
@@ -565,9 +565,9 @@
   <op name="symdifference" arg1="A" arg2="B">
     MULTIPOLYGON(
       (
-        (220 140, 60 140, 60 240, 220 240, 320 240, 320 140, 220 140), 
-        (200 200, 200 180, 220 180, 220 200, 200 200), 
-        (240 220, 240 180, 240 160, 260 160, 300 160, 300 200, 300 220, 280 220, 240 220)), 
+        (220 140, 60 140, 60 240, 220 240, 320 240, 320 140, 220 140),
+        (200 200, 200 180, 220 180, 220 200, 200 200),
+        (240 220, 240 180, 240 160, 260 160, 300 160, 300 200, 300 220, 280 220, 240 220)),
       (
         (240 180, 280 220, 300 200, 260 160, 240 180)))
   </op>
@@ -582,7 +582,7 @@
   </a>
   <b>
     POLYGON(
-      (160 160, 100 160, 100 100, 160 100, 160 160), 
+      (160 160, 100 160, 100 100, 160 100, 160 160),
       (140 140, 120 140, 120 120, 140 120, 140 140))
   </b>
 <test>
@@ -599,7 +599,7 @@
 <test>
   <op name="intersection" arg1="A" arg2="B">
     GEOMETRYCOLLECTION(
-      LINESTRING(140 140, 140 120), 
+      LINESTRING(140 140, 140 120),
       POLYGON(
         (100 160, 140 160, 140 140, 120 140, 120 120, 140 120, 140 100, 100 100, 100 160)))
   </op>
@@ -614,7 +614,7 @@
   <op name="difference" arg1="A" arg2="B">
     MULTIPOLYGON(
       (
-        (60 160, 100 160, 100 100, 140 100, 140 60, 60 60, 60 160)), 
+        (60 160, 100 160, 100 100, 140 100, 140 60, 60 60, 60 160)),
       (
         (140 140, 140 120, 120 120, 120 140, 140 140)))
   </op>
@@ -623,11 +623,42 @@
   <op name="symdifference" arg1="A" arg2="B">
     MULTIPOLYGON(
       (
-        (60 160, 100 160, 100 100, 140 100, 140 60, 60 60, 60 160)), 
+        (60 160, 100 160, 100 100, 140 100, 140 60, 60 60, 60 160)),
       (
         (140 140, 140 160, 160 160, 160 100, 140 100, 140 120, 120 120, 120 140, 140 140)))
   </op>
 </test>
 </case>
 
+<case>
+  <desc>AA - Polygons which stress hole assignment</desc>
+  <a>
+POLYGON ((0 0, 4 0, 4 4, 0 4, 0 0), (1 1, 1 2, 2 1, 1 1), (1 2, 1 3, 2 3, 1 2), (2 3, 3 3, 3 2, 2 3))
+  </a>
+  <b>
+POLYGON ((2 1, 3 1, 3 2, 2 1))
+  </b>
+<test>
+  <op name="intersection" arg1="A" arg2="B">
+POLYGON ((3 2, 3 1, 2 1, 3 2))
+  </op>
+</test>
+<test>
+  <op name="union" arg1="A" arg2="B">
+POLYGON ((0 0, 0 4, 4 4, 4 0, 0 0), (1 2, 1 1, 2 1, 1 2), (1 2, 2 3, 1 3, 1 2), (2 3, 3 2, 3 3, 2 3))
+  </op>
+</test>
+<test>
+  <op name="difference" arg1="A" arg2="B">
+MULTIPOLYGON (((0 0, 0 4, 4 4, 4 0, 0 0), (1 2, 1 1, 2 1, 3 1, 3 2, 3 3, 2 3, 1 3, 1 2)), ((2 1, 1 2, 2 3, 3 2, 2 1)))
+  </op>
+</test>
+<test>
+  <op name="symdifference" arg1="A" arg2="B">
+MULTIPOLYGON (((0 0, 0 4, 4 4, 4 0, 0 0), (1 2, 1 1, 2 1, 3 1, 3 2, 3 3, 2 3, 1 3, 1 2)), ((2 1, 1 2, 2 3, 3 2, 2 1)))
+  </op>
+</test>
+</case>
+
+
 </run>

-----------------------------------------------------------------------

Summary of changes:
 NEWS                                             |   1 +
 src/operation/overlay/PolygonBuilder.cpp         |  57 ++---
 tests/xmltester/tests/general/TestFunctionAA.xml | 297 +++++++++++++----------
 3 files changed, 195 insertions(+), 160 deletions(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list