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

git at osgeo.org git at osgeo.org
Wed Sep 29 13:37:59 PDT 2021


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  f5c3da3342b16da45a81704c6affcf4a855b49b6 (commit)
      from  55fb9a19ad3bf8395e8ef2fcee988fa5b9e7fefe (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 f5c3da3342b16da45a81704c6affcf4a855b49b6
Author: Sandro Santilli <strk at kbt.io>
Date:   Wed Sep 29 22:36:44 2021 +0200

    Expose a PreparedGeometry::isDistanceWithin method
    
    And have the C-API call that.
    
    The method doesn't have optimized implementations but simply
    calls (for now) the isDistanceWithin() method of the base geometry.

diff --git a/capi/geos_ts_c.cpp b/capi/geos_ts_c.cpp
index cc6d9e7..3abc02b 100644
--- a/capi/geos_ts_c.cpp
+++ b/capi/geos_ts_c.cpp
@@ -3286,9 +3286,8 @@ extern "C" {
                          const geos::geom::prep::PreparedGeometry* pg,
                          const Geometry* g, double dist)
     {
-        // TODO: further optimize this ?
         return execute(extHandle, 2, [&]() {
-            return pg->distance(g) <= dist;
+            return pg->isDistanceWithin(g, dist);
         });
     }
 
diff --git a/include/geos/geom/prep/BasicPreparedGeometry.h b/include/geos/geom/prep/BasicPreparedGeometry.h
index 29639e9..714d2f5 100644
--- a/include/geos/geom/prep/BasicPreparedGeometry.h
+++ b/include/geos/geom/prep/BasicPreparedGeometry.h
@@ -181,6 +181,11 @@ public:
      */
     double distance(const geom::Geometry* g) const override;
 
+    /**
+     * Default implementation.
+     */
+    bool isDistanceWithin(const geom::Geometry* geom, double dist) const override;
+
     std::string toString();
 
 };
diff --git a/include/geos/geom/prep/PreparedGeometry.h b/include/geos/geom/prep/PreparedGeometry.h
index 29b7786..eda52ad 100644
--- a/include/geos/geom/prep/PreparedGeometry.h
+++ b/include/geos/geom/prep/PreparedGeometry.h
@@ -216,6 +216,17 @@ public:
      *
      */
     virtual double distance(const geom::Geometry* geom) const = 0;
+
+    /** \brief
+     * Tests whether the base {@link Geometry} is within a given
+     * distance from the given geometry.
+     *
+     * @param geom the Geometry to test the distance to
+     * @return true if this Geometry is within the given distance from
+     * the given Geometry.
+     *
+     */
+    virtual bool isDistanceWithin(const geom::Geometry* geom, double dist) const = 0;
 };
 
 
diff --git a/src/geom/prep/BasicPreparedGeometry.cpp b/src/geom/prep/BasicPreparedGeometry.cpp
index 78acb8a..a3e058a 100644
--- a/src/geom/prep/BasicPreparedGeometry.cpp
+++ b/src/geom/prep/BasicPreparedGeometry.cpp
@@ -171,6 +171,12 @@ BasicPreparedGeometry::distance(const geom::Geometry* g) const
     return coords->getAt(0).distance( coords->getAt(1) );
 }
 
+bool
+BasicPreparedGeometry::isDistanceWithin(const geom::Geometry* g, double dist) const
+{
+    return baseGeom->isWithinDistance(g, dist);
+}
+
 std::string
 BasicPreparedGeometry::toString()
 {

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

Summary of changes:
 capi/geos_ts_c.cpp                             |  3 +--
 include/geos/geom/prep/BasicPreparedGeometry.h |  5 +++++
 include/geos/geom/prep/PreparedGeometry.h      | 11 +++++++++++
 src/geom/prep/BasicPreparedGeometry.cpp        |  6 ++++++
 4 files changed, 23 insertions(+), 2 deletions(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list