[geos-commits] [SCM] GEOS branch 3.8 updated. a4631692706716576734d7779dfb7173ac197c9c

git at osgeo.org git at osgeo.org
Tue May 30 15:33:29 PDT 2023


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.8 has been updated
       via  a4631692706716576734d7779dfb7173ac197c9c (commit)
      from  09cca89f8617c3a3dbf5f330a7d15299a15be7bf (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 a4631692706716576734d7779dfb7173ac197c9c
Author: Mike Taves <mwtoews at gmail.com>
Date:   Wed May 31 09:54:35 2023 +1200

    GEOSClipByRect: Fix case with POINT EMPTY, add more tests (#913)

diff --git a/NEWS b/NEWS
index 93e08fa03..b2dfcc6d6 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,7 @@ Changes in 3.8.4
 
 - Bug fixes / improvements
   - Fix PreparedGeometry to avoid crashes with EMPTY elements in input (GH-678, Martin Davis)
+  - GEOSClipByRect: Fix case with POINT EMPTY (GH-913, Mike Taves)
 
 
 Changes in 3.8.3
diff --git a/src/operation/intersection/RectangleIntersection.cpp b/src/operation/intersection/RectangleIntersection.cpp
index 23febb66c..472663614 100644
--- a/src/operation/intersection/RectangleIntersection.cpp
+++ b/src/operation/intersection/RectangleIntersection.cpp
@@ -117,7 +117,7 @@ RectangleIntersection::clip_point(const geom::Point* g,
                                   RectangleIntersectionBuilder& parts,
                                   const Rectangle& rect)
 {
-    if(g == nullptr) {
+    if(g == nullptr || g->isEmpty()) {
         return;
     }
 
@@ -535,6 +535,10 @@ RectangleIntersection::clip_polygon(const geom::Polygon* g,
                                     const Rectangle& rect,
                                     bool keep_polygons)
 {
+    if(g == nullptr || g->isEmpty()) {
+        return;
+    }
+
     if(keep_polygons) {
         clip_polygon_to_polygons(g, parts, rect);
     }
diff --git a/tests/unit/capi/GEOSClipByRectTest.cpp b/tests/unit/capi/GEOSClipByRectTest.cpp
index e5358436e..7341e3dd5 100644
--- a/tests/unit/capi/GEOSClipByRectTest.cpp
+++ b/tests/unit/capi/GEOSClipByRectTest.cpp
@@ -200,5 +200,32 @@ template<> template<> void object::test<13>
     isEqual(geom2_, "POLYGON ((5 5, 5 15, 10 15, 10 10, 15 10, 15 5, 5 5))");
 }
 
+/// Empty combinations - always return GEOMETRYCOLLECTION EMPTY
+template<> template<> void object::test<14>
+()
+{
+    std::vector<const char*> variants{
+        "POINT EMPTY",
+        "LINESTRING EMPTY",
+        "POLYGON EMPTY",
+        "MULTIPOINT EMPTY",
+        "MULTILINESTRING EMPTY",
+        "MULTIPOLYGON EMPTY",
+        "GEOMETRYCOLLECTION EMPTY",
+        "LINEARRING EMPTY",
+    };
+    for (const auto& wkt : variants) {
+        GEOSGeom geom1 = GEOSGeomFromWKT(wkt);
+        GEOSGeom geom2 = GEOSClipByRect(geom1, 0, 0, 1, 1);
+        char* obt_wkt = GEOSWKTWriter_write(w_, geom2);
+        std::string obt_wkt2(obt_wkt);
+        GEOSFree(obt_wkt);
+        GEOSGeom_destroy(geom1);
+        GEOSGeom_destroy(geom2);
+        ensure_equals(obt_wkt2, "GEOMETRYCOLLECTION EMPTY");
+    }
+}
+
+
 } // namespace tut
 
diff --git a/tests/unit/operation/intersection/RectangleIntersectionTest.cpp b/tests/unit/operation/intersection/RectangleIntersectionTest.cpp
index 1aef16e1c..0dfb3b356 100644
--- a/tests/unit/operation/intersection/RectangleIntersectionTest.cpp
+++ b/tests/unit/operation/intersection/RectangleIntersectionTest.cpp
@@ -1678,4 +1678,27 @@ template<> template<> void object::test<208>
 
     doClipTest(inp, exp, r, 1e-20);
 }
+
+/// Empty combinations - always return GEOMETRYCOLLECTION EMPTY
+template<> template<> void object::test<209>
+()
+{
+    std::vector<const char*> variants{
+        "POINT EMPTY",
+        "LINESTRING EMPTY",
+        "POLYGON EMPTY",
+        "MULTIPOINT EMPTY",
+        "MULTILINESTRING EMPTY",
+        "MULTIPOLYGON EMPTY",
+        "GEOMETRYCOLLECTION EMPTY",
+        "LINEARRING EMPTY",
+    };
+    for (const auto& inp : variants) {
+        doClipTest(
+            inp,
+            "GEOMETRYCOLLECTION EMPTY",
+            Rectangle(0, 0, 1, 1)
+        );
+    }
+}
 }

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

Summary of changes:
 NEWS                                               |  1 +
 .../intersection/RectangleIntersection.cpp         |  6 ++++-
 tests/unit/capi/GEOSClipByRectTest.cpp             | 27 ++++++++++++++++++++++
 .../intersection/RectangleIntersectionTest.cpp     | 23 ++++++++++++++++++
 4 files changed, 56 insertions(+), 1 deletion(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list