[geos-commits] [SCM] GEOS branch 3.8 updated. b2dfcbbc147273c05c0ce521419924614831d4a3

git at osgeo.org git at osgeo.org
Fri Apr 17 15:05:23 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, 3.8 has been updated
       via  b2dfcbbc147273c05c0ce521419924614831d4a3 (commit)
       via  27f25e72f6287a531f3d5fffe7507d1b4983b55f (commit)
       via  0e6f5175e9bf79d3d9b63c4812fea51028a19fea (commit)
      from  f1a9d42fd1da0483ae172f37becfe5d2450848ee (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 b2dfcbbc147273c05c0ce521419924614831d4a3
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Fri Apr 17 15:04:48 2020 -0700

    Add news entry for #1026

diff --git a/NEWS b/NEWS
index 13cf98a..cbdfdde 100644
--- a/NEWS
+++ b/NEWS
@@ -2,7 +2,9 @@ Changes in 3.8.2
 2020-xx-xx
 
 - Bug fixes / improvements
-  - 
+  - DistanceOp against geometry with empty components 
+    crashes (#1026, Paul Ramsey)
+
 
 Changes in 3.8.1
 2020-03-10

commit 27f25e72f6287a531f3d5fffe7507d1b4983b55f
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Fri Apr 17 13:46:26 2020 -0700

    literal port of jts commit, still segfaults

diff --git a/include/geos/algorithm/locate/IndexedPointInAreaLocator.h b/include/geos/algorithm/locate/IndexedPointInAreaLocator.h
index 10541a1..149433b 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 581fd8d..99e8d50 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/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>

commit 0e6f5175e9bf79d3d9b63c4812fea51028a19fea
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Fri Apr 17 14:22:40 2020 -0700

    Don't allow empty rings to get into calculation of distance

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);
     }

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

Summary of changes:
 NEWS                                                             | 4 +++-
 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 +++++++
 7 files changed, 21 insertions(+), 2 deletions(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list