[geos-commits] [SCM] GEOS branch 3.9 updated. 835d1360220955ca0928f9d8ff9472bbede4ae27
git at osgeo.org
git at osgeo.org
Mon Jun 17 11:50:36 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.9 has been updated
via 835d1360220955ca0928f9d8ff9472bbede4ae27 (commit)
via 64c96ba2265f9707eed692cc3caa4d41d885d4e8 (commit)
via 7590379676d1b2a99fce225416d3df2f1c66a87c (commit)
from 3effbfd32bf304c0276bed1691137d2c48ed907b (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 835d1360220955ca0928f9d8ff9472bbede4ae27
Author: Daniel Baston <dbaston at gmail.com>
Date: Mon Jun 17 14:47:32 2024 -0400
NEWS updates
diff --git a/NEWS b/NEWS
index 195b7fa50..889f00328 100644
--- a/NEWS
+++ b/NEWS
@@ -3,7 +3,8 @@ xxxx-xx-xx
- Bug fixes / improvements:
- Intersection: change to using DoubleDouble computation to improve robustness (GH-937, Martin Davis)
-
+ - Centroid: Fix crash on polygons with empty holes (GH-1075, Dan Baston)
+ - GEOSRelatePatternMatch: Fix crash on invalid DE-9IM pattern (GH-1089, Dan Baston)
## Changes in 3.9.5
2023-11-12
commit 64c96ba2265f9707eed692cc3caa4d41d885d4e8
Author: Daniel Baston <dbaston at gmail.com>
Date: Tue Apr 30 18:37:19 2024 -0400
IntersectionMatrix: Ignore patterns longer than 9 characters
Fixes https://github.com/libgeos/geos/issues/1084
diff --git a/src/geom/IntersectionMatrix.cpp b/src/geom/IntersectionMatrix.cpp
index a8c7a4b39..b055742a3 100644
--- a/src/geom/IntersectionMatrix.cpp
+++ b/src/geom/IntersectionMatrix.cpp
@@ -146,7 +146,7 @@ IntersectionMatrix::set(Location row, Location col, int dimensionValue)
void
IntersectionMatrix::set(const string& dimensionSymbols)
{
- auto limit = dimensionSymbols.length();
+ auto limit = std::min(dimensionSymbols.length(), static_cast<std::size_t>(9));
for(size_t i = 0; i < limit; i++) {
auto row = i / firstDim;
diff --git a/tests/unit/capi/GEOSRelatePatternMatchTest.cpp b/tests/unit/capi/GEOSRelatePatternMatchTest.cpp
index 90549d47d..c4509119e 100644
--- a/tests/unit/capi/GEOSRelatePatternMatchTest.cpp
+++ b/tests/unit/capi/GEOSRelatePatternMatchTest.cpp
@@ -8,6 +8,7 @@
#include <cstdarg>
#include <cstdio>
#include <cstdlib>
+#include <cstring>
namespace tut {
//
@@ -101,5 +102,18 @@ void object::test<5>
ensure_equals(ret, char(0));
}
+// invalid DE-9IM argument
+// https://github.com/libgeos/geos/issues/1084
+template<>
+template<>
+void object::test<6>
+()
+{
+ const char* mat = "0000000000";
+ ensure_equals(strlen(mat), 10u); // not a valid DE-9IM!
+
+ GEOSRelatePatternMatch(mat, "111111111");
+}
+
} // namespace tut
commit 7590379676d1b2a99fce225416d3df2f1c66a87c
Author: Daniel Baston <dbaston at gmail.com>
Date: Fri Apr 19 19:49:55 2024 -0400
Centroid: Avoid crash with empty hole
Resolves https://github.com/libgeos/geos/issues/1073
diff --git a/src/algorithm/Centroid.cpp b/src/algorithm/Centroid.cpp
index 8f6568201..16fbbe7d5 100644
--- a/src/algorithm/Centroid.cpp
+++ b/src/algorithm/Centroid.cpp
@@ -124,6 +124,10 @@ Centroid::addShell(const CoordinateSequence& pts)
void
Centroid::addHole(const CoordinateSequence& pts)
{
+ if (pts.isEmpty()) {
+ return;
+ }
+
bool isPositiveArea = Orientation::isCCW(&pts);
for(size_t i = 0, e = pts.size() - 1; i < e; ++i) {
addTriangle(*areaBasePt, pts[i], pts[i + 1], isPositiveArea);
diff --git a/tests/unit/algorithm/CentroidTest.cpp b/tests/unit/algorithm/CentroidTest.cpp
new file mode 100644
index 000000000..be3dcc05e
--- /dev/null
+++ b/tests/unit/algorithm/CentroidTest.cpp
@@ -0,0 +1,133 @@
+//
+// Test Suite for geos::algorithm::Centroid
+
+#include <tut/tut.hpp>
+// geos
+#include <geos/algorithm/Centroid.h>
+#include <geos/geom/Coordinate.h>
+#include <geos/geom/CoordinateArraySequence.h>
+#include <geos/geom/Dimension.h>
+#include <geos/geom/Geometry.h>
+#include <geos/geom/GeometryFactory.h>
+#include <geos/geom/LineString.h>
+#include <geos/geom/PrecisionModel.h>
+#include <geos/io/WKTReader.h>
+// std
+#include <sstream>
+#include <string>
+#include <memory>
+
+using namespace geos;
+using namespace geos::geom;
+
+namespace tut {
+//
+// Test Group
+//
+
+// dummy data, not used
+struct test_centroid_data {
+
+ std::unique_ptr<Geometry> geom_;
+ PrecisionModel pm_;
+ GeometryFactory::Ptr factory_;
+ io::WKTReader reader_;
+
+ test_centroid_data():
+ geom_(nullptr),
+ pm_(1),
+ factory_(GeometryFactory::create(&pm_, 0)),
+ reader_(factory_.get())
+ {
+ assert(nullptr == geom_);
+ }
+
+ ~test_centroid_data()
+ {
+ }
+
+ void
+ checkCentroid(std::string inputWkt, bool expectResult, double expectedX, double expectedY)
+ {
+ std::unique_ptr<Geometry> inputGeom(reader_.read(inputWkt));
+ Coordinate resultCoord;
+ bool gotResult = algorithm::Centroid::getCentroid(*inputGeom, resultCoord);
+ ensure_equals(gotResult, expectResult);
+ if (expectResult) {
+ ensure_equals(expectedX, resultCoord.x);
+ ensure_equals(expectedY, resultCoord.y);
+ }
+ }
+
+ void
+ checkCentroid(std::string inputWkt, double expectedX, double expectedY)
+ {
+ checkCentroid(inputWkt, true, expectedX, expectedY);
+ }
+
+ void
+ checkCentroidFails(std::string inputWkt)
+ {
+ checkCentroid(inputWkt, false, 0, 0);
+ }
+
+};
+
+
+
+typedef test_group<test_centroid_data> group;
+typedef group::object object;
+
+group test_centroid_group("geos::algorithm::Centroid");
+
+
+//
+// Test Cases
+//
+template<>
+template<>
+void object::test<1>() {
+ checkCentroid(
+ "LINESTRING (0 0, 200 200)",
+ 100.0, 100.0);
+}
+
+template<>
+template<>
+void object::test<2>() {
+ checkCentroid(
+ "POLYGON ((0 0, 100 0, 100 100, 0 100, 0 0))",
+ 50.0, 50.0);
+}
+
+template<>
+template<>
+void object::test<3>() {
+ checkCentroid(
+ "GEOMETRYCOLLECTION(POLYGON ((0 0, 100 0, 100 100, 0 100, 0 0)))",
+ 50.0, 50.0);
+}
+
+template<>
+template<>
+void object::test<4>() {
+ checkCentroid(
+ "GEOMETRYCOLLECTION(POLYGON ((0 0, 100 0, 100 100, 0 100, 0 0)), POINT EMPTY)",
+ 50.0, 50.0);
+}
+
+template<>
+template<>
+void object::test<5>() {
+ checkCentroidFails(
+ "POLYGON EMPTY");
+}
+
+template<>
+template<>
+void object::test<6>() {
+ checkCentroid("POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0), EMPTY)", 0.5, 0.5);
+}
+
+} // namespace tut
+
-----------------------------------------------------------------------
Summary of changes:
NEWS | 3 +-
src/algorithm/Centroid.cpp | 4 +
src/geom/IntersectionMatrix.cpp | 2 +-
tests/unit/algorithm/CentroidTest.cpp | 133 +++++++++++++++++++++++++
tests/unit/capi/GEOSRelatePatternMatchTest.cpp | 14 +++
5 files changed, 154 insertions(+), 2 deletions(-)
create mode 100644 tests/unit/algorithm/CentroidTest.cpp
hooks/post-receive
--
GEOS
More information about the geos-commits
mailing list