[geos-commits] [SCM] GEOS branch main updated. 1bfc5b27493c552fd9a28823358a4c1f4c3b65f7

git at osgeo.org git at osgeo.org
Tue Jul 13 16:01:04 PDT 2021


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, main has been updated
       via  1bfc5b27493c552fd9a28823358a4c1f4c3b65f7 (commit)
      from  917aeecadaaa5db9e7361ecfef2bca7bb64c8ec9 (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 1bfc5b27493c552fd9a28823358a4c1f4c3b65f7
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Tue Jul 13 16:00:10 2021 -0700

    Port JTS https://github.com/locationtech/jts/pull/756 to match
    IsValidReason more closely to historic reasons for self-intersecting
    polygons.

diff --git a/src/operation/valid/PolygonIntersectionAnalyzer.cpp b/src/operation/valid/PolygonIntersectionAnalyzer.cpp
index fbdf35d..a8ebe83 100644
--- a/src/operation/valid/PolygonIntersectionAnalyzer.cpp
+++ b/src/operation/valid/PolygonIntersectionAnalyzer.cpp
@@ -68,6 +68,8 @@ PolygonIntersectionAnalyzer::findInvalidIntersection(
         return TopologyValidationError::oNoInvalidIntersection;
     }
 
+    bool isSameSegString = (ss0 == ss1);
+
     /**
      * Check for an intersection in the interior of both segments.
      * Collinear intersections by definition contain an interior intersection.
@@ -89,7 +91,6 @@ PolygonIntersectionAnalyzer::findInvalidIntersection(
      * (since they are not collinear).
      * This is valid.
      */
-    bool isSameSegString = ss0 == ss1;
     bool isAdjacentSegments = isSameSegString && isAdjacentInRing(ss0, segIndex0, segIndex1);
     // Assert: intersection is an endpoint of both segs
     if (isAdjacentSegments) return TopologyValidationError::oNoInvalidIntersection;
@@ -99,7 +100,7 @@ PolygonIntersectionAnalyzer::findInvalidIntersection(
      * So the intersection is invalid.
      */
     if (isSameSegString && ! isInvertedRingValid) {
-        return TopologyValidationError::eSelfIntersection;
+        return TopologyValidationError::eRingSelfIntersection;
     }
 
     /**
diff --git a/tests/unit/capi/GEOSisValidDetailTest.cpp b/tests/unit/capi/GEOSisValidDetailTest.cpp
index b342b17..20092ba 100644
--- a/tests/unit/capi/GEOSisValidDetailTest.cpp
+++ b/tests/unit/capi/GEOSisValidDetailTest.cpp
@@ -116,7 +116,7 @@ void object::test<4>
     geom1_ = GEOSGeomFromWKT("POLYGON((0 1, -10 10, 10 10, 0 1, 4 6, -4 6, 0 1))");
     int r = GEOSisValidDetail(geom1_, 0, &reason_, &loc_);
     ensure_equals(r, 0); // invalid
-    ensure_equals(std::string(reason_), std::string("Self-intersection"));
+    ensure_equals(std::string(reason_), std::string("Ring Self-intersection"));
     ensure_equals(toWKT(loc_), "POINT (0 1)");
 }
 
diff --git a/tests/unit/operation/valid/IsValidOpTest.cpp b/tests/unit/operation/valid/IsValidOpTest.cpp
index 30ae4d5..e68c88d 100644
--- a/tests/unit/operation/valid/IsValidOpTest.cpp
+++ b/tests/unit/operation/valid/IsValidOpTest.cpp
@@ -188,6 +188,16 @@ void object::test<8> ()
         "POLYGON ((10 90, 90 10, 90 90, 10 10, 10 90))");
 }
 
+// testInvalidPolygonInverted
+template<>
+template<>
+void object::test<22> ()
+{
+    checkInvalid(
+        TopologyValidationError::eRingSelfIntersection,
+        "POLYGON ((70 250, 40 500, 100 400, 70 250, 80 350, 60 350, 70 250))");
+}
+
 // testSimplePolygonHole
 template<>
 template<>
@@ -309,6 +319,58 @@ void object::test<21> ()
         "MULTIPOLYGON (((20 380, 420 380, 420 20, 20 20, 20 380), (220 340, 180 240, 60 200, 140 100, 340 60, 300 240, 220 340)), ((60 200, 340 60, 220 340, 60 200)))");
 }
 
+// testLineString
+template<>
+template<>
+void object::test<23> ()
+{
+    checkInvalid(
+        "LINESTRING(0 0, 0 0)");
+}
+
+// testLinearRingTriangle
+template<>
+template<>
+void object::test<24> ()
+{
+    checkValid(
+        "LINEARRING (100 100, 150 200, 200 100, 100 100)");
+}
+
+// testLinearRingSelfCrossing
+template<>
+template<>
+void object::test<25> ()
+{
+    checkInvalid(TopologyValidationError::eRingSelfIntersection,
+        "LINEARRING (150 100, 300 300, 100 300, 350 100, 150 100)");
+}
+
+// testLinearRingSelfCrossing2
+template<>
+template<>
+void object::test<26> ()
+{
+    checkInvalid(TopologyValidationError::eRingSelfIntersection,
+        "LINEARRING (0 0, 100 100, 100 0, 0 100, 0 0)");
+}
+
+//
+template<>
+template<>
+void object::test<27> ()
+{
+    checkInvalid(TopologyValidationError::eRingSelfIntersection,
+        "POLYGON ((70 250, 40 500, 100 400, 70 250, 80 350, 60 350, 70 250))");
+}
+
+template<>
+template<>
+void object::test<28> ()
+{
+    checkInvalid(TopologyValidationError::eSelfIntersection,
+        "POLYGON ((70 250, 70 500, 80 400, 40 400, 70 250))");
+}
 
 
 } // namespace tut

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

Summary of changes:
 .../valid/PolygonIntersectionAnalyzer.cpp          |  5 +-
 tests/unit/capi/GEOSisValidDetailTest.cpp          |  2 +-
 tests/unit/operation/valid/IsValidOpTest.cpp       | 62 ++++++++++++++++++++++
 3 files changed, 66 insertions(+), 3 deletions(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list