[geos-commits] [SCM] GEOS branch master updated. 099e74b3127348e1f8544ab279b609e2fdc6cc74

git at osgeo.org git at osgeo.org
Thu May 7 12:08:13 PDT 2020


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, master has been updated
       via  099e74b3127348e1f8544ab279b609e2fdc6cc74 (commit)
      from  a57d337ca05c1089f7935d3548e18e8ed85e19d6 (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 099e74b3127348e1f8544ab279b609e2fdc6cc74
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Thu May 7 08:58:26 2020 -0700

    Add boundary argument to CAPI for LargestEmptyCircle

diff --git a/capi/geos_c.cpp b/capi/geos_c.cpp
index 8e4547d..363d8bf 100644
--- a/capi/geos_c.cpp
+++ b/capi/geos_c.cpp
@@ -464,9 +464,9 @@ extern "C" {
     }
 
     Geometry*
-    GEOSLargestEmptyCircle(const Geometry* g, double tolerance)
+    GEOSLargestEmptyCircle(const Geometry* g, const Geometry* boundary, double tolerance)
     {
-        return GEOSLargestEmptyCircle_r(handle, g, tolerance);
+        return GEOSLargestEmptyCircle_r(handle, g, boundary, tolerance);
     }
 
     Geometry*
diff --git a/capi/geos_c.h.in b/capi/geos_c.h.in
index e411f79..ccccbc1 100644
--- a/capi/geos_c.h.in
+++ b/capi/geos_c.h.in
@@ -562,7 +562,7 @@ extern GEOSGeometry GEOS_DLL *GEOSMinimumRotatedRectangle_r(GEOSContextHandle_t
                                                const GEOSGeometry* g);
 
 extern GEOSGeometry GEOS_DLL *GEOSMaximumInscribedCircle_r(GEOSContextHandle_t handle, const GEOSGeometry* g, double tolerance);
-extern GEOSGeometry GEOS_DLL *GEOSLargestEmptyCircle_r(GEOSContextHandle_t handle, const GEOSGeometry* g, double tolerance);
+extern GEOSGeometry GEOS_DLL *GEOSLargestEmptyCircle_r(GEOSContextHandle_t handle, const GEOSGeometry* g, const GEOSGeometry* boundary, double tolerance);
 
 /* Returns a LINESTRING geometry which represents the minimum diameter of the geometry.
  * The minimum diameter is defined to be the width of the smallest band that
@@ -1632,7 +1632,7 @@ extern GEOSGeometry GEOS_DLL *GEOSMaximumInscribedCircle(const GEOSGeometry* g,
  * Returns a two-point linestring, with one point at the center of the inscribed circle and the other
  * on the boundary of the inscribed circle.
  */
-extern GEOSGeometry GEOS_DLL *GEOSLargestEmptyCircle(const GEOSGeometry* g, double tolerance);
+extern GEOSGeometry GEOS_DLL *GEOSLargestEmptyCircle(const GEOSGeometry* g, const GEOSGeometry* boundary, double tolerance);
 
 /* Returns a LINESTRING geometry which represents the minimum diameter of the geometry.
  * The minimum diameter is defined to be the width of the smallest band that
diff --git a/capi/geos_ts_c.cpp b/capi/geos_ts_c.cpp
index a4b2692..519da23 100644
--- a/capi/geos_ts_c.cpp
+++ b/capi/geos_ts_c.cpp
@@ -1172,10 +1172,10 @@ extern "C" {
     }
 
     Geometry*
-    GEOSLargestEmptyCircle_r(GEOSContextHandle_t extHandle, const Geometry* g, double tolerance)
+    GEOSLargestEmptyCircle_r(GEOSContextHandle_t extHandle, const Geometry* g, const GEOSGeometry* boundary, double tolerance)
     {
         return execute(extHandle, [&]() {
-            geos::algorithm::construct::LargestEmptyCircle lec(g, tolerance);
+            geos::algorithm::construct::LargestEmptyCircle lec(g, boundary, tolerance);
             auto g3 = lec.getRadiusLine();
             g3->setSRID(g->getSRID());
             return g3.release();
diff --git a/include/geos/algorithm/construct/LargestEmptyCircle.h b/include/geos/algorithm/construct/LargestEmptyCircle.h
index 6bd9d2c..84eed26 100644
--- a/include/geos/algorithm/construct/LargestEmptyCircle.h
+++ b/include/geos/algorithm/construct/LargestEmptyCircle.h
@@ -68,6 +68,7 @@ public:
     * @param p_tolerance the distance tolerance for computing the circle center point
     */
     LargestEmptyCircle(const geom::Geometry* p_obstacles, double p_tolerance);
+    LargestEmptyCircle(const geom::Geometry* p_obstacles, const geom::Geometry* p_boundary, double p_tolerance);
     ~LargestEmptyCircle() = default;
 
     /**
diff --git a/src/algorithm/construct/LargestEmptyCircle.cpp b/src/algorithm/construct/LargestEmptyCircle.cpp
index 82ebfbe..2cdd47f 100644
--- a/src/algorithm/construct/LargestEmptyCircle.cpp
+++ b/src/algorithm/construct/LargestEmptyCircle.cpp
@@ -43,16 +43,35 @@ namespace construct { // geos.algorithm.construct
 
 
 LargestEmptyCircle::LargestEmptyCircle(const Geometry* p_obstacles, double p_tolerance)
+    : LargestEmptyCircle(p_obstacles, nullptr, p_tolerance)
+{
+}
+
+LargestEmptyCircle::LargestEmptyCircle(const Geometry* p_obstacles, const Geometry* p_boundary, double p_tolerance)
     : tolerance(p_tolerance)
     , obstacles(p_obstacles)
     , factory(p_obstacles->getFactory())
-    , boundary(p_obstacles->convexHull())
     , obstacleDistance(p_obstacles)
     , done(false)
 {
-    if (p_obstacles->isEmpty()) {
+    if (!p_boundary)
+    {
+        boundary = p_obstacles->convexHull();
+    }
+    else
+    {
+        boundary = p_boundary->clone();
+    }
+
+    if (obstacles->isEmpty()) {
+        throw util::IllegalArgumentException("Empty obstacles geometry is not supported");
+    }
+    if (boundary->isEmpty()) {
         throw util::IllegalArgumentException("Empty obstacles geometry is not supported");
     }
+    if (!boundary->covers(obstacles)) {
+        throw util::IllegalArgumentException("Boundary geometry does not cover obstacles");
+    }
 
     // if boundary does not enclose an area cannot create a ptLocator
     if (boundary->getDimension() >= 2) {
@@ -61,7 +80,6 @@ LargestEmptyCircle::LargestEmptyCircle(const Geometry* p_obstacles, double p_tol
     }
 }
 
-
 /* public static */
 std::unique_ptr<Point>
 LargestEmptyCircle::getCenter(const Geometry* p_obstacles, double p_tolerance)
diff --git a/tests/unit/capi/GEOSMaximumInscribedCircleTest.cpp b/tests/unit/capi/GEOSMaximumInscribedCircleTest.cpp
index 210f9e8..341c1f1 100644
--- a/tests/unit/capi/GEOSMaximumInscribedCircleTest.cpp
+++ b/tests/unit/capi/GEOSMaximumInscribedCircleTest.cpp
@@ -93,7 +93,7 @@ void object::test<2>
 {
     geom1_ = GEOSGeomFromWKT("MULTIPOINT ((100 100), (100 200), (200 200), (200 100))");
     ensure(nullptr != geom1_);
-    geom2_ = GEOSLargestEmptyCircle(geom1_, 0.001);
+    geom2_ = GEOSLargestEmptyCircle(geom1_, nullptr, 0.001);
     ensure(nullptr != geom2_);
 
     wkt_ = GEOSWKTWriter_write(wktw_, geom2_);

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

Summary of changes:
 capi/geos_c.cpp                                    |  4 ++--
 capi/geos_c.h.in                                   |  4 ++--
 capi/geos_ts_c.cpp                                 |  4 ++--
 .../geos/algorithm/construct/LargestEmptyCircle.h  |  1 +
 src/algorithm/construct/LargestEmptyCircle.cpp     | 24 +++++++++++++++++++---
 tests/unit/capi/GEOSMaximumInscribedCircleTest.cpp |  2 +-
 6 files changed, 29 insertions(+), 10 deletions(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list