[geos-commits] [SCM] GEOS branch main updated. b3d6d20a94fdbe6a8401d176668a6d7d76465673

git at osgeo.org git at osgeo.org
Thu Nov 30 08:35:50 PST 2023


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  b3d6d20a94fdbe6a8401d176668a6d7d76465673 (commit)
      from  ddba88a37bd8edb0acc08c9753a1a0e28de3baee (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 b3d6d20a94fdbe6a8401d176668a6d7d76465673
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Thu Nov 30 08:35:16 2023 -0800

    Fix and test for LargestEmptyCircle crash on malformed input (#1004)
    
    * Fix and tests for GH-1003
    * Call to init() was missing? Does not explain why the bug in the original issue seemed tied to particular coordinates, as the fix will apply across all inputs. So be warned, there may still be something hiding in there.

diff --git a/src/algorithm/construct/IndexedDistanceToPoint.cpp b/src/algorithm/construct/IndexedDistanceToPoint.cpp
index 92c703ef8..e1fd58571 100644
--- a/src/algorithm/construct/IndexedDistanceToPoint.cpp
+++ b/src/algorithm/construct/IndexedDistanceToPoint.cpp
@@ -36,7 +36,7 @@ IndexedDistanceToPoint::IndexedDistanceToPoint(const Geometry& geom)
 void IndexedDistanceToPoint::init()
 {
     if (facetDistance != nullptr)
-      return;
+        return;
     ptLocator.reset(new IndexedPointInPolygonsLocator(targetGeometry));
     facetDistance.reset(new IndexedFacetDistance(&targetGeometry));
 }
@@ -62,7 +62,8 @@ bool IndexedDistanceToPoint::isInArea(const Point& pt)
 std::unique_ptr<geom::CoordinateSequence> 
 IndexedDistanceToPoint::nearestPoints(const Point& pt)
 {
+    init();
     return facetDistance->nearestPoints(&pt);
 }
 
-}}}
\ No newline at end of file
+}}}
diff --git a/tests/unit/algorithm/construct/LargestEmptyCircleTest.cpp b/tests/unit/algorithm/construct/LargestEmptyCircleTest.cpp
index b0110fa0f..5a09e2ef8 100644
--- a/tests/unit/algorithm/construct/LargestEmptyCircleTest.cpp
+++ b/tests/unit/algorithm/construct/LargestEmptyCircleTest.cpp
@@ -316,4 +316,30 @@ void object::test<19>()
         0.01, 5.5, 4.5, 2.12 );
 }
 
+
+// https://trac.osgeo.org/postgis/ticket/5626
+template<>
+template<>
+void object::test<20>()
+{
+    checkCircle(
+        "POINT(-11 40)", // input
+        "POLYGON((-71.1 42.3,-71.1 42.4,-71.2 42.3,-71.1 42.3))", // boundary
+        0.1, // test tolerance
+        -71.15, 42.34, 60.19588 ); // expected x, y, radius
+}
+
+
+// https://trac.osgeo.org/postgis/ticket/5626
+template<>
+template<>
+void object::test<21>()
+{
+    checkCircle(
+        "POINT(-11.1111111 40)", // input
+        "POLYGON((-71.0821 42.3036,-71.0821 42.3936,-71.0901 42.3036,-71.0821 42.3036))", // boundary
+        1, // test tolerance
+        -71.15, 42.34, 60.19588 ); // expected x, y, radius
+}
+
 } // namespace tut

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

Summary of changes:
 src/algorithm/construct/IndexedDistanceToPoint.cpp |  5 +++--
 .../algorithm/construct/LargestEmptyCircleTest.cpp | 26 ++++++++++++++++++++++
 2 files changed, 29 insertions(+), 2 deletions(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list