[geos-commits] [SCM] GEOS branch 3.12 updated. 1783c24ccc504ecbc5569e9283c901e77d969cca
git at osgeo.org
git at osgeo.org
Thu Oct 24 13:15:53 PDT 2024
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.12 has been updated
via 1783c24ccc504ecbc5569e9283c901e77d969cca (commit)
via 9722159a09ef025279d94125f26090b94b7cd0fd (commit)
from 237bcacd5b5049632092c800bb1a17958a97033a (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 1783c24ccc504ecbc5569e9283c901e77d969cca
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date: Thu Oct 24 13:15:24 2024 -0700
News entry for GH-1078
diff --git a/NEWS.md b/NEWS.md
index 017a4e2c0..7bfe6a9c9 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -8,7 +8,8 @@
- GEOSLineSubstring: Fix crash on NaN length fractions (GH-1088, Dan Baston)
- GEOSRelatePatternMatch: Fix crash on invalid DE-9IM pattern (GH-1089, Dan Baston)
- Fix ConcaveHullOfPolygons nested shell handling (GH-1169, Martin Davis)
- - GEOSConcaveHullOfPolygons, Avoid crash on zero-area input (GH-1071, Dan Baston)
+ - GEOSConcaveHullOfPolygons, avoid crash on zero-area input (GH-1071, Dan Baston)
+ - DouglasPeuckerLineSimplifier, avoid crash with Point input and NaN tolerance (GH-1078, Dan Baston)
## Changes in 3.12.2
2024-06-05
commit 9722159a09ef025279d94125f26090b94b7cd0fd
Author: Daniel Baston <dbaston at gmail.com>
Date: Wed Jun 19 20:40:48 2024 -0400
DouglasPeuckerLineSimplifier: Avoid crash with Point input and NaN tolerance (#1114)
Fixes https://github.com/libgeos/geos/issues/1078
diff --git a/src/simplify/DouglasPeuckerLineSimplifier.cpp b/src/simplify/DouglasPeuckerLineSimplifier.cpp
index 6a2a456a5..49e040e0b 100644
--- a/src/simplify/DouglasPeuckerLineSimplifier.cpp
+++ b/src/simplify/DouglasPeuckerLineSimplifier.cpp
@@ -21,6 +21,7 @@
#include <geos/geom/LineSegment.h>
#include <geos/geom/LinearRing.h>
#include <geos/util.h>
+#include <geos/util/IllegalArgumentException.h>
#include <vector>
#include <memory> // for unique_ptr
@@ -58,6 +59,9 @@ void
DouglasPeuckerLineSimplifier::setDistanceTolerance(
double nDistanceTolerance)
{
+ if (std::isnan(nDistanceTolerance)) {
+ throw util::IllegalArgumentException("Tolerance must not be NaN");
+ }
distanceTolerance = nDistanceTolerance;
}
@@ -110,6 +114,7 @@ DouglasPeuckerLineSimplifier::simplifySection(
std::size_t j)
{
if((i + 1) == j) {
+
return;
}
diff --git a/tests/unit/simplify/DouglasPeuckerSimplifierTest.cpp b/tests/unit/simplify/DouglasPeuckerSimplifierTest.cpp
index d8d631cd9..73a8a3dd1 100644
--- a/tests/unit/simplify/DouglasPeuckerSimplifierTest.cpp
+++ b/tests/unit/simplify/DouglasPeuckerSimplifierTest.cpp
@@ -43,7 +43,7 @@ struct test_dpsimp_data {
GeomPtr simplified = DouglasPeuckerSimplifier::simplify(g.get(), tolerance);
ensure("Simplified geometry is invalid!", simplified->isValid());
-
+
GeomPtr exp(wktreader.read(wkt_expected));
ensure_equals_geometry(exp.get(), simplified.get());
}
@@ -69,8 +69,8 @@ template<>
template<>
void object::test<1>()
{
- checkDP("POLYGON ((20 220, 40 220, 60 220, 80 220, 100 220, 120 220, 140 220, 140 180, 100 180, 60 180, 20 180, 20 220))",
- 10.0,
+ checkDP("POLYGON ((20 220, 40 220, 60 220, 80 220, 100 220, 120 220, 140 220, 140 180, 100 180, 60 180, 20 180, 20 220))",
+ 10.0,
"POLYGON ((20 220, 140 220, 140 180, 20 180, 20 220))");
}
@@ -79,8 +79,8 @@ template<>
template<>
void object::test<2>()
{
- checkDP("POLYGON ((40 240, 160 241, 280 240, 280 160, 160 240, 40 140, 40 240))",
- 1,
+ checkDP("POLYGON ((40 240, 160 241, 280 240, 280 160, 160 240, 40 140, 40 240))",
+ 1,
"MULTIPOLYGON (((40 240, 160 240, 40 140, 40 240)), ((160 240, 280 240, 280 160, 160 240)))");
}
@@ -90,7 +90,7 @@ template<>
void object::test<3>()
{
checkDP("POLYGON ((120 120, 121 121, 122 122, 220 120, 180 199, 160 200, 140 199, 120 120))",
- 10,
+ 10,
"POLYGON ((120 120, 220 120, 180 199, 160 200, 140 199, 120 120))");
}
@@ -267,7 +267,7 @@ template<>
void object::test<14>()
{
checkDP(
- "POLYGON ((21.32686 47.78723, 21.32386 47.79023, 21.32186 47.80223, 21.31486 47.81023, 21.32786 47.81123, 21.33986 47.80223, 21.33886 47.81123, 21.32686 47.82023, 21.32586 47.82723, 21.32786 47.82323, 21.33886 47.82623, 21.34186 47.82123, 21.36386 47.82223, 21.40686 47.81723, 21.32686 47.78723))",
+ "POLYGON ((21.32686 47.78723, 21.32386 47.79023, 21.32186 47.80223, 21.31486 47.81023, 21.32786 47.81123, 21.33986 47.80223, 21.33886 47.81123, 21.32686 47.82023, 21.32586 47.82723, 21.32786 47.82323, 21.33886 47.82623, 21.34186 47.82123, 21.36386 47.82223, 21.40686 47.81723, 21.32686 47.78723))",
0.0036,
"POLYGON ((21.32686 47.78723, 21.31486 47.81023, 21.32786 47.81123, 21.33986 47.80223, 21.328068201892744 47.823286782334385, 21.33886 47.82623, 21.34186 47.82123, 21.40686 47.81723, 21.32686 47.78723))"
);
@@ -284,7 +284,7 @@ template<>
void object::test<15>()
{
checkDP(
- "MULTIPOLYGON (((-76.02716827 36.55671692, -75.99866486 36.55665207, -75.91191864 36.54253006, -75.92480469 36.47397614, -75.97727966 36.4780159, -75.97628784 36.51792526, -76.02716827 36.55671692)), ((-75.90198517 36.55619812, -75.8781662 36.55587387, -75.77315521 36.22925568, -75.78317261 36.22519302, -75.90198517 36.55619812)))",
+ "MULTIPOLYGON (((-76.02716827 36.55671692, -75.99866486 36.55665207, -75.91191864 36.54253006, -75.92480469 36.47397614, -75.97727966 36.4780159, -75.97628784 36.51792526, -76.02716827 36.55671692)), ((-75.90198517 36.55619812, -75.8781662 36.55587387, -75.77315521 36.22925568, -75.78317261 36.22519302, -75.90198517 36.55619812)))",
0.05,
"POLYGON ((-76.02716827 36.55671692, -75.91191864 36.54253006, -75.92480469 36.47397614, -76.02716827 36.55671692))"
);
@@ -295,7 +295,7 @@ template<>
template<>
void object::test<16>()
{
- checkDP("POLYGON ((1 0, 2 0, 2 2, 0 2, 0 0, 1 0))",
+ checkDP("POLYGON ((1 0, 2 0, 2 2, 0 2, 0 0, 1 0))",
0,
"POLYGON (( 0 0, 2 0, 2 2, 0 2, 0 0))");
}
@@ -305,7 +305,7 @@ template<>
template<>
void object::test<17>()
{
- checkDPNoChange("LINESTRING (1 0, 2 0, 2 2, 0 2, 0 0, 1 0)",
+ checkDPNoChange("LINESTRING (1 0, 2 0, 2 2, 0 2, 0 0, 1 0)",
0);
}
@@ -334,4 +334,19 @@ void object::test<19>()
);
}
+// https://github.com/libgeos/geos/issues/1078
+template<>
+template<>
+void object::test<20>()
+{
+ auto gfact = GeometryFactory::getDefaultInstance();
+ auto pt = gfact->createPoint(Coordinate{0, 0});
+
+ try {
+ DouglasPeuckerSimplifier::simplify(pt.get(), std::numeric_limits<double>::quiet_NaN());
+ fail("Exception not thrown.");
+ } catch (const geos::util::IllegalArgumentException&) {
+ }
+}
+
} // namespace tut
-----------------------------------------------------------------------
Summary of changes:
NEWS.md | 3 +-
src/simplify/DouglasPeuckerLineSimplifier.cpp | 5 ++++
.../unit/simplify/DouglasPeuckerSimplifierTest.cpp | 35 +++++++++++++++-------
3 files changed, 32 insertions(+), 11 deletions(-)
hooks/post-receive
--
GEOS
More information about the geos-commits
mailing list