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

git at osgeo.org git at osgeo.org
Wed Dec 10 11:15:03 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  f175f9af82fd0c4ab2d913205ff8480b7a12a055 (commit)
       via  bfa9cd118979a46de25a2355fd0b9973c476691a (commit)
      from  ad73047bf08756f0786c920358059fe3b9c5fa02 (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 f175f9af82fd0c4ab2d913205ff8480b7a12a055
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Wed Dec 10 11:13:59 2025 -0800

    Quiet FP_DIVBYZERO exception from CGAlgorithmsDD::intersection showing in downstream libraries, closes #1235

diff --git a/include/geos/math/DD.h b/include/geos/math/DD.h
index 7be00a6f7..83b26f6a3 100644
--- a/include/geos/math/DD.h
+++ b/include/geos/math/DD.h
@@ -114,6 +114,7 @@ class GEOS_DLL DD {
         int signum() const;
         DD rint() const;
 
+        void setNaN();
 
     public:
         DD(double p_hi, double p_lo) : hi(p_hi), lo(p_lo) {};
@@ -166,6 +167,7 @@ class GEOS_DLL DD {
         static DD pow(const DD &d, int exp);
         static DD trunc(const DD &d);
 
+        bool isInf() const;
         bool isNaN() const;
         bool isNegative() const;
         bool isPositive() const;
diff --git a/src/algorithm/CGAlgorithmsDD.cpp b/src/algorithm/CGAlgorithmsDD.cpp
index 0d61b335e..df6fd0112 100644
--- a/src/algorithm/CGAlgorithmsDD.cpp
+++ b/src/algorithm/CGAlgorithmsDD.cpp
@@ -139,19 +139,12 @@ CGAlgorithmsDD::intersection(const CoordinateXY& p1, const CoordinateXY& p2,
     DD y = (qx * pw) - (px * qw);
     DD w = (px * qy) - (qx * py);
 
+    if (w.isZero())
+        return CoordinateXY::getNull();
+
     double xInt = (x / w).ToDouble();
     double yInt = (y / w).ToDouble();
-
-    Coordinate rv;
-
-    if (!std::isfinite(xInt) || !std::isfinite(yInt)) {
-        rv.setNull();
-        return rv;
-    }
-
-    rv.x = xInt;
-    rv.y = yInt;
-    return rv;
+    return {xInt, yInt};
 }
 
 /* public static */
diff --git a/src/math/DD.cpp b/src/math/DD.cpp
index 662f1f1d3..e158dc685 100644
--- a/src/math/DD.cpp
+++ b/src/math/DD.cpp
@@ -20,8 +20,16 @@
 namespace geos {
 namespace math { // geos.util
 
-
-
+/* private */
+void DD::setNaN()
+{
+    hi = std::numeric_limits<double>::quiet_NaN();
+}
+/* public */
+bool DD::isInf() const
+{
+    return std::isinf(hi);
+}
 /* public */
 bool DD::isNaN() const
 {
@@ -351,6 +359,7 @@ DD DD::determinant(double x1, double y1, double x2, double y2)
     return determinant(DD(x1), DD(y1), DD(x2), DD(y2) );
 }
 
+
 /**
 * Computes the value of this number raised to an integral power.
 * Follows semantics of Java Math.pow as closely as possible.
diff --git a/tests/unit/algorithm/MinimumAreaRectangleTest.cpp b/tests/unit/algorithm/MinimumAreaRectangleTest.cpp
index a36723bb8..55cf17826 100644
--- a/tests/unit/algorithm/MinimumAreaRectangleTest.cpp
+++ b/tests/unit/algorithm/MinimumAreaRectangleTest.cpp
@@ -147,35 +147,37 @@ template<>
 template<>
 void object::test<10>()
 {
-    // bool error = false;
-    // try {
-        checkMinRectangle(
-            "LINESTRING(-99.48710639268086 34.79029839231914,-99.48370699999998 34.78689899963806,-99.48152167568102 34.784713675318976)",
-            "POLYGON ((-99.48710639268066 34.790298392318675, -99.48710639268066 34.790298392318675, -99.48152167568082 34.78471367531866, -99.48152167568082 34.78471367531866, -99.48710639268066 34.790298392318675))");
-    // } catch (std::exception& e) {
-    //     error = true;
-    //     // errorMessage = e.what();
-    // }
-    // ensure("caught exception", error == true);
+    checkMinRectangle(
+        "LINESTRING(-99.48710639268086 34.79029839231914,-99.48370699999998 34.78689899963806,-99.48152167568102 34.784713675318976)",
+        "POLYGON ((-99.48710639268066 34.790298392318675, -99.48710639268066 34.790298392318675, -99.48152167568082 34.78471367531866, -99.48152167568082 34.78471367531866, -99.48710639268066 34.790298392318675))");
 }
 
+
 // testBadRectl
 template<>
 template<>
 void object::test<11>()
 {
-    // bool error = false;
-    // try {
     checkMinRectangle(
         "POLYGON ((-5.21175 49.944633, -5.77435 50.021367, -5.7997 50.0306, -5.81815 50.0513, -5.82625 50.073567, -5.83085 50.1173, -6.2741 56.758767, -5.93245 57.909, -5.1158 58.644533, -5.07915 58.661733, -3.42575 58.686633, -3.1392 58.6685, -3.12495 58.666233, -1.88745 57.6444, 1.68845 52.715133, 1.7057 52.6829, 1.70915 52.6522, 1.7034 52.585433, 1.3867 51.214033, 1.36595 51.190267, 1.30485 51.121967, 0.96365 50.928567, 0.93025 50.912433, 0.1925 50.7436, -5.21175 49.944633))",
         "POLYGON ((1.8583607388069103 50.41649058582797, -5.816631979932251 49.904263313964535, -6.395241388167441 58.57389735949991, 1.2797513305717105 59.08612463136336, 1.8583607388069103 50.41649058582797))");
-    // } catch (std::exception& e) {
-    //     error = true;
-    //     // errorMessage = e.what();
-    // }
-    // ensure("caught exception", error == true);
 }
 
 
+// https://github.com/libgeos/geos/issues/1235
+// throwing FE_DIVBYZERO
+template<>
+template<>
+void object::test<12>()
+{
+    checkMinRectangle(
+        "POLYGON ((-100 -100, -100 100, 100 100, 100 -100, -100 -100))",
+        "POLYGON ((-100 -100, -100 100, 100 100, 100 -100, -100 -100))");
+}
+
+
+
+
+
 } // namespace tut
 
diff --git a/tests/unit/geos_unit.cpp b/tests/unit/geos_unit.cpp
index 9526b009e..cbd1a86cc 100644
--- a/tests/unit/geos_unit.cpp
+++ b/tests/unit/geos_unit.cpp
@@ -50,7 +50,7 @@ usage()
          << "  " << module << " geos::geom::Envelope\n"
          << "  " << module << " geos::geom::Envelope 2\n"
          << endl
-         << "GEOS homepage: http://geos.osgeo.org" << endl;
+         << "GEOS homepage: https://libgeos.org" << endl;
 }
 
 int

commit bfa9cd118979a46de25a2355fd0b9973c476691a
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Wed Dec 10 10:49:16 2025 -0800

    Use nameless catch for exceptions that do not use exception var

diff --git a/src/linearref/LinearGeometryBuilder.cpp b/src/linearref/LinearGeometryBuilder.cpp
index 445f2d70d..947747ba8 100644
--- a/src/linearref/LinearGeometryBuilder.cpp
+++ b/src/linearref/LinearGeometryBuilder.cpp
@@ -117,10 +117,9 @@ LinearGeometryBuilder::endLine()
     try {
         line = geomFact->createLineString(std::move(coordList));
     }
-    catch(util::IllegalArgumentException & ex) {
+    catch(util::IllegalArgumentException &) {
         // exception is due to too few points in line.
         // only propagate if not ignoring short lines
-        ::geos::ignore_unused_variable_warning(ex);
         if(! ignoreInvalidLines) {
             throw;
         }
diff --git a/src/operation/union/CascadedPolygonUnion.cpp b/src/operation/union/CascadedPolygonUnion.cpp
index 82cd91bcc..35a93b0e9 100644
--- a/src/operation/union/CascadedPolygonUnion.cpp
+++ b/src/operation/union/CascadedPolygonUnion.cpp
@@ -204,8 +204,7 @@ ClassicUnionStrategy::Union(const geom::Geometry* g0, const geom::Geometry* g1)
     try {
         return operation::overlayng::OverlayNGRobust::Overlay(g0, g1, operation::overlayng::OverlayNG::UNION);
     }
-    catch (const util::TopologyException &ex) {
-        ::geos::ignore_unused_variable_warning(ex);
+    catch (const util::TopologyException &) {
         // union-by-buffer only works for polygons
         if (g0->getDimension() != 2 || g1->getDimension() != 2)
           throw;
diff --git a/tests/unit/algorithm/construct/MaximumInscribedCircleTest.cpp b/tests/unit/algorithm/construct/MaximumInscribedCircleTest.cpp
index e7e917509..f17568ef7 100644
--- a/tests/unit/algorithm/construct/MaximumInscribedCircleTest.cpp
+++ b/tests/unit/algorithm/construct/MaximumInscribedCircleTest.cpp
@@ -202,16 +202,15 @@ void object::test<8> ()
     try {
         MaximumInscribedCircle mic(g1.get(), 1);
         mic.getCenter();
-    } catch (const util::GEOSException & e) {
-        ::geos::ignore_unused_variable_warning(e);
+    } catch (const util::GEOSException &) {
     }
 
     auto g2 = reader_.read("POLYGON ((0 0, 1 0, 2 NaN,  0 0))");
     try {
         MaximumInscribedCircle mic(g1.get(), 1);
         mic.getCenter();
-    } catch (const util::GEOSException & e) {
-        ::geos::ignore_unused_variable_warning(e);
+    }
+    catch (const util::GEOSException &) {
     }
 }
 
diff --git a/tests/unit/algorithm/distance/DiscreteFrechetDistanceTest.cpp b/tests/unit/algorithm/distance/DiscreteFrechetDistanceTest.cpp
index 86472ac06..b98c8f8d5 100644
--- a/tests/unit/algorithm/distance/DiscreteFrechetDistanceTest.cpp
+++ b/tests/unit/algorithm/distance/DiscreteFrechetDistanceTest.cpp
@@ -76,27 +76,24 @@ void object::test<1> ()
     try {
         checkDensifiedFrechet("LINESTRING (0 0, 2 1)", "LINESTRING EMPTY", 0.0, 0);
     }
-    catch(const geos::util::IllegalArgumentException& e) {
+    catch(const geos::util::IllegalArgumentException &) {
         // We do expect an exception
-        ::geos::ignore_unused_variable_warning(e);
     }
 
     // too big densify factor
     try {
         checkDensifiedFrechet("LINESTRING (0 0, 2 1)", "LINESTRING EMPTY", 1 + 1e-10, 0);
     }
-    catch(const geos::util::IllegalArgumentException& e) {
+    catch(const geos::util::IllegalArgumentException &) {
         // We do expect an exception
-        ::geos::ignore_unused_variable_warning(e);
     }
 
     // too small positive densify factor
     try {
         checkDensifiedFrechet("LINESTRING (0 0, 2 1)", "LINESTRING EMPTY", 1e-30, 0);
     }
-    catch(const geos::util::IllegalArgumentException& e) {
+    catch(const geos::util::IllegalArgumentException &) {
         // We do expect an exception
-        ::geos::ignore_unused_variable_warning(e);
     }
 }
 
diff --git a/tests/unit/operation/overlayng/CoverageUnionNGTest.cpp b/tests/unit/operation/overlayng/CoverageUnionNGTest.cpp
index 66865b349..01095d0f5 100644
--- a/tests/unit/operation/overlayng/CoverageUnionNGTest.cpp
+++ b/tests/unit/operation/overlayng/CoverageUnionNGTest.cpp
@@ -46,8 +46,7 @@ struct test_coverageunionng_data {
 
         try {
             ensure_equals_geometry_xyzm(result.get(), expected.get());
-        } catch (const std::exception& e) {
-            ::geos::ignore_unused_variable_warning(e);
+        } catch (const std::exception &) {
             std::string wkt_result = w.write(result.get());
             std::cerr << std::endl << wkt_result << std::endl;
             throw;
diff --git a/tests/unit/triangulate/VoronoiTest.cpp b/tests/unit/triangulate/VoronoiTest.cpp
index dd9066a95..e1ffaf6ee 100644
--- a/tests/unit/triangulate/VoronoiTest.cpp
+++ b/tests/unit/triangulate/VoronoiTest.cpp
@@ -323,8 +323,7 @@ void object::test<14>
     try {
         runVoronoi(wkt, "", 0, false, true);
         fail();
-    } catch (const geos::util::GEOSException & e) {
-        ::geos::ignore_unused_variable_warning(e);
+    } catch (const geos::util::GEOSException &) {
     }
 }
 

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

Summary of changes:
 include/geos/math/DD.h                             |  2 ++
 src/algorithm/CGAlgorithmsDD.cpp                   | 15 +++------
 src/linearref/LinearGeometryBuilder.cpp            |  3 +-
 src/math/DD.cpp                                    | 13 ++++++--
 src/operation/union/CascadedPolygonUnion.cpp       |  3 +-
 tests/unit/algorithm/MinimumAreaRectangleTest.cpp  | 36 ++++++++++++----------
 .../construct/MaximumInscribedCircleTest.cpp       |  7 ++---
 .../distance/DiscreteFrechetDistanceTest.cpp       |  9 ++----
 tests/unit/geos_unit.cpp                           |  2 +-
 .../operation/overlayng/CoverageUnionNGTest.cpp    |  3 +-
 tests/unit/triangulate/VoronoiTest.cpp             |  3 +-
 11 files changed, 47 insertions(+), 49 deletions(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list