[geos-commits] [SCM] GEOS branch main updated. f74855c5a6ae36dcf31c1fd43ffca60350fbaf3c

git at osgeo.org git at osgeo.org
Tue Jan 14 16:17:53 PST 2025


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  f74855c5a6ae36dcf31c1fd43ffca60350fbaf3c (commit)
      from  0bae66a5d626ab08f12941a5b9127bf40534f5e0 (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 f74855c5a6ae36dcf31c1fd43ffca60350fbaf3c
Author: Mike Taves <mwtoews at gmail.com>
Date:   Wed Jan 15 13:17:31 2025 +1300

    Fix invalid values from CoverageUnionNG (#1226)

diff --git a/src/operation/overlayng/CoverageUnion.cpp b/src/operation/overlayng/CoverageUnion.cpp
index c0c8a1458..3d860c92a 100644
--- a/src/operation/overlayng/CoverageUnion.cpp
+++ b/src/operation/overlayng/CoverageUnion.cpp
@@ -33,7 +33,6 @@ namespace overlayng { // geos.operation.overlayng
 std::unique_ptr<Geometry>
 CoverageUnion::geomunion(const Geometry* coverage)
 {
-    double area_in = coverage->getArea();
     std::unique_ptr<Geometry> result;
 
     // a precision model is not needed since no noding is done
@@ -47,9 +46,10 @@ CoverageUnion::geomunion(const Geometry* coverage)
         result = OverlayNG::geomunion(coverage, nullptr, &bcn);
     }
 
-    double area_out = result->getArea();
+    double area_in = coverage->getArea();
 
-    if (std::abs((area_out - area_in)/area_in) > AREA_PCT_DIFF_TOL) {
+    if ( (area_in != 0.0) &&
+         (std::abs((result->getArea() - area_in)/area_in) > AREA_PCT_DIFF_TOL)) {
         throw geos::util::TopologyException("CoverageUnion cannot process overlapping inputs.");
     }
 
diff --git a/tests/unit/operation/overlayng/CoverageUnionNGTest.cpp b/tests/unit/operation/overlayng/CoverageUnionNGTest.cpp
index c6ca01fbc..d21f960dd 100644
--- a/tests/unit/operation/overlayng/CoverageUnionNGTest.cpp
+++ b/tests/unit/operation/overlayng/CoverageUnionNGTest.cpp
@@ -9,6 +9,7 @@
 #include <geos/util.h>
 
 // std
+#include <cfenv>
 #include <memory>
 
 using namespace geos::geom;
@@ -32,7 +33,9 @@ struct test_coverageunionng_data {
     {
         std::unique_ptr<Geometry> geom = r.read(wkt);
         std::unique_ptr<Geometry> expected = r.read(wktExpected);
+        std::feclearexcept(FE_ALL_EXCEPT);
         std::unique_ptr<Geometry> result = CoverageUnion::geomunion(geom.get());
+        ensure("FE_INVALID raised", !std::fetestexcept(FE_INVALID));
 
         try {
             ensure_equals_geometry_xyzm(result.get(), expected.get());
@@ -222,4 +225,31 @@ void object::test<17>()
                "POLYGON M ((0 0 0, 1 0 1, 1 1 2, 0 1 3, 0 0 0))");
 }
 
+// Check empty polygon
+template<>
+template<>
+void object::test<18>()
+{
+    checkUnion("POLYGON EMPTY",
+               "POLYGON EMPTY");
+}
+
+// Check empty GeometryCollection, with M dimension
+template<>
+template<>
+void object::test<19>()
+{
+    checkUnion("GEOMETRYCOLLECTION M EMPTY",
+               "GEOMETRYCOLLECTION M EMPTY");
+}
+
+// Check GeometryCollection of empty polygon
+template<>
+template<>
+void object::test<20>()
+{
+    checkUnion("GEOMETRYCOLLECTION( POLYGON EMPTY )",
+               "POLYGON EMPTY");
+}
+
 } // namespace tut

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

Summary of changes:
 src/operation/overlayng/CoverageUnion.cpp          |  6 ++---
 .../operation/overlayng/CoverageUnionNGTest.cpp    | 30 ++++++++++++++++++++++
 2 files changed, 33 insertions(+), 3 deletions(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list