[geos-commits] [SCM] GEOS branch main updated. 55fb9a19ad3bf8395e8ef2fcee988fa5b9e7fefe

git at osgeo.org git at osgeo.org
Wed Sep 29 13:24:23 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  55fb9a19ad3bf8395e8ef2fcee988fa5b9e7fefe (commit)
      from  180fe65edcf2509d2a4766c010c0861bb3e5388f (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 55fb9a19ad3bf8395e8ef2fcee988fa5b9e7fefe
Author: Sandro Santilli <strk at kbt.io>
Date:   Wed Sep 29 22:24:04 2021 +0200

    Optimize Geometry::isWithinDistance
    
    This is now matching JTS implementation

diff --git a/src/geom/Geometry.cpp b/src/geom/Geometry.cpp
index ff5822b..c0029ef 100644
--- a/src/geom/Geometry.cpp
+++ b/src/geom/Geometry.cpp
@@ -149,19 +149,7 @@ Geometry::hasNullElements(const CoordinateSequence* list)
 bool
 Geometry::isWithinDistance(const Geometry* geom, double cDistance) const
 {
-    const Envelope* env0 = getEnvelopeInternal();
-    const Envelope* env1 = geom->getEnvelopeInternal();
-    double envDist = env0->distance(*env1);
-
-    if(envDist > cDistance) {
-        return false;
-    }
-    // NOTE: this could be implemented more efficiently
-    double geomDist = distance(geom);
-    if(geomDist > cDistance) {
-        return false;
-    }
-    return true;
+    return DistanceOp::isWithinDistance(*this, *geom, cDistance);
 }
 
 /*public*/
diff --git a/src/operation/distance/DistanceOp.cpp b/src/operation/distance/DistanceOp.cpp
index 33f6e8c..b96f892 100644
--- a/src/operation/distance/DistanceOp.cpp
+++ b/src/operation/distance/DistanceOp.cpp
@@ -527,6 +527,16 @@ DistanceOp::isWithinDistance(const geom::Geometry& g0,
                              const geom::Geometry& g1,
                              double distance)
 {
+    // check envelope distance for a short-circuit negative result
+    const Envelope* env0 = g0.getEnvelopeInternal();
+    const Envelope* env1 = g1.getEnvelopeInternal();
+    double envDist = env0->distance(*env1);
+    if (envDist > distance)
+      return false;
+
+    // MD - could improve this further with a positive short-circuit based
+    // on envelope MinMaxDist
+
     DistanceOp distOp(g0, g1, distance);
     return distOp.distance() <= distance;
 }

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

Summary of changes:
 src/geom/Geometry.cpp                 | 14 +-------------
 src/operation/distance/DistanceOp.cpp | 10 ++++++++++
 2 files changed, 11 insertions(+), 13 deletions(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list