[geos-commits] [SCM] GEOS branch main updated. 8e4d950d8071a02748d54772b839623f5e586428
git at osgeo.org
git at osgeo.org
Tue Jan 13 05:49:38 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 8e4d950d8071a02748d54772b839623f5e586428 (commit)
from d5d89d025fcd877fc96b80cd6a325b572a1b16f3 (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 8e4d950d8071a02748d54772b839623f5e586428
Author: Daniel Baston <dbaston at gmail.com>
Date: Tue Jan 13 08:49:15 2026 -0500
Polygonizer: Preserve M values in input (#1363)
Resolves https://github.com/libgeos/geos/issues/1360
diff --git a/include/geos/operation/polygonize/PolygonizeEdge.h b/include/geos/operation/polygonize/PolygonizeEdge.h
index 718d709b4..d58d9b8f5 100644
--- a/include/geos/operation/polygonize/PolygonizeEdge.h
+++ b/include/geos/operation/polygonize/PolygonizeEdge.h
@@ -49,7 +49,7 @@ public:
PolygonizeEdge(const geom::LineString* newLine);
// Just return what it was given initially
- const geom::LineString* getLine();
+ const geom::LineString* getLine() const;
};
} // namespace geos::operation::polygonize
diff --git a/src/operation/polygonize/EdgeRing.cpp b/src/operation/polygonize/EdgeRing.cpp
index 4f4252a8d..937b92497 100644
--- a/src/operation/polygonize/EdgeRing.cpp
+++ b/src/operation/polygonize/EdgeRing.cpp
@@ -224,9 +224,19 @@ const CoordinateSequence*
EdgeRing::getCoordinates() const
{
if(ringPts == nullptr) {
- ringPts = std::make_shared<CoordinateSequence>(0u, 0u);
+ bool hasZ = false;
+ bool hasM = false;
+
for(const auto& de : deList) {
- auto edge = dynamic_cast<PolygonizeEdge*>(de->getEdge());
+ const auto edge = detail::down_cast<PolygonizeEdge*>(de->getEdge());
+ hasZ |= edge->getLine()->hasZ();
+ hasM |= edge->getLine()->hasM();
+ }
+
+ ringPts = std::make_shared<CoordinateSequence>(0u, hasZ, hasM);
+
+ for(const auto& de : deList) {
+ auto edge = detail::down_cast<PolygonizeEdge*>(de->getEdge());
addEdge(edge->getLine()->getCoordinatesRO(),
de->getEdgeDirection(), ringPts.get());
}
@@ -281,13 +291,13 @@ EdgeRing::addEdge(const CoordinateSequence* coords, bool isForward,
{
const std::size_t npts = coords->getSize();
if(isForward) {
- for(std::size_t i = 0; i < npts; ++i) {
- coordList->add(coords->getAt(i), false);
- }
+ coordList->add(*coords, 0, npts - 1, false);
}
else {
for(std::size_t i = npts; i > 0; --i) {
- coordList->add(coords->getAt(i - 1), false);
+ coords->applyAt(i-1, [coordList](const auto& coord) {
+ coordList->add(coord, false);
+ });
}
}
}
diff --git a/src/operation/polygonize/PolygonizeEdge.cpp b/src/operation/polygonize/PolygonizeEdge.cpp
index a224ec2cb..d2d210cc5 100644
--- a/src/operation/polygonize/PolygonizeEdge.cpp
+++ b/src/operation/polygonize/PolygonizeEdge.cpp
@@ -32,7 +32,7 @@ PolygonizeEdge::PolygonizeEdge(const LineString* newLine)
}
const LineString*
-PolygonizeEdge::getLine()
+PolygonizeEdge::getLine() const
{
return line;
}
diff --git a/tests/unit/operation/polygonize/PolygonizeTest.cpp b/tests/unit/operation/polygonize/PolygonizeTest.cpp
index 0a1a9e40e..970fd4797 100644
--- a/tests/unit/operation/polygonize/PolygonizeTest.cpp
+++ b/tests/unit/operation/polygonize/PolygonizeTest.cpp
@@ -381,5 +381,25 @@ void object::test<10>()
INVALID_RING_LINES);
}
+template<>
+template<>
+void object::test<11>()
+{
+ set_test_name("Z/M preserved");
+
+ doTest(
+ {"GEOMETRYCOLLECTION ("
+ "LINESTRING ZM (10 0 3 4, 0 0 0 0, 0 10 1 2, 10 10 2 3),"
+ "LINESTRING ZM (10 10 2 3, 10 0 3 4),"
+ "LINESTRING M (10 0 8, 20 0 9, 10 10 11))"
+ },
+ {
+ "POLYGON ZM ((0 0 0 0, 0 10 1 2, 10 10 2 3, 10 0 3 4, 0 0 0 0))",
+ "POLYGON ZM ((10 0 3 4, 10 10 2 3, 20 0 NaN 9, 10 0 3 4))"
+ },
+ false,
+ POLYGONS);
+}
+
} // namespace tut
-----------------------------------------------------------------------
Summary of changes:
include/geos/operation/polygonize/PolygonizeEdge.h | 2 +-
src/operation/polygonize/EdgeRing.cpp | 22 ++++++++++++++++------
src/operation/polygonize/PolygonizeEdge.cpp | 2 +-
tests/unit/operation/polygonize/PolygonizeTest.cpp | 20 ++++++++++++++++++++
4 files changed, 38 insertions(+), 8 deletions(-)
hooks/post-receive
--
GEOS
More information about the geos-commits
mailing list