[geos-commits] [SCM] GEOS branch master updated. 21ea8486666968ec8c723c582e60d96639caa310

git at osgeo.org git at osgeo.org
Mon Apr 8 13:43:28 PDT 2019


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  21ea8486666968ec8c723c582e60d96639caa310 (commit)
      from  43959918201670cd1e72913cf4cffb07b4666708 (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 21ea8486666968ec8c723c582e60d96639caa310
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Mon Apr 8 13:43:00 2019 -0700

    Add envelope check to SimplePointInAreaLocator
    Port JTS commit 74a9b9d52440f024cd56f90c8c39fea4709cbee2
    https://github.com/locationtech/jts/pull/355

diff --git a/include/geos/algorithm/locate/SimplePointInAreaLocator.h b/include/geos/algorithm/locate/SimplePointInAreaLocator.h
index 2b51986..5a52a06 100644
--- a/include/geos/algorithm/locate/SimplePointInAreaLocator.h
+++ b/include/geos/algorithm/locate/SimplePointInAreaLocator.h
@@ -33,16 +33,22 @@ namespace locate { // geos::algorithm::locate
 
 /** \brief
  * Computes the location of points
- * relative to an areal {@link Geometry},
- * using a simple O(n) algorithm.
+ * relative to a {@link Polygonal} {@link Geometry},
+ * using a simple <tt>O(n)</tt> algorithm.
  *
- * This algorithm is suitable for use in cases where
- * only one or a few points will be tested against a given area.
+ * The algorithm used reports
+ * if a point lies in the interior, exterior,
+ * or exactly on the boundary of the Geometry.
  *
- * The algorithm used is only guaranteed to return correct results
- * for points which are <b>not</b> on the boundary of the Geometry.
+ * Instance methods are provided to implement
+ * the interface {@link PointInAreaLocator}.
+ * However, they provide no performance
+ * advantage over the class methods.
  *
- * @version 1.7
+ * This algorithm is suitable for use in cases where
+ * only a few points will be tested.
+ * If many points will be tested,
+ * {@link IndexedPointInAreaLocator} may provide better performance.
  */
 class SimplePointInAreaLocator : public PointOnGeometryLocator {
 
@@ -53,6 +59,12 @@ public:
 
     /**
     * Determines the {@link Location} of a point in a {@link Polygon}.
+    * The return value is one of:
+    *
+    * - {@link Location.INTERIOR} if the point is in the geometry interior
+    * - {@link Location.BOUNDARY} if the point lies exactly on the boundary
+    * - {@link Location.EXTERIOR} if the point is outside the geometry
+    *
     * Computes {@link Location::BOUNDARY} if the point lies exactly
     * on the polygon boundary.
     *
@@ -62,6 +74,19 @@ public:
     */
     static int locatePointInPolygon(const geom::Coordinate& p,
                                     const geom::Polygon* poly);
+    /**
+    * Determines whether a point is contained in a {@link Geometry},
+    * or lies on its boundary.
+    * This is a convenience method for
+    *
+    *  Location.EXTERIOR != locate(p, geom)
+    *
+    * @param p the point to test
+    * @param geom the geometry to test
+    * @return true if the point lies in or on the geometry
+    */
+    static bool isContained(const geom::Coordinate& p,
+                            const geom::Geometry* geom);
 
     SimplePointInAreaLocator(const geom::Geometry* p_g)
         :	g(p_g)
diff --git a/src/algorithm/locate/SimplePointInAreaLocator.cpp b/src/algorithm/locate/SimplePointInAreaLocator.cpp
index 8f9a971..b08ebc1 100644
--- a/src/algorithm/locate/SimplePointInAreaLocator.cpp
+++ b/src/algorithm/locate/SimplePointInAreaLocator.cpp
@@ -44,9 +44,21 @@ SimplePointInAreaLocator::locate(const Coordinate& p, const Geometry* geom)
         return Location::EXTERIOR;
     }
 
+    /**
+     * Do a fast check against the geometry envelope first
+     */
+    if (! geom->getEnvelopeInternal()->intersects(p))
+        return Location::EXTERIOR;
+
     return locateInGeometry(p, geom);
 }
 
+bool
+SimplePointInAreaLocator::isContained(const Coordinate& p, const Geometry* geom)
+{
+    return Location::EXTERIOR != locate(p, geom);
+}
+
 int
 SimplePointInAreaLocator::locateInGeometry(const Coordinate& p, const Geometry* geom)
 {

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

Summary of changes:
 .../algorithm/locate/SimplePointInAreaLocator.h    | 39 ++++++++++++++++++----
 src/algorithm/locate/SimplePointInAreaLocator.cpp  | 12 +++++++
 2 files changed, 44 insertions(+), 7 deletions(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list