[geos-commits] [SCM] GEOS branch 3.13 updated. cd28a08b0554dd9156856458b2f3123bbb8ba41c

git at osgeo.org git at osgeo.org
Wed Dec 10 11:18:55 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, 3.13 has been updated
       via  cd28a08b0554dd9156856458b2f3123bbb8ba41c (commit)
       via  89546095ea121ac948b46b2f2795e2d0fbf8bf82 (commit)
      from  28f2e42a6c40910fda9f08fddec28f43c148583b (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 cd28a08b0554dd9156856458b2f3123bbb8ba41c
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Wed Dec 10 11:18:02 2025 -0800

    Update NEWS

diff --git a/NEWS.md b/NEWS.md
index 5bcee20e8..d413c6c81 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -8,6 +8,7 @@
   - Fix DepthSegment comparison logic (really this time) (GH-1266, Martin Davis)
   - Change CoverageGapFinder to return polygons (Martin Davis)
   - Fix incorrect envelope calculation for arcs (GH-1314, Dan Baston)
+  - Quiet FP_DIVBYZERO exception from CGAlgorithmsDD::intersection (GH-1235, Paul Ramsey)
 
 ## Changes in 3.13.1
 2025-03-03

commit 89546095ea121ac948b46b2f2795e2d0fbf8bf82
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 61e3a08a7..764801251 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) {};
@@ -165,6 +166,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 ccfef602e..1526d3754 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 c620c1b62..86d284a11 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
 {
@@ -346,6 +354,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 dad960837..506ecea7f 100644
--- a/tests/unit/algorithm/MinimumAreaRectangleTest.cpp
+++ b/tests/unit/algorithm/MinimumAreaRectangleTest.cpp
@@ -148,35 +148,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 8e008c8b2..a3a78236f 100644
--- a/tests/unit/geos_unit.cpp
+++ b/tests/unit/geos_unit.cpp
@@ -49,7 +49,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

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

Summary of changes:
 NEWS.md                                           |  1 +
 include/geos/math/DD.h                            |  2 ++
 src/algorithm/CGAlgorithmsDD.cpp                  | 15 +++-------
 src/math/DD.cpp                                   | 13 ++++++--
 tests/unit/algorithm/MinimumAreaRectangleTest.cpp | 36 ++++++++++++-----------
 tests/unit/geos_unit.cpp                          |  2 +-
 6 files changed, 38 insertions(+), 31 deletions(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list