[geos-commits] [SCM] GEOS branch main updated. 4f2442b078b7e26df23ced6193dc62f11090f674

git at osgeo.org git at osgeo.org
Wed Jul 8 04:30:09 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  4f2442b078b7e26df23ced6193dc62f11090f674 (commit)
      from  678482bd85082ab0c671a100373a1d9c46764ffe (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 4f2442b078b7e26df23ced6193dc62f11090f674
Author: Daniel Baston <dbaston at gmail.com>
Date:   Wed Jul 8 07:29:46 2026 -0400

    GEOSPreparedDistance: fallback to brute-force distance for curved inputs (#1467)
    
    * FacetSequenceTreeBuilder: guard against curved components
    
    * GEOSPreparedDistance: fallback to brute-force distance for curved inputs

diff --git a/capi/geos_ts_c.cpp b/capi/geos_ts_c.cpp
index 32254f9e3..21202a2b0 100644
--- a/capi/geos_ts_c.cpp
+++ b/capi/geos_ts_c.cpp
@@ -4587,6 +4587,10 @@ extern "C" {
                          const PreparedGeometry* pg, const Geometry* g)
     {
         return execute(extHandle, [&]() -> geos::geom::CoordinateSequence* {
+            if (g->hasCurvedComponents()) {
+                geos::operation::distance::DistanceOp dop(pg->getGeometry(), *g);
+                return dop.nearestPoints().release();
+            }
             return pg->nearestPoints(g).release();
         });
     }
@@ -4597,7 +4601,11 @@ extern "C" {
                          const Geometry* g, double* dist)
     {
         return execute(extHandle, 0, [&]() {
-            *dist = pg->distance(g);
+            if (g->hasCurvedComponents()) {
+                *dist = pg->getGeometry().distance(g);
+            } else {
+                *dist = pg->distance(g);
+            }
             return 1;
         });
     }
@@ -4608,10 +4616,14 @@ extern "C" {
                          const Geometry* g, double dist)
     {
         return execute(extHandle, 2, [&]() {
+            if (g->hasCurvedComponents()) {
+                return pg->getGeometry().isWithinDistance(g, dist);
+            }
             return pg->isWithinDistance(g, dist);
         });
     }
 
+
 //-----------------------------------------------------------------
 // STRtree
 //-----------------------------------------------------------------
diff --git a/src/operation/distance/FacetSequenceTreeBuilder.cpp b/src/operation/distance/FacetSequenceTreeBuilder.cpp
index ec10c8c57..9727abe19 100644
--- a/src/operation/distance/FacetSequenceTreeBuilder.cpp
+++ b/src/operation/distance/FacetSequenceTreeBuilder.cpp
@@ -30,6 +30,8 @@ namespace distance {
 std::unique_ptr<TemplateSTRtree<const FacetSequence*>>
 FacetSequenceTreeBuilder::build(const Geometry* g)
 {
+    util::ensureNoCurvedComponents(g);
+
     std::unique_ptr<TemplateSTRtree<const FacetSequence*>> tree(new FacetSequenceTree(computeFacetSequences(g)));
 
     tree->build();
diff --git a/tests/unit/capi/GEOSPreparedDistanceTest.cpp b/tests/unit/capi/GEOSPreparedDistanceTest.cpp
index 5ea53f1e0..758d18432 100644
--- a/tests/unit/capi/GEOSPreparedDistanceTest.cpp
+++ b/tests/unit/capi/GEOSPreparedDistanceTest.cpp
@@ -213,5 +213,18 @@ void object::test<14>
     );
 }
 
+template<>
+template<>
+void object::test<15>()
+{
+    set_test_name("curved second geometry argument");
+
+    checkDistance(
+        "LINESTRING (0 0, 0 5)",
+        "CIRCULARSTRING (-5 0, 0 -5, 5 0)",
+        5
+    );
+}
+
 } // namespace tut
 
diff --git a/tests/unit/capi/GEOSPreparedDistanceWithinTest.cpp b/tests/unit/capi/GEOSPreparedDistanceWithinTest.cpp
index 7be2a2d2b..f29c54fb1 100644
--- a/tests/unit/capi/GEOSPreparedDistanceWithinTest.cpp
+++ b/tests/unit/capi/GEOSPreparedDistanceWithinTest.cpp
@@ -280,5 +280,19 @@ void object::test<16>()
     );
 }
 
+template<>
+template<>
+void object::test<17>()
+{
+    set_test_name("curved second geometry argument");
+
+    checkDistanceWithin(
+        "LINESTRING (0 0, 0 5)",
+        "CIRCULARSTRING (-5 0, 0 -5, 5 0)",
+        5,
+        1
+    );
+}
+
 } // namespace tut
 
diff --git a/tests/unit/capi/GEOSPreparedNearestPointsTest.cpp b/tests/unit/capi/GEOSPreparedNearestPointsTest.cpp
index effa0628b..800266ee1 100644
--- a/tests/unit/capi/GEOSPreparedNearestPointsTest.cpp
+++ b/tests/unit/capi/GEOSPreparedNearestPointsTest.cpp
@@ -153,5 +153,19 @@ void object::test<6>
     );
 }
 
+template<>
+template<>
+void object::test<7>()
+{
+    set_test_name("curved second geometry argument");
+
+    checkNearestPoints(
+        "LINESTRING (3 0, 4 0)",
+        "CIRCULARSTRING (0 0, 1 1, 2 0)",
+        3, 0, 2, 0
+    );
+}
+
+
 } // namespace tut
 

-----------------------------------------------------------------------

Summary of changes:
 capi/geos_ts_c.cpp                                  | 14 +++++++++++++-
 src/operation/distance/FacetSequenceTreeBuilder.cpp |  2 ++
 tests/unit/capi/GEOSPreparedDistanceTest.cpp        | 13 +++++++++++++
 tests/unit/capi/GEOSPreparedDistanceWithinTest.cpp  | 14 ++++++++++++++
 tests/unit/capi/GEOSPreparedNearestPointsTest.cpp   | 14 ++++++++++++++
 5 files changed, 56 insertions(+), 1 deletion(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list