[geos-commits] [SCM] GEOS branch main updated. c1a3d838ced34c29f2d4ba9982dbde31f79b2a05
git at osgeo.org
git at osgeo.org
Fri Mar 14 14:18:11 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 c1a3d838ced34c29f2d4ba9982dbde31f79b2a05 (commit)
from f1519c182497a99db8315ef78e0ae283b0469008 (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 c1a3d838ced34c29f2d4ba9982dbde31f79b2a05
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date: Fri Mar 14 14:04:20 2025 -0700
Fix GeometryCollections in coverageSimplify result in segfaults, #1250
diff --git a/src/coverage/CoverageSimplifier.cpp b/src/coverage/CoverageSimplifier.cpp
index dbbd9022a..98ba1ad87 100644
--- a/src/coverage/CoverageSimplifier.cpp
+++ b/src/coverage/CoverageSimplifier.cpp
@@ -86,7 +86,8 @@ CoverageSimplifier::CoverageSimplifier(const std::vector<const Geometry*>& cover
, m_geomFactory(coverage.empty() ? nullptr : coverage[0]->getFactory())
{
for (const Geometry* g: m_input) {
- if (!g->isPolygonal())
+ auto typeId = g->getGeometryTypeId();
+ if (typeId != geom::GEOS_POLYGON && typeId != geom::GEOS_MULTIPOLYGON)
throw util::IllegalArgumentException("Argument is non-polygonal");
}
}
diff --git a/tests/unit/coverage/CoverageSimplifierTest.cpp b/tests/unit/coverage/CoverageSimplifierTest.cpp
index dfec0fa69..1973ae965 100644
--- a/tests/unit/coverage/CoverageSimplifierTest.cpp
+++ b/tests/unit/coverage/CoverageSimplifierTest.cpp
@@ -483,4 +483,24 @@ void object::test<30> ()
}
+// Test non-polygon inputs (GH-1250)
+template<>
+template<>
+void object::test<31> ()
+{
+ auto input = readArray({
+ "GEOMETRYCOLLECTION (POLYGON ((0 10, 10 10, 10 7, 10 3, 10 0, 0 0, 0 10)), GEOMETRYCOLLECTION (POLYGON ((10 10, 20 10, 20 0, 10 0, 10 3, 10 7, 10 10))))"
+ });
+ try {
+ std::vector<std::unique_ptr<Geometry>> result =
+ CoverageSimplifier::simplify(input, 10);
+ }
+ catch (geos::util::IllegalArgumentException&) {
+ ensure("caught IllegalArgumentException", true);
+ return;
+ }
+ ensure("did not throw IllegalArgumentException", false);
+}
+
+
} // namespace tut
-----------------------------------------------------------------------
Summary of changes:
src/coverage/CoverageSimplifier.cpp | 3 ++-
tests/unit/coverage/CoverageSimplifierTest.cpp | 20 ++++++++++++++++++++
2 files changed, 22 insertions(+), 1 deletion(-)
hooks/post-receive
--
GEOS
More information about the geos-commits
mailing list