[geos-commits] [SCM] GEOS branch master updated. 2ac00b1c5ae669c384d78155cbf94042d0fc90b0

git at osgeo.org git at osgeo.org
Fri Apr 17 15:06:41 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  2ac00b1c5ae669c384d78155cbf94042d0fc90b0 (commit)
      from  3df362a9d8c04a53bdaae0916c821296641ef6a3 (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 2ac00b1c5ae669c384d78155cbf94042d0fc90b0
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Fri Apr 17 15:06:35 2020 -0700

    Fix bug in DistanceOp for geometries with empty components, Closes #1026

diff --git a/include/geos/algorithm/locate/IndexedPointInAreaLocator.h b/include/geos/algorithm/locate/IndexedPointInAreaLocator.h
index 89e2b69..a29fb94 100644
--- a/include/geos/algorithm/locate/IndexedPointInAreaLocator.h
+++ b/include/geos/algorithm/locate/IndexedPointInAreaLocator.h
@@ -48,6 +48,9 @@ namespace locate { // geos::algorithm::locate
  * or segments will return [Location::BOUNDARY](@ref geom::Location::BOUNDARY).
  *
  * Polygonal and [LinearRing](@ref geom::LinearRing) geometries are supported.
+ *
+ * The index is lazy-loaded, which allows creating instances even if they are not used.
+ *
  */
 class IndexedPointInAreaLocator : public PointOnGeometryLocator {
 private:
diff --git a/include/geos/operation/distance/ConnectedElementLocationFilter.h b/include/geos/operation/distance/ConnectedElementLocationFilter.h
index 9273653..379dd19 100644
--- a/include/geos/operation/distance/ConnectedElementLocationFilter.h
+++ b/include/geos/operation/distance/ConnectedElementLocationFilter.h
@@ -42,7 +42,7 @@ namespace distance { // geos::operation::distance
 /** \brief
  * A ConnectedElementPointFilter extracts a single point from each connected
  * element in a Geometry (e.g. a polygon, linestring or point) and returns
- * them in a list.
+ * them in a list. Empty geometries do not provide a location item.
  *
  * The elements of the list are GeometryLocation.
  */
diff --git a/include/geos/operation/distance/DistanceOp.h b/include/geos/operation/distance/DistanceOp.h
index 3ba3264..bdf6282 100644
--- a/include/geos/operation/distance/DistanceOp.h
+++ b/include/geos/operation/distance/DistanceOp.h
@@ -64,6 +64,8 @@ namespace distance { // geos::operation::distance
  * the coordinate computed is a close
  * approximation to the exact point.
  *
+ * Empty geometry collection components are ignored.
+ *
  * The algorithms used are straightforward O(n^2)
  * comparisons.  This worst-case performance could be improved on
  * by using Voronoi techniques or spatial indexes.
diff --git a/src/geom/util/LinearComponentExtracter.cpp b/src/geom/util/LinearComponentExtracter.cpp
index 57c5372..2eca78a 100644
--- a/src/geom/util/LinearComponentExtracter.cpp
+++ b/src/geom/util/LinearComponentExtracter.cpp
@@ -38,6 +38,7 @@ LinearComponentExtracter::getLines(const Geometry& geom, std::vector<const LineS
 void
 LinearComponentExtracter::filter_rw(Geometry* geom)
 {
+    if (geom->isEmpty()) return;
     if(const LineString* ls = dynamic_cast<const LineString*>(geom)) {
         comps.push_back(ls);
     }
@@ -46,6 +47,7 @@ LinearComponentExtracter::filter_rw(Geometry* geom)
 void
 LinearComponentExtracter::filter_ro(const Geometry* geom)
 {
+    if (geom->isEmpty()) return;
     if(const LineString* ls = dynamic_cast<const LineString*>(geom)) {
         comps.push_back(ls);
     }
diff --git a/src/operation/distance/ConnectedElementLocationFilter.cpp b/src/operation/distance/ConnectedElementLocationFilter.cpp
index e12b892..aeefb7a 100644
--- a/src/operation/distance/ConnectedElementLocationFilter.cpp
+++ b/src/operation/distance/ConnectedElementLocationFilter.cpp
@@ -46,6 +46,7 @@ ConnectedElementLocationFilter::getLocations(const Geometry* geom)
 void
 ConnectedElementLocationFilter::filter_ro(const Geometry* geom)
 {
+    if (geom->isEmpty()) return;
     if((typeid(*geom) == typeid(Point)) ||
             (typeid(*geom) == typeid(LineString)) ||
             (typeid(*geom) == typeid(LinearRing)) ||
@@ -57,6 +58,8 @@ ConnectedElementLocationFilter::filter_ro(const Geometry* geom)
 void
 ConnectedElementLocationFilter::filter_rw(Geometry* geom)
 {
+    // empty geometries do not provide a location
+    if (geom->isEmpty()) return;
     if((typeid(*geom) == typeid(Point)) ||
             (typeid(*geom) == typeid(LineString)) ||
             (typeid(*geom) == typeid(LinearRing)) ||
diff --git a/tests/xmltester/tests/general/TestDistance.xml b/tests/xmltester/tests/general/TestDistance.xml
index af243e9..4ce6d0f 100644
--- a/tests/xmltester/tests/general/TestDistance.xml
+++ b/tests/xmltester/tests/general/TestDistance.xml
@@ -57,4 +57,11 @@
 <test><op name="distance" arg1="A" arg2="B" >    0.0   </op></test>
 </case>
 
+<case>
+  <desc>mAmA - multipolygon with empty component</desc>
+  <a> MULTIPOLYGON (EMPTY, ((98 200, 200 200, 200 99, 98 99, 98 200))) </a>
+  <b> POLYGON ((300 200, 400 200, 400 100, 300 100, 300 200)) </b>
+<test><op name="distance" arg1="A" arg2="B" >    100.0   </op></test>
+</case>
+
 </run>

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

Summary of changes:
 include/geos/algorithm/locate/IndexedPointInAreaLocator.h        | 3 +++
 include/geos/operation/distance/ConnectedElementLocationFilter.h | 2 +-
 include/geos/operation/distance/DistanceOp.h                     | 2 ++
 src/geom/util/LinearComponentExtracter.cpp                       | 2 ++
 src/operation/distance/ConnectedElementLocationFilter.cpp        | 3 +++
 tests/xmltester/tests/general/TestDistance.xml                   | 7 +++++++
 6 files changed, 18 insertions(+), 1 deletion(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list