[geos-commits] [SCM] GEOS branch main updated. 5885024d0f7f58085c8ca5260be58863c24410e5
git at osgeo.org
git at osgeo.org
Thu Oct 1 07:45:49 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 5885024d0f7f58085c8ca5260be58863c24410e5 (commit)
via c24beb890360ba4a3afb987f332f9a094cd856f0 (commit)
from a8361685706776ba18266ac873d914d99f60ffad (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 5885024d0f7f58085c8ca5260be58863c24410e5
Author: Sandro Santilli <strk at kbt.io>
Date: Thu Oct 1 16:45:27 2026 +0200
Allow passign null as locations to GEOSisSimpleWithParams
diff --git a/capi/geos_c.h.in b/capi/geos_c.h.in
index 906fb311e..8121af536 100644
--- a/capi/geos_c.h.in
+++ b/capi/geos_c.h.in
@@ -3708,7 +3708,8 @@ extern char GEOS_DLL GEOSisSimple(const GEOSGeometry* g);
*
* \param g The geometry to test
* \param findAllLocations Whether to return all self-intersection locations, or just one
-* \param locations A pointer in which the location GEOSGeometry will be placed
+* \param locations A pointer in which the location GEOSGeometry will be placed, if any.
+* Pass null if you don't want locations.
* \return 1 when simple, 0 when non-simple, 2 on exception
*
* \since 3.14
diff --git a/capi/geos_ts_c.cpp b/capi/geos_ts_c.cpp
index e35bc743e..a21c00528 100644
--- a/capi/geos_ts_c.cpp
+++ b/capi/geos_ts_c.cpp
@@ -1661,17 +1661,19 @@ extern "C" {
op->setFindAllLocations( params->findAllLocations );
- *result = nullptr;
bool simple = op->isSimple();
- if (!simple) {
- auto locations = op->getNonSimpleLocations();
- if (locations.size() == 1 || ! params->findAllLocations ) {
- *result = extHandle->geomFactory->createPoint(locations.front()).release();
- } else {
- *result = extHandle->geomFactory->createMultiPoint(locations).release();
+ if ( result ) {
+ *result = nullptr;
+ if (!simple) {
+ auto locations = op->getNonSimpleLocations();
+ if (locations.size() == 1 || ! params->findAllLocations ) {
+ *result = extHandle->geomFactory->createPoint(locations.front()).release();
+ } else {
+ *result = extHandle->geomFactory->createMultiPoint(locations).release();
+ }
+ (*result)->setSRID(inputGeom->getSRID());
}
- (*result)->setSRID(inputGeom->getSRID());
}
return simple;
diff --git a/tests/unit/capi/GEOSisSimpleWithParamsTest.cpp b/tests/unit/capi/GEOSisSimpleWithParamsTest.cpp
index 307d53573..6bb1b718e 100644
--- a/tests/unit/capi/GEOSisSimpleWithParamsTest.cpp
+++ b/tests/unit/capi/GEOSisSimpleWithParamsTest.cpp
@@ -32,8 +32,7 @@ void object::test<1>()
{
set_test_name("MultiLineString containing two rings that touch at their endpoints, default params");
- input_ = GEOSGeomFromWKT("MULTILINESTRING( (0 0, -10 10,-10 -10, 0 0), (0 0,20 -10,20 10,0 0) )");
- ensure(nullptr != input_);
+ input_ = fromWKT("MULTILINESTRING( (0 0, -10 10,-10 -10, 0 0), (0 0,20 -10,20 10,0 0) )");
ensure_equals((int)GEOSisSimpleWithParams(input_, _params, &result_), 0);
ensure_geometry_equals(result_, "POINT (0 0)");
}
@@ -44,8 +43,7 @@ void object::test<2>()
{
set_test_name("MultiLineString containing two rings that touch at their endpoints, EndPoint boundary node rule");
- input_ = GEOSGeomFromWKT("MULTILINESTRING( (0 0, -10 10,-10 -10, 0 0), (0 0,20 -10,20 10,0 0) )");
- ensure(nullptr != input_);
+ input_ = fromWKT("MULTILINESTRING( (0 0, -10 10,-10 -10, 0 0), (0 0,20 -10,20 10,0 0) )");
GEOSisSimpleParams_setBoundaryNodeRule(_params, GEOSRELATE_BNR_ENDPOINT);
ensure_equals((int)GEOSisSimpleWithParams(input_, _params, &result_), 1);
ensure(result_ == nullptr);
@@ -57,8 +55,7 @@ void object::test<3>()
{
set_test_name("MultiLineString containing two rings that touch at their endpoints, MultiValent boundary node rule");
- input_ = GEOSGeomFromWKT("MULTILINESTRING( (0 0, -10 10,-10 -10, 0 0), (0 0,20 -10,20 10,0 0) )");
- ensure(nullptr != input_);
+ input_ = fromWKT("MULTILINESTRING( (0 0, -10 10,-10 -10, 0 0), (0 0,20 -10,20 10,0 0) )");
GEOSisSimpleParams_setBoundaryNodeRule(_params, GEOSRELATE_BNR_MULTIVALENT_ENDPOINT);
ensure_equals((int)GEOSisSimpleWithParams(input_, _params, &result_), 1);
ensure(result_ == nullptr);
@@ -70,8 +67,7 @@ void object::test<4>()
{
set_test_name("MultiLineString containing two rings that touch at their endpoints, MonoValent boundary node rule");
- input_ = GEOSGeomFromWKT("MULTILINESTRING( (0 0, -10 10,-10 -10, 0 0), (0 0,20 -10,20 10,0 0) )");
- ensure(nullptr != input_);
+ input_ = fromWKT("MULTILINESTRING( (0 0, -10 10,-10 -10, 0 0), (0 0,20 -10,20 10,0 0) )");
GEOSisSimpleParams_setBoundaryNodeRule(_params, GEOSRELATE_BNR_MONOVALENT_ENDPOINT);
ensure_equals((int)GEOSisSimpleWithParams(input_, _params, &result_), 0);
ensure_geometry_equals(result_, "POINT (0 0)");
@@ -83,8 +79,7 @@ void object::test<5>()
{
set_test_name("MultiLineString with a line intersected by two other lines, finding all locations");
- input_ = GEOSGeomFromWKT("MULTILINESTRING( (0 0,10 0),(2 -5,2 5),(4 -5, 4 5) )");
- ensure(nullptr != input_);
+ input_ = fromWKT("MULTILINESTRING( (0 0,10 0),(2 -5,2 5),(4 -5, 4 5) )");
GEOSisSimpleParams_setFindAllLocations(_params, 1);
ensure_equals((int)GEOSisSimpleWithParams(input_, _params, &result_), 0);
ensure_equals(GEOSGetNumGeometries(result_), 2);
@@ -96,9 +91,8 @@ void object::test<6>()
{
set_test_name("Non-simple line with a SRID");
- input_ = GEOSGeomFromWKT("LINESTRING(0 0,10 0,2 -5,2 5,6 -8)");
+ input_ = fromWKT("LINESTRING(0 0,10 0,2 -5,2 5,6 -8)");
GEOSSetSRID(input_, 3857);
- ensure(nullptr != input_);
ensure_equals((int)GEOSisSimpleWithParams(input_, _params, &result_), 0);
ensure_equals(GEOSGetNumGeometries(result_), 1);
ensure_equals(GEOSGetSRID(result_), 3857);
@@ -110,12 +104,24 @@ void object::test<7>()
{
set_test_name("Non-simple line with a SRID and finding all locations");
- input_ = GEOSGeomFromWKT("LINESTRING(0 0,10 0,2 -5,2 5,6 -8)");
+ input_ = fromWKT("LINESTRING(0 0,10 0,2 -5,2 5,6 -8)");
GEOSSetSRID(input_, 4326);
- ensure(nullptr != input_);
GEOSisSimpleParams_setFindAllLocations(_params, 1);
ensure_equals((int)GEOSisSimpleWithParams(input_, _params, &result_), 0);
ensure_equals(GEOSGetNumGeometries(result_), 3);
ensure_equals(GEOSGetSRID(result_), 4326);
}
+
+template<>
+template<>
+void object::test<8>()
+{
+ set_test_name("Passing NULL as locations for non-simple line");
+
+ input_ = fromWKT("LINESTRING(0 0,10 0,2 -5,2 5,6 -8)");
+ GEOSSetSRID(input_, 4326);
+ GEOSisSimpleParams_setFindAllLocations(_params, 1);
+ ensure_equals((int)GEOSisSimpleWithParams(input_, _params, NULL), 0);
+}
+
} // namespace tut
commit c24beb890360ba4a3afb987f332f9a094cd856f0
Author: Sandro Santilli <strk at kbt.io>
Date: Thu Oct 1 16:36:09 2026 +0200
Fix capitalization
diff --git a/capi/geos_c.h.in b/capi/geos_c.h.in
index 2635099fd..906fb311e 100644
--- a/capi/geos_c.h.in
+++ b/capi/geos_c.h.in
@@ -1686,12 +1686,12 @@ extern char GEOS_DLL GEOSisSimple_r(
GEOSContextHandle_t handle,
const GEOSGeometry* g);
-/** \see GEOSIsSimpleParams_create */
+/** \see GEOSisSimpleParams_create */
extern GEOSisSimpleParams GEOS_DLL *
GEOSisSimpleParams_create_r(
GEOSContextHandle_t handle);
-/** \see GEOSIsSimpleParams_destroy */
+/** \see GEOSisSimpleParams_destroy */
extern void GEOS_DLL
GEOSisSimpleParams_destroy_r(
GEOSContextHandle_t handle,
-----------------------------------------------------------------------
Summary of changes:
capi/geos_c.h.in | 7 +++---
capi/geos_ts_c.cpp | 18 ++++++++------
tests/unit/capi/GEOSisSimpleWithParamsTest.cpp | 34 +++++++++++++++-----------
3 files changed, 34 insertions(+), 25 deletions(-)
hooks/post-receive
--
GEOS
More information about the geos-commits
mailing list