[geos-commits] [SCM] GEOS branch 3.9 updated. b14c2287a1b0e0242de0308bf60f8c03f2bca0e6

git at osgeo.org git at osgeo.org
Fri Oct 29 14:57:20 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, 3.9 has been updated
       via  b14c2287a1b0e0242de0308bf60f8c03f2bca0e6 (commit)
      from  17658cbe9c48d6ddc8856201944ee6e67b701a1a (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 b14c2287a1b0e0242de0308bf60f8c03f2bca0e6
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Fri Oct 29 14:33:35 2021 -0700

    Fix crasher reducing LinearRing precision, references #1135

diff --git a/NEWS b/NEWS
index df5521027..44d849ee9 100644
--- a/NEWS
+++ b/NEWS
@@ -14,6 +14,7 @@ Changes in 3.9.2
   - Avoid stack overflow in KdTree::queryNode (Even Roualt)
   - Avoid raising double overflow signals in distance calcs (Paul Ramsey)
   - Fix performance issue in buffer building (Paul Ramsey)
+  - Fix crash when precision reducing LinearRing (#1135, Paul Ramsey)
 
 
 Changes in 3.9.1
diff --git a/src/geom/util/GeometryTransformer.cpp b/src/geom/util/GeometryTransformer.cpp
index 38efefd42..3167f006e 100644
--- a/src/geom/util/GeometryTransformer.cpp
+++ b/src/geom/util/GeometryTransformer.cpp
@@ -198,7 +198,7 @@ GeometryTransformer::transformLinearRing(
     CoordinateSequence::Ptr seq(transformCoordinates(
                                     geom->getCoordinatesRO(), geom));
 
-    auto seqSize = seq->size();
+    std::size_t seqSize = seq ? seq->size() : 0;
 
     // ensure a valid LinearRing
     if(seqSize > 0 && seqSize < 4 && ! preserveType) {
diff --git a/tests/unit/capi/GEOSGeom_setPrecisionTest.cpp b/tests/unit/capi/GEOSGeom_setPrecisionTest.cpp
index 13000d3d9..ef4d07959 100644
--- a/tests/unit/capi/GEOSGeom_setPrecisionTest.cpp
+++ b/tests/unit/capi/GEOSGeom_setPrecisionTest.cpp
@@ -163,5 +163,56 @@ void object::test<5>
     ensure_equals(toWKT(geom3_), "LINESTRING (0 0, 0 0)");
 }
 
+// Retain (or not) collapsed elements
+template<>
+template<>
+void object::test<6> ()
+{
+    geom1_ = fromWKT("LINESTRING (0 0, 0.1 0.1)");
+    geom2_ = GEOSGeom_setPrecision(geom1_, 1.0, 0);
+    ensure_geometry_equals(geom2_, "LINESTRING EMPTY");
+}
+
+// Retain (or not) collapsed elements
+template<>
+template<>
+void object::test<7> ()
+{
+    geom1_ = fromWKT("LINESTRING (0 0, 0.1 0.1)");
+    geom2_ = GEOSGeom_setPrecision(geom1_, 1.0, GEOS_PREC_NO_TOPO);
+    ensure_geometry_equals(geom2_, "LINESTRING (0 0, 0 0)");
+}
+
+// Retain (or not) collapsed elements
+template<>
+template<>
+void object::test<8> ()
+{
+    geom1_ = fromWKT("LINESTRING (0 0, 0.1 0.1)");
+    geom2_ = GEOSGeom_setPrecision(geom1_, 1.0, GEOS_PREC_KEEP_COLLAPSED);
+    ensure_geometry_equals(geom2_, "LINESTRING (0 0, 0 0)");
+}
+
+// Retain (or not) collapsed elements
+template<>
+template<>
+void object::test<9> ()
+{
+    geom1_ = fromWKT("LINESTRING (0 0, 0.1 0.1)");
+    geom2_ = GEOSGeom_setPrecision(geom1_, 1.0, GEOS_PREC_KEEP_COLLAPSED | GEOS_PREC_NO_TOPO);
+    ensure_geometry_equals(geom2_, "LINESTRING (0 0, 0 0)");
+}
+
+
+// Collapse a linearRing / Trac #1135
+template<>
+template<>
+void object::test<10> ()
+{
+    geom1_ = fromWKT("LINEARRING (0 0, 0.1 0, 0.1 0.1, 0 0.1, 0 0)");
+    geom2_ = GEOSGeom_setPrecision(geom1_, 1.0, 0);
+    ensure_geometry_equals(geom2_, "LINEARRING EMPTY");
+}
+
 } // namespace tut
 

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

Summary of changes:
 NEWS                                          |  1 +
 src/geom/util/GeometryTransformer.cpp         |  2 +-
 tests/unit/capi/GEOSGeom_setPrecisionTest.cpp | 51 +++++++++++++++++++++++++++
 3 files changed, 53 insertions(+), 1 deletion(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list