[geos-commits] [SCM] GEOS branch main updated. 97a079ae411f116b946357ad5da234502417c578

git at osgeo.org git at osgeo.org
Tue Aug 20 15:08:51 PDT 2024


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  97a079ae411f116b946357ad5da234502417c578 (commit)
       via  792084ee015c7e19671ccdc941e17f9fd4fee419 (commit)
      from  ee1cce91c9e7500af1a5eb8a56e66e6b9dd6db32 (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 97a079ae411f116b946357ad5da234502417c578
Merge: 792084ee0 ee1cce91c
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Tue Aug 20 15:08:11 2024 -0700

    Merge branch 'main' of github.com:libgeos/geos


commit 792084ee015c7e19671ccdc941e17f9fd4fee419
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Tue Aug 20 15:07:05 2024 -0700

    Port JTS commit
    https://github.com/locationtech/jts/commit/28aa77d57957bb5cef311c0066a20bc3a1210312
    
    Fix GeometryCollection equals equivalent primitive with some shared boundaries.
    
    Closes GH-1148

diff --git a/include/geos/operation/relateng/RelateGeometry.h b/include/geos/operation/relateng/RelateGeometry.h
index e96a3b878..936c03be0 100644
--- a/include/geos/operation/relateng/RelateGeometry.h
+++ b/include/geos/operation/relateng/RelateGeometry.h
@@ -203,7 +203,23 @@ public:
 
     int locateWithDim(const CoordinateXY* pt);
 
-    bool isPointsOrPolygons() const;
+    /**
+     * Indicates whether the geometry requires self-noding
+     * for correct evaluation of specific spatial predicates.
+     * Self-noding is required for geometries which may self-cross
+     * - i.e. lines, and overlapping polygons in GeometryCollections.
+     * Self-noding is not required for polygonal geometries,
+     * since they can only touch at vertices.
+     * This ensures that the coordinates of nodes created by
+     * crossing segments are computed explicitly.
+     * This ensures that node locations match in situations
+     * where a self-crossing and mutual crossing occur at the same logical location.
+     * E.g. a self-crossing line tested against a single segment
+     * identical to one of the crossed segments.
+     *
+     * @return true if self-noding is required for this geometry
+     */
+    bool isSelfNodingRequired() const;
 
     /**
      * Tests whether the geometry has polygonal topology.
diff --git a/include/geos/operation/relateng/TopologyComputer.h b/include/geos/operation/relateng/TopologyComputer.h
index 00b204693..e0a474c38 100644
--- a/include/geos/operation/relateng/TopologyComputer.h
+++ b/include/geos/operation/relateng/TopologyComputer.h
@@ -157,8 +157,9 @@ public:
      * for correct evaluation of specific spatial predicates.
      * Self-noding is required for geometries which may self-cross
      * - i.e. lines, and overlapping polygons in GeometryCollections.
-     * Self-noding is not required for polygonal geometries.
-     * This ensures that the locations of nodes created by
+     * Self-noding is not required for polygonal geometries,
+     * since they can only touch at vertices.
+     * This ensures that the coordinates of nodes created by
      * crossing segments are computed explicitly.
      * This ensures that node locations match in situations
      * where a self-crossing and mutual crossing occur at the same logical location.
diff --git a/src/operation/relateng/RelateGeometry.cpp b/src/operation/relateng/RelateGeometry.cpp
index 8a9620053..9c3aa3e84 100644
--- a/src/operation/relateng/RelateGeometry.cpp
+++ b/src/operation/relateng/RelateGeometry.cpp
@@ -235,13 +235,20 @@ RelateGeometry::locateWithDim(const CoordinateXY* pt)
 
 /* public */
 bool
-RelateGeometry::isPointsOrPolygons() const
+RelateGeometry::isSelfNodingRequired() const
 {
     GeometryTypeId typeId = geom->getGeometryTypeId();
-    return typeId == GEOS_POINT
+    if (typeId == GEOS_POINT
         || typeId == GEOS_MULTIPOINT
         || typeId == GEOS_POLYGON
-        || typeId == GEOS_MULTIPOLYGON;
+        || typeId == GEOS_MULTIPOLYGON)
+    {
+         return false;
+     }
+    //-- GC with a single polygon does not need noding
+    if (hasAreas && geom->getNumGeometries() == 1)
+        return false;
+    return true;
 }
 
 
diff --git a/src/operation/relateng/TopologyComputer.cpp b/src/operation/relateng/TopologyComputer.cpp
index 6d6d11b16..006873a13 100644
--- a/src/operation/relateng/TopologyComputer.cpp
+++ b/src/operation/relateng/TopologyComputer.cpp
@@ -132,9 +132,8 @@ TopologyComputer::getDimension(bool isA) const
 bool
 TopologyComputer::isSelfNodingRequired() const
 {
-    //TODO: change to testing for lines or GC with > 1 polygon
-    if (geomA.isPointsOrPolygons()) return false;
-    if (geomB.isPointsOrPolygons()) return false;
+    if (geomA.isSelfNodingRequired()) return true;
+    if (geomB.isSelfNodingRequired()) return true;
     return predicate.requireSelfNoding();
 }
 
diff --git a/tests/unit/operation/relateng/RelateNGGCTest.cpp b/tests/unit/operation/relateng/RelateNGGCTest.cpp
index 5ca0bf8ff..f9b972096 100644
--- a/tests/unit/operation/relateng/RelateNGGCTest.cpp
+++ b/tests/unit/operation/relateng/RelateNGGCTest.cpp
@@ -311,5 +311,27 @@ void object::test<22> ()
 }
 
 
+// testPolygonContainingPointsInBoundary
+// https://github.com/libgeos/geos/issues/1148
+template<>
+template<>
+void object::test<23> ()
+{
+    std::string a = "POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0))";
+    std::string b = "GEOMETRYCOLLECTION (POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0)), MULTIPOINT ((0 2), (0 5)))";
+    checkEquals(a, b, true);
+}
+
+
+// testPolygonContainingLineInBoundary
+template<>
+template<>
+void object::test<24> ()
+{
+    std::string a = "POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0))";
+    std::string b = "GEOMETRYCOLLECTION (POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0)), LINESTRING (0 2, 0 5))";
+    checkEquals(a, b, true);
+}
+
 
 } // namespace tut

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

Summary of changes:
 include/geos/operation/relateng/RelateGeometry.h   | 18 +++++++++++++++++-
 include/geos/operation/relateng/TopologyComputer.h |  5 +++--
 src/operation/relateng/RelateGeometry.cpp          | 13 ++++++++++---
 src/operation/relateng/TopologyComputer.cpp        |  5 ++---
 tests/unit/operation/relateng/RelateNGGCTest.cpp   | 22 ++++++++++++++++++++++
 5 files changed, 54 insertions(+), 9 deletions(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list