[geos-commits] [SCM] GEOS branch 3.7 updated. 609e764eb096c68ce75357e24e4be500576e4137

git at osgeo.org git at osgeo.org
Mon Jan 28 13:54:42 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  609e764eb096c68ce75357e24e4be500576e4137 (commit)
      from  35280712b63b7f43af80a771b0bb35c876655ab3 (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 609e764eb096c68ce75357e24e4be500576e4137
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Mon Jan 28 13:53:42 2019 -0800

    Invalid union result from valid polygon inputs
    References #838

diff --git a/NEWS b/NEWS
index 9efb73b..72fa921 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,7 @@ Changes in 3.7.2
   - 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)
+  - Invalid union result from valid polygon inputs (#838)
 
 
 
diff --git a/src/noding/SingleInteriorIntersectionFinder.cpp b/src/noding/SingleInteriorIntersectionFinder.cpp
index a7798a4..050f8b7 100644
--- a/src/noding/SingleInteriorIntersectionFinder.cpp
+++ b/src/noding/SingleInteriorIntersectionFinder.cpp
@@ -12,7 +12,7 @@
  *
  **********************************************************************
  *
- * Last port: noding/SingleInteriorIntersectionFinder.java rev. ??? (JTS-1.8)
+ * Last port: noding/SingleInteriorIntersectionFinder.java rev. 2019-01-28
  *
  **********************************************************************/
 
@@ -23,6 +23,38 @@
 
 using namespace geos::geom;
 
+
+namespace { // anonymous
+
+	/* private in JTS */
+	bool isEndInteriorIntersection(
+	        const Coordinate& p0, bool isEnd0,
+	        const Coordinate& p1, bool isEnd1)
+	{
+		if (isEnd0 && isEnd1) return false;
+		if (p0.equals2D(p1)) {
+			return true;
+		}
+		return false;
+	}
+
+	/* public in JTS */
+	bool isEndInteriorIntersection(
+	        const Coordinate& p00, const Coordinate& p01,
+	        const Coordinate& p10, const Coordinate& p11,
+	        bool isEnd00, bool isEnd01,
+	        bool isEnd10, bool isEnd11)
+	{
+		if (isEndInteriorIntersection(p00, isEnd00, p10, isEnd10)) return true;
+		if (isEndInteriorIntersection(p00, isEnd00, p11, isEnd11)) return true;
+		if (isEndInteriorIntersection(p01, isEnd01, p10, isEnd10)) return true;
+		if (isEndInteriorIntersection(p01, isEnd01, p11, isEnd11)) return true;
+		return false;
+	}
+
+} // anonymous namespace
+
+
 namespace geos {
 namespace noding { // geos.noding
 
@@ -46,22 +78,28 @@ SingleInteriorIntersectionFinder::processIntersections(
 	const Coordinate& p10 = e1->getCoordinate(segIndex1);
 	const Coordinate& p11 = e1->getCoordinate(segIndex1 + 1);
 
+	bool isEnd00 = segIndex0 == 0;
+	bool isEnd01 = segIndex0 + 2 == static_cast<int>(e0->size());
+	bool isEnd10 = segIndex1 == 0;
+	bool isEnd11 = segIndex1 + 2 == static_cast<int>(e1->size());
+
 	li.computeIntersection(p00, p01, p10, p11);
 //if (li.hasIntersection() && li.isProper()) Debug.println(li);
+	bool isProperInteriorInt = li.hasIntersection() &&
+	                           li.isInteriorIntersection();
+	bool isEndInteriorInt = (e0 != e1) && isEndInteriorIntersection(
+	         p00, p01, p10, p11, isEnd00, isEnd01, isEnd10, isEnd11);
 
-	if (li.hasIntersection())
-	{
-		if (li.isInteriorIntersection())
-		{
-			intSegments.resize(4);
-			intSegments[0] = p00;
-			intSegments[1] = p01;
-			intSegments[2] = p10;
-			intSegments[3] = p11;
-
-			interiorIntersection = li.getIntersection(0);
-		}
+	if (isProperInteriorInt || isEndInteriorInt) {
+		// found an intersection!
+		intSegments.resize(4);
+		intSegments[0] = p00;
+		intSegments[1] = p01;
+		intSegments[2] = p10;
+		intSegments[3] = p11;
+		interiorIntersection = li.getIntersection(0);
 	}
+
 }
 
 
diff --git a/tests/xmltester/CMakeLists.txt b/tests/xmltester/CMakeLists.txt
index 1eebe10..3021f4b 100644
--- a/tests/xmltester/CMakeLists.txt
+++ b/tests/xmltester/CMakeLists.txt
@@ -62,6 +62,7 @@ if(GEOS_ENABLE_TESTS)
     ${XMLTESTS_DIR}/ticket/bug188.xml
     ${XMLTESTS_DIR}/ticket/bug244.xml
     ${XMLTESTS_DIR}/ticket/bug275.xml
+    ${XMLTESTS_DIR}/ticket/bug838.xml
     ${XMLTESTS_DIR}/general/TestBoundary.xml
     ${XMLTESTS_DIR}/general/TestBuffer.xml
     ${XMLTESTS_DIR}/general/TestBufferMitredJoin.xml
diff --git a/tests/xmltester/Makefile.am b/tests/xmltester/Makefile.am
index b631260..c11ad2a 100644
--- a/tests/xmltester/Makefile.am
+++ b/tests/xmltester/Makefile.am
@@ -44,6 +44,7 @@ SAFE_XMLTESTS=$(srcdir)/tests/testLeaksBig.xml \
 	$(srcdir)/tests/ticket/bug615.xml \
 	$(srcdir)/tests/ticket/bug716.xml \
 	$(srcdir)/tests/ticket/bug837.xml \
+	$(srcdir)/tests/ticket/bug838.xml \
 	$(srcdir)/tests/general/TestBoundary.xml \
 	$(srcdir)/tests/general/TestBuffer.xml \
 	$(srcdir)/tests/general/TestBufferMitredJoin.xml \
diff --git a/tests/xmltester/tests/ticket/bug838.xml b/tests/xmltester/tests/ticket/bug838.xml
new file mode 100644
index 0000000..1d21cd0
--- /dev/null
+++ b/tests/xmltester/tests/ticket/bug838.xml
@@ -0,0 +1,20 @@
+<run>
+<precisionModel type="FLOATING" />
+<case>
+<desc>
+Union of two valid polygons resulting in an invalid geometry
+See https://trac.osgeo.org/geos/ticket/838
+</desc>
+<a>
+00000000060000000200000000030000000100000005412CD75B00000000413D8F0966666667412CD75933333333413D8F6D80000000412CD82166666667413D8F6E4CCCCCCD412CD82500000000413D8EA61999999A412CD75B00000000413D8F096666666700000000030000000100000005412CD82500000001413D8EA61999999A412CD82333333334413D8F0A33333333412CD8EB66666666413D8F0B19999999412CD8ED33333333413D8EA700000001412CD82500000001413D8EA61999999A
+</a>
+<b>
+00000000030000000100000007412CD9D4D50CE8F7413D8EA7FBC39C12412CD8ED33333333413D8EA700000000412CD8EB66666667413D8F0B1999999A412CD82333333333413D8F0A33333333412CD82166666667413D8F6E4CCCCCCD412CD9B1CCCCCCCD413D8F701999999A412CD9D4D50CE8F7413D8EA7FBC39C12
+</b>
+<test>
+  <op name="union" arg1="A" arg2="B">
+0103000000010000000A000000000000005BD72C4167666666098F3D413333333359D72C41000000806D8F3D416766666621D82C41CDCCCC4C6E8F3D41CDCCCCCCB1D92C419A999919708F3D41F7E80CD5D4D92C41129CC3FBA78E3D4133333333EDD82C4100000000A78E3D410100000025D82C419A999919A68E3D413333333323D82C41333333330A8F3D410000000025D82C419A999919A68E3D41000000005BD72C4167666666098F3D41
+  </op>
+</test>
+</case>
+</run>

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

Summary of changes:
 NEWS                                            |  1 +
 src/noding/SingleInteriorIntersectionFinder.cpp | 64 ++++++++++++++++++++-----
 tests/xmltester/CMakeLists.txt                  |  1 +
 tests/xmltester/Makefile.am                     |  1 +
 tests/xmltester/tests/ticket/bug838.xml         | 20 ++++++++
 5 files changed, 74 insertions(+), 13 deletions(-)
 create mode 100644 tests/xmltester/tests/ticket/bug838.xml


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list