[geos-commits] [SCM] GEOS branch 3.12 updated. 47e2308ef2d4d54f3e93789798e20458edcdd6f5
git at osgeo.org
git at osgeo.org
Fri Nov 15 14:48:26 PST 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 47e2308ef2d4d54f3e93789798e20458edcdd6f5 (commit)
via bf8a953557bb3c9d7dd313c9149f7aef2a648208 (commit)
from 51c3b3d8a74864e7b05916c27e57ed95036301b4 (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 47e2308ef2d4d54f3e93789798e20458edcdd6f5
Merge: bf8a95355 51c3b3d8a
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date: Fri Nov 15 14:47:52 2024 -0800
Fix LineString->getPoint(n) for M geometries (closes GH-1191)
diff --cc NEWS.md
index 877845bbb,c85d46c92..40af8671b
--- a/NEWS.md
+++ b/NEWS.md
@@@ -12,9 -12,8 +12,10 @@@
- DouglasPeuckerLineSimplifier, avoid crash with Point input and NaN tolerance (GH-1078, Dan Baston)
- GEOSLineSubstring, avoid crash with NaN length fraction (GH-1077, Dan Baston)
- MinimumClearance, avoid crash on NaN inputs (GH-1079, Dan Baston)
+ - Fix LineString->getPoint(n) for M geometries (GH-1191, @hsieyuan)
+ - Fix TopologyPreservingSimplifier/TaggedLineString to avoid jumping components (JTS-1096, Martin Davis)
+
## Changes in 3.12.2
2024-06-05
commit bf8a953557bb3c9d7dd313c9149f7aef2a648208
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date: Fri Nov 15 14:46:41 2024 -0800
Fix LineString->getPoint(n) for M geometries (closes GH-1191)
diff --git a/NEWS.md b/NEWS.md
index ee77dbf89..877845bbb 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -12,6 +12,8 @@
- DouglasPeuckerLineSimplifier, avoid crash with Point input and NaN tolerance (GH-1078, Dan Baston)
- GEOSLineSubstring, avoid crash with NaN length fraction (GH-1077, Dan Baston)
- MinimumClearance, avoid crash on NaN inputs (GH-1079, Dan Baston)
+ - Fix LineString->getPoint(n) for M geometries (GH-1191, @hsieyuan)
+
## Changes in 3.12.2
2024-06-05
diff --git a/src/geom/LineString.cpp b/src/geom/LineString.cpp
index e3c84c3dc..209bef43e 100644
--- a/src/geom/LineString.cpp
+++ b/src/geom/LineString.cpp
@@ -181,7 +181,16 @@ LineString::getPointN(std::size_t n) const
{
assert(getFactory());
assert(points.get());
- return std::unique_ptr<Point>(getFactory()->createPoint(points->getAt(n)));
+ if (hasM() || hasZ()) {
+ CoordinateXYZM c;
+ points->getAt(n, c);
+ return getFactory()->createPoint(c);
+ }
+ else {
+ CoordinateXY c;
+ points->getAt(n, c);
+ return getFactory()->createPoint(c);
+ }
}
std::unique_ptr<Point>
diff --git a/tests/unit/geom/LineStringTest.cpp b/tests/unit/geom/LineStringTest.cpp
index 26a8756bf..1e1136fce 100644
--- a/tests/unit/geom/LineStringTest.cpp
+++ b/tests/unit/geom/LineStringTest.cpp
@@ -13,6 +13,7 @@
#include <geos/geom/GeometryFactory.h>
#include <geos/geom/PrecisionModel.h>
#include <geos/io/WKTReader.h>
+#include <geos/io/WKTWriter.h>
#include <geos/util/GEOSException.h>
#include <geos/util/IllegalArgumentException.h>
#include <geos/constants.h>
@@ -35,6 +36,7 @@ struct test_linestring_data {
geos::geom::PrecisionModel pm_;
geos::geom::GeometryFactory::Ptr factory_;
geos::io::WKTReader reader_;
+ geos::io::WKTWriter writer_;
std::unique_ptr<geos::geom::LineString> empty_line_;
std::unique_ptr<geos::geom::LineString> line_;
@@ -588,5 +590,23 @@ void object::test<32>
ensure(!line_->hasDimension(geos::geom::Dimension::A));
}
+
+// https://github.com/libgeos/geos/issues/1191
+// line->getPoint(n) loses M dimension
+template<>
+template<>
+void object::test<33>
+()
+{
+ auto geom = reader_.read("LINESTRING M (0 1 2, 10 11 12, 20 21 22)");
+ ensure(geom != nullptr);
+ geos::geom::LineString *line = static_cast<LineString*>(geom.get());
+ ensure_equals(line->getCoordinateDimension(), 3);
+ auto pt = line->getPointN(2);
+ auto out = writer_.write(*pt);
+ ensure_equals(out, "POINT M (20 21 22)");
+}
+
+
} // namespace tut
-----------------------------------------------------------------------
Summary of changes:
NEWS.md | 2 ++
src/geom/LineString.cpp | 11 ++++++++++-
tests/unit/geom/LineStringTest.cpp | 20 ++++++++++++++++++++
3 files changed, 32 insertions(+), 1 deletion(-)
hooks/post-receive
--
GEOS
More information about the geos-commits
mailing list