[geos-commits] [SCM] GEOS branch main updated. a180ae12ad185da32746e665ee068b63b1ac4644
git at osgeo.org
git at osgeo.org
Tue Feb 17 12:28:12 PST 2026
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 a180ae12ad185da32746e665ee068b63b1ac4644 (commit)
from 9bc6ca8716552f8d35e90cd22be433123c06b175 (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 a180ae12ad185da32746e665ee068b63b1ac4644
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date: Tue Feb 17 12:27:46 2026 -0800
Preserve ZM when creating edges in Coverage (#1384)
* When creating the edges for a new Coverage, check the dimensionality
of the inputs and create coordinate sequences with the same dimensionality,
so the extra dims pass through. Closes GH-1366.
diff --git a/src/coverage/CoverageEdge.cpp b/src/coverage/CoverageEdge.cpp
index a3504a2f6..53252b964 100644
--- a/src/coverage/CoverageEdge.cpp
+++ b/src/coverage/CoverageEdge.cpp
@@ -79,13 +79,19 @@ std::unique_ptr<CoordinateSequence>
CoverageEdge::extractEdgePoints(const CoordinateSequence& ring,
std::size_t start, std::size_t end)
{
- auto pts = detail::make_unique<CoordinateSequence>();
std::size_t size = start < end
? end - start + 1
: ring.getSize() - start + end;
+
+ // Create CoordinateSequence with the same dimensions as the input ring
+ auto pts = detail::make_unique<CoordinateSequence>(size, ring.hasZ(), ring.hasM());
+
std::size_t iring = start;
for (std::size_t i = 0; i < size; i++) {
- pts->add(ring.getAt(iring));
+ // Use applyAt to correctly add coordinates while preserving dimension
+ ring.applyAt(iring, [&pts, &i](const auto& c){
+ pts->setAt(c, i);
+ });
iring += 1;
if (iring >= ring.getSize())
iring = 1;
diff --git a/src/coverage/CoverageRingEdges.cpp b/src/coverage/CoverageRingEdges.cpp
index 99c53b04e..fa87c2885 100644
--- a/src/coverage/CoverageRingEdges.cpp
+++ b/src/coverage/CoverageRingEdges.cpp
@@ -369,7 +369,8 @@ CoverageRingEdges::buildRing(const LinearRing* ring) const
}
// CoordinateList ptsList = new CoordinateList();
- std::unique_ptr<CoordinateSequence> pts(new CoordinateSequence());
+ // Create CoordinateSequence with the same dimensions as the original ring
+ std::unique_ptr<CoordinateSequence> pts(new CoordinateSequence(0, ring->hasZ(), ring->hasM()));
Coordinate nullPt = Coordinate::getNull();
for (std::size_t i = 0; i < ringEdges->size(); i++) {
Coordinate& lastPt = pts->isEmpty() ? nullPt : pts->back();
diff --git a/src/simplify/LinkedLine.cpp b/src/simplify/LinkedLine.cpp
index 684e493e9..2d55ccf24 100644
--- a/src/simplify/LinkedLine.cpp
+++ b/src/simplify/LinkedLine.cpp
@@ -156,11 +156,14 @@ LinkedLine::remove(std::size_t index)
std::unique_ptr<CoordinateSequence>
LinkedLine::getCoordinates() const
{
- std::unique_ptr<CoordinateSequence> coords(new CoordinateSequence());
+ // Create CoordinateSequence with the same dimensions as the original m_coord
+ std::unique_ptr<CoordinateSequence> coords(new CoordinateSequence(0, m_coord.hasZ(), m_coord.hasM()));
std::size_t len = m_isRing ? m_coord.size() - 1 : m_coord.size();
for (std::size_t i = 0; i < len; i++) {
if (hasCoordinate(i)) {
- coords->add(m_coord.getAt(i), false);
+ m_coord.applyAt(i, [&coords](const auto& c){ // Use applyAt for safe coordinate copy
+ coords->add(c, false);
+ });
}
}
if (m_isRing) {
diff --git a/tests/unit/coverage/CoverageSimplifierTest.cpp b/tests/unit/coverage/CoverageSimplifierTest.cpp
index 1973ae965..be8b1938c 100644
--- a/tests/unit/coverage/CoverageSimplifierTest.cpp
+++ b/tests/unit/coverage/CoverageSimplifierTest.cpp
@@ -6,6 +6,10 @@
// geos
#include <geos/coverage/CoverageSimplifier.h>
+#include <geos/geom/Polygon.h> // Added for Polygon
+#include <geos/geom/SimpleCurve.h> // Added for SimpleCurve
+
+
using geos::coverage::CoverageSimplifier;
@@ -502,5 +506,20 @@ void object::test<31> ()
ensure("did not throw IllegalArgumentException", false);
}
+// Test GH-1366: M values are preserved
+template<>
+template<>
+void object::test<32> ()
+{
+ std::string wktInput = "POLYGON ZM ((0 0 0 0, 10 0 1 1, 10 10 2 2, 0 10 3 3, 0 0 0 0))";
+ std::string wktExpected = "POLYGON ZM ((0 0 0 0, 10 0 1 1, 10 10 2 2, 0 10 3 3, 0 0 0 0))"; // No simplification occurs with tolerance 0
+
+ std::vector<std::unique_ptr<Geometry>> input = readArray({ wktInput });
+ std::vector<std::unique_ptr<Geometry>> expected = readArray({ wktExpected });
+ std::vector<std::unique_ptr<Geometry>> actual = CoverageSimplifier::simplify(input, 0.0);
+
+ ensure_equals_exact_geometry_xyzm(actual[0].get(), expected[0].get(), 0.001);
+}
+
} // namespace tut
-----------------------------------------------------------------------
Summary of changes:
src/coverage/CoverageEdge.cpp | 10 ++++++++--
src/coverage/CoverageRingEdges.cpp | 3 ++-
src/simplify/LinkedLine.cpp | 7 +++++--
tests/unit/coverage/CoverageSimplifierTest.cpp | 19 +++++++++++++++++++
4 files changed, 34 insertions(+), 5 deletions(-)
hooks/post-receive
--
GEOS
More information about the geos-commits
mailing list