[geos-commits] [SCM] GEOS branch main updated. a1ade8d631190782a6032f2105f4727ead0fb5f3
git at osgeo.org
git at osgeo.org
Sun Mar 8 17:43:54 PDT 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 a1ade8d631190782a6032f2105f4727ead0fb5f3 (commit)
from 927e1df7e5f4202c64d986bb8ee858d53e5b71eb (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 a1ade8d631190782a6032f2105f4727ead0fb5f3
Author: Daniel Baston <dbaston at gmail.com>
Date: Sun Mar 8 19:57:22 2026 -0400
C API: Add more comments/tests on Z/M handling
diff --git a/capi/geos_c.h.in b/capi/geos_c.h.in
index 95a5e2600..21a85501f 100644
--- a/capi/geos_c.h.in
+++ b/capi/geos_c.h.in
@@ -5034,7 +5034,7 @@ extern GEOSGeometry GEOS_DLL *GEOSMinimumWidth(const GEOSGeometry* g);
/**
-* Returns a point that is inside the boundary of a polygonal geometry.
+* Returns a 2D point that is inside the boundary of a polygonal geometry.
* \param g The input geometry
* \return A point that is inside the input
* Caller is responsible for freeing with GEOSGeom_destroy().
@@ -5045,7 +5045,7 @@ extern GEOSGeometry GEOS_DLL *GEOSMinimumWidth(const GEOSGeometry* g);
extern GEOSGeometry GEOS_DLL *GEOSPointOnSurface(const GEOSGeometry* g);
/**
-* Returns a point at the center of mass of the input.
+* Returns a 2D point at the center of mass of the input.
* \param g The input geometry
* \return A point at the center of mass of the input
* Caller is responsible for freeing with GEOSGeom_destroy().
@@ -5056,7 +5056,7 @@ extern GEOSGeometry GEOS_DLL *GEOSPointOnSurface(const GEOSGeometry* g);
extern GEOSGeometry GEOS_DLL *GEOSGetCentroid(const GEOSGeometry* g);
/**
-* Returns a geometry which represents the "minimum bounding circle",
+* Returns a 2D geometry which represents the "minimum bounding circle",
* the smallest circle that contains the input.
* \param[in] g The input geometry
* \param[out] radius Pointer will be filled with output radius.
@@ -5075,6 +5075,9 @@ extern GEOSGeometry GEOS_DLL *GEOSMinimumBoundingCircle(
/**
* Return a Delaunay triangulation of the vertices of the given geometry.
*
+* Z values from the input points will be propagated to the generated polygons.
+* M values from the input points will be ignored.
+*
* \param g the input geometry whose vertices will be used as "sites"
* \param tolerance optional snapping tolerance to use for improved robustness
* \param onlyEdges if non-zero will return a MultiLineString, otherwise it will
@@ -5095,6 +5098,9 @@ extern GEOSGeometry GEOS_DLL * GEOSDelaunayTriangulation(
* given polygon(s).
* For non-polygonal inputs, returns an empty geometry collection.
*
+* Z values from the input points will be propagated to the generated polygons.
+* M values from the input points will be ignored.
+*
* \param g the input geometry whose rings will be used as input
* \return A newly allocated geometry. NULL on exception.
* Caller is responsible for freeing with GEOSGeom_destroy().
@@ -5116,7 +5122,8 @@ enum GEOSVoronoiFlags
};
/**
-* Returns the Voronoi polygons or edges of the vertices of the given geometry.
+* Returns the 2D Voronoi polygons or edges computed from the vertices
+* of the given geometry.
*
* \param g the input geometry whose vertices will be used as sites.
* \param tolerance snapping tolerance to use for improved robustness. A
@@ -5152,6 +5159,10 @@ extern GEOSGeometry GEOS_DLL * GEOSVoronoiDiagram(
/**
* For linear inputs, returns a new geometry in which no lines cross
* each other, and all touching occurs at end points.
+*
+* Z and M values of input coordinates will be preserved.
+* Z and M values at constructed points will be interpolated.
+*
* \param g The input geometry
* \return The noded geometry or NULL on exception
* Caller is responsible for freeing with GEOSGeom_destroy().
@@ -5165,9 +5176,11 @@ extern GEOSGeometry GEOS_DLL *GEOSNode(const GEOSGeometry* g);
* Polygonizes a set of Geometries which contain linework that
* represents the edges of a planar graph.
*
-* All types of Geometry are accepted as input; the constituent
+* All non-curved types of Geometry are accepted as input; the constituent
* linework is extracted as the edges to be polygonized.
*
+* Z and M values from the input linework will be preserved.
+*
* The edges must be correctly noded; that is, they must only meet
* at their endpoints and not overlap anywhere. If your edges are not
* already noded, run them through GEOSUnaryUnion() first.
@@ -5195,7 +5208,7 @@ extern GEOSGeometry GEOS_DLL *GEOSNode(const GEOSGeometry* g);
* that the input lines form a valid polygonal geometry (which may
* include holes or nested polygons).
*
-* \param geoms Array of linear geometries to polygons. Caller retains ownersihp of both array container and objects.
+* \param geoms Array of linear geometries to polygons. Caller retains ownership of both array container and objects.
* \param ngeoms Size of the geoms array.
* \return The polygonal output geometry.
* Caller is responsible for freeing with GEOSGeom_destroy().
@@ -5212,7 +5225,7 @@ extern GEOSGeometry GEOS_DLL *GEOSPolygonize(
* but returns a result which is a valid polygonal geometry.
* The result will not contain any edge-adjacent elements.
*
-* \param geoms Array of linear geometries to polygons. Caller retains ownersihp of both array container and objects.
+* \param geoms Array of linear geometries to polygons. Caller retains ownership of both array container and objects.
* \param ngeoms Size of the geoms array.
* \return The polygonal output geometry.
* Caller is responsible for freeing with GEOSGeom_destroy().
@@ -5287,7 +5300,8 @@ extern GEOSGeometry GEOS_DLL *GEOSBuildArea(const GEOSGeometry* g);
* Densifies a geometry using a given distance tolerance.
* Additional vertices will be added to every line segment
* that is greater this tolerance; these vertices will
-* evenly subdivide that segment.
+* evenly subdivide that segment. Z and M values of added
+* vertices will be interpolated.
* Only linear components of input geometry are densified.
* \param g The geometry to densify
* \param tolerance the distance tolerance to densify
@@ -5304,7 +5318,11 @@ extern GEOSGeometry GEOS_DLL *GEOSDensify(
* Merges a set of LineStrings,
* joining them at nodes which have cardinality 2.
* Lines may have their direction reversed.
-
+*
+* Z and M values from the input will be preserved. If the Z and M
+* values differ at the points where two lines are joined, the values
+* from one of the points will be selected.
+*
* \param g The input linework
* \return The merged linework.
* Caller is responsible for freeing with GEOSGeom_destroy().
@@ -5318,7 +5336,11 @@ extern GEOSGeometry GEOS_DLL *GEOSLineMerge(const GEOSGeometry* g);
* joining them at nodes which have cardinality 2.
* and where the lines have the same direction.
* This means that lines do not have their direction reversed.
-
+*
+* Z and M values from the input will be preserved. If the Z and M
+* values differ at the points where two lines are joined, the values
+* from one of the points will be selected.
+*
* \param g The input linework
* \return The merged linework.
* Caller is responsible for freeing with GEOSGeom_destroy().
@@ -5331,6 +5353,10 @@ extern GEOSGeometry GEOS_DLL *GEOSLineMergeDirected(const GEOSGeometry* g);
/**
* Computes the line which is the section of the input LineString starting and
* ending at the given length fractions.
+ *
+ * Z values will be interpolated from the input.
+ * M values from the input will be ignored.
+ *
* \param g The input LineString
* \param start_fraction start fraction (0-1) along the length of g
* \param end_fraction end fraction (0-1) along the length of g
@@ -5347,7 +5373,8 @@ extern GEOSGeometry GEOS_DLL *GEOSLineSubstring(
/**
* For geometries with coordinate sequences, reverses the order
* of the sequences. Converts CCW rings to CW. Reverses direction
-* of LineStrings.
+* of LineStrings. Z and M values of the input coordinates are
+* preserved.
* \param g The input geometry
* \return The reversed geometry
* Caller is responsible for freeing with GEOSGeom_destroy().
diff --git a/tests/unit/capi/GEOSConstrainedDelaunayTriangulationTest.cpp b/tests/unit/capi/GEOSConstrainedDelaunayTriangulationTest.cpp
index cee6d9019..51362108f 100644
--- a/tests/unit/capi/GEOSConstrainedDelaunayTriangulationTest.cpp
+++ b/tests/unit/capi/GEOSConstrainedDelaunayTriangulationTest.cpp
@@ -79,6 +79,21 @@ void object::test<4>()
ensure("curved geometry not supported", result_ == nullptr);
}
+template<>
+template<>
+void object::test<5>()
+{
+ set_test_name("POLYGON ZM input");
+
+ input_ = fromWKT("POLYGON ZM ((0 0 4 3, 1 7 9 8, 6 2 6 2, 0 0 4 4))");
+ ensure(input_);
+
+ result_ = GEOSConstrainedDelaunayTriangulation(input_);
+ ensure(result_);
+
+ ensure(GEOSHasZ(result_));
+ ensure(!GEOSHasM(result_));
+}
} // namespace tut
diff --git a/tests/unit/capi/GEOSDelaunayTriangulationTest.cpp b/tests/unit/capi/GEOSDelaunayTriangulationTest.cpp
index d685ae25b..f0f2ab077 100644
--- a/tests/unit/capi/GEOSDelaunayTriangulationTest.cpp
+++ b/tests/unit/capi/GEOSDelaunayTriangulationTest.cpp
@@ -134,5 +134,21 @@ void object::test<7>()
ensure("curved geometry not supported", result_ == nullptr);
}
+template<>
+template<>
+void object::test<8>()
+{
+ set_test_name("MULTIPOINT ZM input");
+
+ input_ = fromWKT("MULTIPOINT ZM (0 0 4 3, 1 7 9 8, 6 2 6 2)");
+ ensure(input_);
+
+ result_ = GEOSDelaunayTriangulation(input_, 0, 0);
+ ensure(result_);
+
+ ensure(GEOSHasZ(result_));
+ ensure(!GEOSHasM(result_));
+}
+
} // namespace tut
diff --git a/tests/unit/capi/GEOSGetCentroidTest.cpp b/tests/unit/capi/GEOSGetCentroidTest.cpp
index e0fc823fe..2e9b17b5c 100644
--- a/tests/unit/capi/GEOSGetCentroidTest.cpp
+++ b/tests/unit/capi/GEOSGetCentroidTest.cpp
@@ -145,5 +145,22 @@ void object::test<6>()
ensure("curved geometry not supported", result_ == nullptr);
}
+template<>
+template<>
+void object::test<7>()
+{
+ set_test_name("Z/M dimensions ignored");
+
+ input_ = fromWKT("LINESTRING ZM (0 0 4 3, 2 6 9 1)");
+ ensure(input_);
+
+ result_ = GEOSGetCentroid(input_);
+ ensure(result_);
+
+ expected_ = fromWKT("POINT (1 3)");
+ ensure(expected_);
+ ensure_geometry_equals_identical(result_, expected_);
+}
+
} // namespace tut
diff --git a/tests/unit/capi/GEOSLineMergeDirectedTest.cpp b/tests/unit/capi/GEOSLineMergeDirectedTest.cpp
index 1e145abc6..91a2e5072 100644
--- a/tests/unit/capi/GEOSLineMergeDirectedTest.cpp
+++ b/tests/unit/capi/GEOSLineMergeDirectedTest.cpp
@@ -70,5 +70,24 @@ void object::test<3>()
ensure("curved geometries not supported", result_ == nullptr);
}
+
+template<>
+template<>
+void object::test<4>()
+{
+ set_test_name("MULTILINESTRING ZM input");
+
+ input_ = fromWKT("MULTILINESTRING ZM ((0 0 4 5, 2 8 4 3), (2 8 8 6, 10 10 9 3))");
+ ensure(input_);
+
+ result_ = GEOSLineMergeDirected(input_);
+ ensure(result_);
+
+ expected_ = fromWKT("LINESTRING ZM (0 0 4 5, 2 8 4 3, 10 10 9 3)");
+ ensure(expected_);
+
+ ensure_geometry_equals_identical(result_, expected_);
+}
+
} // namesplace tut
diff --git a/tests/unit/capi/GEOSLineMergeTest.cpp b/tests/unit/capi/GEOSLineMergeTest.cpp
index 48817c074..ba728b82c 100644
--- a/tests/unit/capi/GEOSLineMergeTest.cpp
+++ b/tests/unit/capi/GEOSLineMergeTest.cpp
@@ -53,5 +53,23 @@ void object::test<2>()
ensure("curved geometries not supported", result_ == nullptr);
}
+template<>
+template<>
+void object::test<3>()
+{
+ set_test_name("MULTILINESTRING ZM input");
+
+ input_ = fromWKT("MULTILINESTRING ZM ((0 0 4 5, 2 8 4 3), (2 8 8 6, 10 10 9 3))");
+ ensure(input_);
+
+ result_ = GEOSLineMerge(input_);
+ ensure(result_);
+
+ expected_ = fromWKT("LINESTRING ZM (0 0 4 5, 2 8 4 3, 10 10 9 3)");
+ ensure(expected_);
+
+ ensure_geometry_equals_identical(result_, expected_);
+}
+
} // namespace tut
diff --git a/tests/unit/capi/GEOSLineSubstringTest.cpp b/tests/unit/capi/GEOSLineSubstringTest.cpp
index 8135a75d5..9dbc7896b 100644
--- a/tests/unit/capi/GEOSLineSubstringTest.cpp
+++ b/tests/unit/capi/GEOSLineSubstringTest.cpp
@@ -85,22 +85,13 @@ template<>
void object::test<5>
()
{
- input_ = GEOSGeomFromWKT("LINESTRINGZ (0 0 0, 2 2 5)");
+ set_test_name("Z dimension is interpolated, M dimension is dropped");
+
+ input_ = GEOSGeomFromWKT("LINESTRING ZM (0 0 0 0, 2 2 5 10)");
result_ = GEOSLineSubstring(input_, 0, 0.5);
- expected_ = GEOSGeomFromWKT("LINESTRING (0 0 0, 1 1 2.5)");
+ expected_ = GEOSGeomFromWKT("LINESTRING Z (0 0 0, 1 1 2.5)");
- ensure_geometry_equals(result_, expected_);
-
- // check 3rd dimension that isgnored by ensure_geometry_equals
- ensure(GEOSHasZ(result_));
- auto seq = GEOSGeom_getCoordSeq(expected_);
-
- double z0, z1;
- GEOSCoordSeq_getZ(seq, 0, &z0);
- GEOSCoordSeq_getZ(seq, 1, &z1);
-
- ensure_equals(z0, 0);
- ensure_equals(z1, 2.5);
+ ensure_geometry_equals_identical(result_, expected_);
}
// reversed fractions give a reversed substring
diff --git a/tests/unit/capi/GEOSPointOnSurfaceTest.cpp b/tests/unit/capi/GEOSPointOnSurfaceTest.cpp
index 0118234fa..de1ab2d3c 100644
--- a/tests/unit/capi/GEOSPointOnSurfaceTest.cpp
+++ b/tests/unit/capi/GEOSPointOnSurfaceTest.cpp
@@ -231,5 +231,20 @@ void object::test<10>
ensure("curved geometry not supported", result_ == nullptr);
}
+template<>
+template<>
+void object::test<11>()
+{
+ set_test_name("Z/M values ignored");
+
+ input_ = fromWKT("POLYGON ZM ((0 0 4 2, 10 0 8 4, 10 10 12 6, 0 10 8 1, 0 0 4 2))");
+ ensure(input_);
+
+ result_ = GEOSPointOnSurface(input_);
+ ensure(result_);
+ ensure(!GEOSHasZ(result_));
+ ensure(!GEOSHasM(result_));
+}
+
} // namespace tut
diff --git a/tests/unit/capi/GEOSPolygonizeTest.cpp b/tests/unit/capi/GEOSPolygonizeTest.cpp
index 8ed9325bd..145743ccc 100644
--- a/tests/unit/capi/GEOSPolygonizeTest.cpp
+++ b/tests/unit/capi/GEOSPolygonizeTest.cpp
@@ -5,6 +5,8 @@
// geos
#include <geos_c.h>
+#include <array>
+
#include "capi_test_utils.h"
namespace tut {
@@ -205,5 +207,28 @@ void object::test<7>
}
}
+template<>
+template<>
+void object::test<8>
+()
+{
+ set_test_name("LINESTRING ZM inputs");
+
+ geom1_ = fromWKT("LINESTRING ZM (0 0 5 4, 2 0 6 5, 2 2 7 6)");
+ geom2_ = fromWKT("LINESTRING ZM (2 2 7 6, 0 0 5 4)");
+
+ ensure(geom1_);
+ ensure(geom2_);
+
+ std::array<GEOSGeometry*, 2> geoms = {geom1_, geom2_};
+ result_ = GEOSPolygonize(geoms.data(), geoms.size());
+ ensure(result_);
+
+ expected_ = fromWKT("GEOMETRYCOLLECTION ZM (POLYGON ZM ((2 2 7 6, 2 0 6 5, 0 0 5 4, 2 2 7 6)))");
+ ensure(expected_);
+
+ ensure_geometry_equals_identical(result_, expected_);
+}
+
} // namespace tut
diff --git a/tests/unit/capi/GEOSReverseTest.cpp b/tests/unit/capi/GEOSReverseTest.cpp
index cb8895d26..f2e618ee1 100644
--- a/tests/unit/capi/GEOSReverseTest.cpp
+++ b/tests/unit/capi/GEOSReverseTest.cpp
@@ -13,6 +13,22 @@ namespace tut {
// Common data used in test cases.
struct test_capigeosreverse : public capitest::utility {
+ void
+ testReverse(const std::string& wkt_input,
+ const std::string& wkt_output)
+ {
+ GEOSGeometry* input = GEOSGeomFromWKT(wkt_input.c_str());
+ GEOSGeometry* expected_result = GEOSGeomFromWKT(wkt_output.c_str());
+ GEOSGeometry* result = GEOSReverse(input);
+
+ ensure(result != nullptr);
+
+ ensure_geometry_equals_identical(result, expected_result);
+
+ GEOSGeom_destroy(input);
+ GEOSGeom_destroy(expected_result);
+ GEOSGeom_destroy(result);
+ }
};
typedef test_group<test_capigeosreverse> group;
@@ -20,21 +36,6 @@ typedef group::object object;
group test_capigeosreverse_group("capi::GEOSReverse");
-void
-testReverse(const std::string& wkt_input,
- const std::string& wkt_output)
-{
- GEOSGeometry* input = GEOSGeomFromWKT(wkt_input.c_str());
- GEOSGeometry* expected_result = GEOSGeomFromWKT(wkt_output.c_str());
- GEOSGeometry* result = GEOSReverse(input);
-
- ensure(result != nullptr);
- ensure_equals(1, GEOSEqualsExact(result, expected_result, 0.0));
-
- GEOSGeom_destroy(input);
- GEOSGeom_destroy(expected_result);
- GEOSGeom_destroy(result);
-}
//
// Test Cases
@@ -127,4 +128,13 @@ void object::test<9>()
"CIRCULARSTRING (2 0, 1 1, 0 0)");
}
+template<>
+template<>
+void object::test<10>()
+{
+ testReverse("POINT ZM (1 2 3 4)", "POINT ZM (1 2 3 4)");
+ testReverse("LINESTRING ZM (1 2 3 4, 5 6 7 8)", "LINESTRING ZM (5 6 7 8, 1 2 3 4)");
+ testReverse("POLYGON ZM ((1 2 3 4, 5 6 7 8, 9 10 11 12, 1 2 3 4))", "POLYGON ZM ((1 2 3 4, 9 10 11 12, 5 6 7 8, 1 2 3 4))");
+}
+
} // namespace tut
-----------------------------------------------------------------------
Summary of changes:
capi/geos_c.h.in | 49 +++++++++++++++++-----
.../GEOSConstrainedDelaunayTriangulationTest.cpp | 15 +++++++
tests/unit/capi/GEOSDelaunayTriangulationTest.cpp | 16 +++++++
tests/unit/capi/GEOSGetCentroidTest.cpp | 17 ++++++++
tests/unit/capi/GEOSLineMergeDirectedTest.cpp | 19 +++++++++
tests/unit/capi/GEOSLineMergeTest.cpp | 18 ++++++++
tests/unit/capi/GEOSLineSubstringTest.cpp | 19 +++------
tests/unit/capi/GEOSPointOnSurfaceTest.cpp | 15 +++++++
tests/unit/capi/GEOSPolygonizeTest.cpp | 25 +++++++++++
tests/unit/capi/GEOSReverseTest.cpp | 40 +++++++++++-------
10 files changed, 193 insertions(+), 40 deletions(-)
hooks/post-receive
--
GEOS
More information about the geos-commits
mailing list