[geos-commits] [SCM] GEOS branch main updated. e0ff2cd9eda39cf7a3283e6321b0c69eca5db49b
git at osgeo.org
git at osgeo.org
Thu Oct 1 05:34:02 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 e0ff2cd9eda39cf7a3283e6321b0c69eca5db49b (commit)
from 7c25167af9fd326cd957ad588296495ac188d231 (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 e0ff2cd9eda39cf7a3283e6321b0c69eca5db49b
Author: Mohd Quamar Tyagi <104281681+Tyagiquamar at users.noreply.github.com>
Date: Thu Oct 1 18:03:32 2026 +0530
GEOSProject_r: throw IllegalArgumentException and handle empty points (#1547)
Fixes #1534
diff --git a/capi/geos_ts_c.cpp b/capi/geos_ts_c.cpp
index 179015f24..e118726e7 100644
--- a/capi/geos_ts_c.cpp
+++ b/capi/geos_ts_c.cpp
@@ -4773,8 +4773,8 @@ extern "C" {
{
return execute(extHandle, -1.0, [&]() {
const Point* point = dynamic_cast<const Point*>(p);
- if(!point) {
- throw std::runtime_error("third argument of GEOSProject_r must be Point");
+ if(!point || point->isEmpty()) {
+ throw IllegalArgumentException("third argument of GEOSProject_r must be non-empty Point");
}
const geos::geom::Coordinate inputPt(*p->getCoordinate());
const auto inputLine = convertToLineIfNeeded(extHandle, g);
diff --git a/tests/unit/capi/GEOSProjectTest.cpp b/tests/unit/capi/GEOSProjectTest.cpp
index a8f550809..6c3ac7d4c 100644
--- a/tests/unit/capi/GEOSProjectTest.cpp
+++ b/tests/unit/capi/GEOSProjectTest.cpp
@@ -143,4 +143,40 @@ void object::test<6>
ensure_equals("GEOSProjectNormalized result does not match", dist_norm, 0.5, 1e-3);
}
+// Empty point as second argument returns -1.0 instead of crashing
+// https://github.com/libgeos/geos/issues/1534
+template<>
+template<>
+void object::test<7>
+()
+{
+ geom1_ = GEOSGeomFromWKT("LINESTRING (0 0, 0 2)");
+ geom2_ = GEOSGeomFromWKT("POINT EMPTY");
+
+ ensure_equals(GEOSProject(geom1_, geom2_), -1.0);
+ ensure_equals(GEOSProjectNormalized(geom1_, geom2_), -1.0);
+}
+
+// Invalid second argument reports IllegalArgumentException
+// https://github.com/libgeos/geos/issues/1534
+template<>
+template<>
+void object::test<8>
+()
+{
+ useContext();
+
+ geom1_ = fromWKT("LINESTRING (0 0, 0 2)");
+ geom2_ = fromWKT("LINESTRING (0 0, 0 2)");
+
+ std::string errorMsg;
+ GEOSContext_setErrorMessageHandler_r(ctxt_, [](const char* message, void* userdata) {
+ static_cast<std::string*>(userdata)->append(message);
+ }, &errorMsg);
+
+ ensure_equals(GEOSProject_r(ctxt_, geom1_, geom2_), -1.0);
+ ensure("error message contains IllegalArgumentException",
+ errorMsg.find("IllegalArgumentException") != std::string::npos);
+}
+
} // namespace tut
-----------------------------------------------------------------------
Summary of changes:
capi/geos_ts_c.cpp | 4 ++--
tests/unit/capi/GEOSProjectTest.cpp | 36 ++++++++++++++++++++++++++++++++++++
2 files changed, 38 insertions(+), 2 deletions(-)
hooks/post-receive
--
GEOS
More information about the geos-commits
mailing list