[geos-commits] [SCM] GEOS branch main updated. 553d99b24f474aec191d4d5c83e7a346dd7ee91f
git at osgeo.org
git at osgeo.org
Sun May 4 12:55:19 PDT 2025
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 553d99b24f474aec191d4d5c83e7a346dd7ee91f (commit)
from ddd197d17589d1ce8106eee37bd4460026a854c4 (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 553d99b24f474aec191d4d5c83e7a346dd7ee91f
Author: Aurele Ferotin <aurele.ferotin at icloud.com>
Date: Sun May 4 21:54:53 2025 +0200
Add GEOSCoordSeq_hasZ, GEOSCoordSeq_hasM (#1261)
diff --git a/capi/geos_c.cpp b/capi/geos_c.cpp
index 6aa9952a0..19f340be3 100644
--- a/capi/geos_c.cpp
+++ b/capi/geos_c.cpp
@@ -1135,6 +1135,18 @@ extern "C" {
return GEOSCoordSeq_copyToArrays_r(handle, s, x, y, z, m);
}
+ char
+ GEOSCoordSeq_hasZ(CoordinateSequence* s)
+ {
+ return GEOSCoordSeq_hasZ_r(handle, s);
+ }
+
+ char
+ GEOSCoordSeq_hasM(CoordinateSequence* s)
+ {
+ return GEOSCoordSeq_hasM_r(handle, s);
+ }
+
int
GEOSCoordSeq_setOrdinate(CoordinateSequence* s, unsigned int idx, unsigned int dim, double val)
{
diff --git a/capi/geos_c.h.in b/capi/geos_c.h.in
index 3ca7a9aac..30e7bb960 100644
--- a/capi/geos_c.h.in
+++ b/capi/geos_c.h.in
@@ -495,6 +495,16 @@ extern void GEOS_DLL GEOSCoordSeq_destroy_r(
GEOSContextHandle_t handle,
GEOSCoordSequence* s);
+/** \see GEOSCoordSeq_hasZ */
+extern char GEOS_DLL GEOSCoordSeq_hasZ_r(
+ GEOSContextHandle_t handle,
+ GEOSCoordSequence* s);
+
+/** \see GEOSCoordSeq_hasM */
+extern char GEOS_DLL GEOSCoordSeq_hasM_r(
+ GEOSContextHandle_t handle,
+ GEOSCoordSequence* s);
+
/** \see GEOSCoordSeq_setX */
extern int GEOS_DLL GEOSCoordSeq_setX_r(
GEOSContextHandle_t handle,
@@ -2346,6 +2356,24 @@ extern GEOSCoordSequence GEOS_DLL *GEOSCoordSeq_clone(const GEOSCoordSequence* s
*/
extern void GEOS_DLL GEOSCoordSeq_destroy(GEOSCoordSequence* s);
+/**
+* Tests whether the input coordinate sequence has Z coordinates.
+* \param s the coordinate sequence to test
+* \return 1 on true, 0 on false, 2 on exception
+*
+* \since 3.14
+*/
+extern char GEOS_DLL GEOSCoordSeq_hasZ(GEOSCoordSequence* s);
+
+/**
+* Tests whether the input coordinate sequence has M coordinates.
+* \param s the coordinate sequence to test
+* \return 1 on true, 0 on false, 2 on exception
+*
+* \since 3.14
+*/
+extern char GEOS_DLL GEOSCoordSeq_hasM(GEOSCoordSequence* s);
+
/**
* Set X ordinate values in a coordinate sequence.
* \param s the coordinate sequence
diff --git a/capi/geos_ts_c.cpp b/capi/geos_ts_c.cpp
index c6a824cbb..75536a98d 100644
--- a/capi/geos_ts_c.cpp
+++ b/capi/geos_ts_c.cpp
@@ -2849,6 +2849,22 @@ extern "C" {
});
}
+ char
+ GEOSCoordSeq_hasZ_r(GEOSContextHandle_t extHandle, CoordinateSequence* cs)
+ {
+ return execute(extHandle, 2, [&]() {
+ return cs->hasZ();
+ });
+ }
+
+ char
+ GEOSCoordSeq_hasM_r(GEOSContextHandle_t extHandle, CoordinateSequence* cs)
+ {
+ return execute(extHandle, 2, [&]() {
+ return cs->hasM();
+ });
+ }
+
int
GEOSCoordSeq_setOrdinate_r(GEOSContextHandle_t extHandle, CoordinateSequence* cs,
unsigned int idx, unsigned int dim, double val)
diff --git a/src/geom/CoordinateSequence.cpp b/src/geom/CoordinateSequence.cpp
index 014c3188b..a6459da85 100644
--- a/src/geom/CoordinateSequence.cpp
+++ b/src/geom/CoordinateSequence.cpp
@@ -68,8 +68,13 @@ CoordinateSequence::CoordinateSequence(std::size_t sz, bool hasz, bool hasm, boo
}
CoordinateSequence::CoordinateSequence(std::size_t sz, std::size_t dim) :
+#ifdef GEOS_COORDSEQ_PADZ
m_vect(sz * std::max(static_cast<std::uint8_t>(dim), static_cast<std::uint8_t>(3))),
m_stride(std::max(static_cast<std::uint8_t>(dim), static_cast<std::uint8_t>(3))),
+#else
+ m_vect(sz * static_cast<std::uint8_t>(dim)),
+ m_stride(static_cast<std::uint8_t>(dim)),
+#endif
m_hasdim(dim > 0),
m_hasz(dim >= 3),
m_hasm(dim == 4)
diff --git a/tests/unit/capi/GEOSCoordSeqTest.cpp b/tests/unit/capi/GEOSCoordSeqTest.cpp
index 8adf02658..f81572b23 100644
--- a/tests/unit/capi/GEOSCoordSeqTest.cpp
+++ b/tests/unit/capi/GEOSCoordSeqTest.cpp
@@ -881,4 +881,52 @@ void object::test<27>()
ensure_equals(m, 4);
}
+template<>
+template<>
+void object::test<28>()
+{
+ set_test_name("hasZ, hasM, getCoordinateType on XY sequence");
+
+ cs_ = GEOSCoordSeq_createWithDimensions(2, 0, 0);
+
+ ensure_not("hasZ", GEOSCoordSeq_hasZ(cs_));
+ ensure_not("hasM", GEOSCoordSeq_hasM(cs_));
+}
+
+template<>
+template<>
+void object::test<29>()
+{
+ set_test_name("hasZ, hasM, getCoordinateType on XYZ sequence");
+
+ cs_ = GEOSCoordSeq_createWithDimensions(2, 1, 0);
+
+ ensure("hasZ", GEOSCoordSeq_hasZ(cs_));
+ ensure_not("hasM", GEOSCoordSeq_hasM(cs_));
+}
+
+template<>
+template<>
+void object::test<30>()
+{
+ set_test_name("hasZ, hasM, getCoordinateType on XYM sequence");
+
+ cs_ = GEOSCoordSeq_createWithDimensions(2, 0, 1);
+
+ ensure_not("hasZ", GEOSCoordSeq_hasZ(cs_));
+ ensure("hasM", GEOSCoordSeq_hasM(cs_));
+}
+
+template<>
+template<>
+void object::test<31>()
+{
+ set_test_name("hasZ, hasM, getCoordinateType on XYZM sequence");
+
+ cs_ = GEOSCoordSeq_createWithDimensions(2, 1, 1);
+
+ ensure("hasZ", GEOSCoordSeq_hasZ(cs_));
+ ensure("hasM", GEOSCoordSeq_hasM(cs_));
+}
+
} // namespace tut
-----------------------------------------------------------------------
Summary of changes:
capi/geos_c.cpp | 12 +++++++++
capi/geos_c.h.in | 28 +++++++++++++++++++++
capi/geos_ts_c.cpp | 16 ++++++++++++
src/geom/CoordinateSequence.cpp | 5 ++++
tests/unit/capi/GEOSCoordSeqTest.cpp | 48 ++++++++++++++++++++++++++++++++++++
5 files changed, 109 insertions(+)
hooks/post-receive
--
GEOS
More information about the geos-commits
mailing list