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

git at osgeo.org git at osgeo.org
Tue Jul 8 13:13:50 PDT 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  a7b98f56014ede6ecbeae43d2abef78b2a527871 (commit)
      from  34a1e547d4a016e482539c936bfe0a8ba49a9d54 (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 a7b98f56014ede6ecbeae43d2abef78b2a527871
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Tue Jul 8 13:13:31 2025 -0700

    Catch empty components of CompoundCurve in validation
    
    closes #1167

diff --git a/src/geom/CompoundCurve.cpp b/src/geom/CompoundCurve.cpp
index 740e7c5bc..9c01111b6 100644
--- a/src/geom/CompoundCurve.cpp
+++ b/src/geom/CompoundCurve.cpp
@@ -314,13 +314,19 @@ CompoundCurve::reverseImpl() const
 void
 CompoundCurve::validateConstruction() const
 {
+    for (std::size_t i = 0; i < curves.size(); i++) {
+        if (curves[i]->isEmpty()) {
+            std::ostringstream ss;
+            ss << "Section " << i << " of CompoundCurve is empty";
+            throw util::IllegalArgumentException(ss.str());
+        }
+    }
     for (std::size_t i = 1; i < curves.size(); i++) {
         const CoordinateXY& end = curves[i-1]->getCoordinatesRO()->back<CoordinateXY>();
         const CoordinateXY& start = curves[i]->getCoordinatesRO()->front<CoordinateXY>();
 
         if (start != end) {
             std::ostringstream ss;
-
             ss << "Sections of CompoundCurve are not contiguous: " <<
                    "curve " << (i-1) << " ends at " << end <<
                    " ; curve " << i << " begins at " << start;
diff --git a/tests/unit/geom/CompoundCurveTest.cpp b/tests/unit/geom/CompoundCurveTest.cpp
index 958cf109e..165c67338 100644
--- a/tests/unit/geom/CompoundCurveTest.cpp
+++ b/tests/unit/geom/CompoundCurveTest.cpp
@@ -322,11 +322,12 @@ void object::test<9>()
 
     curves.push_back(wktreader_.read<SimpleCurve>("LINESTRING (0 0, 1 2)"));
     curves.push_back(wktreader_.read<SimpleCurve>("CIRCULARSTRING (2 1, 3 3, 4 1)"));
+    ensure_THROW(factory_->createCompoundCurve(std::move(curves)), geos::util::IllegalArgumentException);
 
+    curves.clear();
+    curves.push_back(wktreader_.read<SimpleCurve>("LINESTRING (0 0, 1 2)"));
+    curves.push_back(wktreader_.read<SimpleCurve>("CIRCULARSTRING EMPTY"));
     ensure_THROW(factory_->createCompoundCurve(std::move(curves)), geos::util::IllegalArgumentException);
 }
 
 }
-
-
-

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

Summary of changes:
 src/geom/CompoundCurve.cpp            | 8 +++++++-
 tests/unit/geom/CompoundCurveTest.cpp | 7 ++++---
 2 files changed, 11 insertions(+), 4 deletions(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list