[geos-commits] [SCM] GEOS branch master updated. e6c6fa39e32caf8bc15022cd17f47334a510197b

git at osgeo.org git at osgeo.org
Mon Jan 25 16:48:45 PST 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, master has been updated
       via  e6c6fa39e32caf8bc15022cd17f47334a510197b (commit)
      from  9dfef81cb651449287f95ea67510bfcdc03924a0 (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 e6c6fa39e32caf8bc15022cd17f47334a510197b
Author: Martin Davis <mtnclimb at gmail.com>
Date:   Mon Jan 25 16:45:39 2021 -0800

    Check for invalid area before fixing polygonal result in Densifier and DPSimplifier

diff --git a/src/geom/util/Densifier.cpp b/src/geom/util/Densifier.cpp
index 5154888..e0c5387 100644
--- a/src/geom/util/Densifier.cpp
+++ b/src/geom/util/Densifier.cpp
@@ -91,6 +91,8 @@ Densifier::DensifyTransformer::transformMultiPolygon(const MultiPolygon* geom, c
 std::unique_ptr<Geometry>
 Densifier::DensifyTransformer::createValidArea(const Geometry* roughAreaGeom)
 {
+    if (roughAreaGeom->isValid())
+        return Geometry::Ptr(roughAreaGeom->clone());
     return roughAreaGeom->buffer(0.0);
 }
 
diff --git a/src/simplify/DouglasPeuckerSimplifier.cpp b/src/simplify/DouglasPeuckerSimplifier.cpp
index cad62a1..f32d302 100644
--- a/src/simplify/DouglasPeuckerSimplifier.cpp
+++ b/src/simplify/DouglasPeuckerSimplifier.cpp
@@ -95,7 +95,10 @@ DPTransformer::DPTransformer(double t)
 Geometry::Ptr
 DPTransformer::createValidArea(const Geometry* roughAreaGeom)
 {
-    return Geometry::Ptr(roughAreaGeom->buffer(0.0));
+    bool isValidArea = roughAreaGeom->getDimension() == 2 && roughAreaGeom->isValid();
+    if (! isValidArea)
+        return Geometry::Ptr(roughAreaGeom->buffer(0.0));
+    return Geometry::Ptr(roughAreaGeom->clone());
 }
 
 CoordinateSequence::Ptr
diff --git a/tests/unit/simplify/DouglasPeuckerSimplifierTest.cpp b/tests/unit/simplify/DouglasPeuckerSimplifierTest.cpp
index 3894b9c..6c34530 100644
--- a/tests/unit/simplify/DouglasPeuckerSimplifierTest.cpp
+++ b/tests/unit/simplify/DouglasPeuckerSimplifierTest.cpp
@@ -102,7 +102,7 @@ void object::test<3>
     std::string wkt_in("POLYGON ((120 120, 121 121, 122 122, 220 120, \
 					180 199, 160 200, 140 199, 120 120))");
 
-    std::string wkt_ex("POLYGON ((120 120, 140 199, 160 200, 180 199, 220 120, 120 120))");
+    std::string wkt_ex("POLYGON ((120 120, 220 120, 180 199, 160 200, 140 199, 120 120))");
 
     GeomPtr g(wktreader.read(wkt_in));
 
@@ -126,8 +126,8 @@ void object::test<4>
     std::string wkt_in("POLYGON ((80 200, 240 200, 240 60, 80 60, 80 200), \
 					(120 120, 220 120, 180 199, 160 200, 140 199, 120 120))");
 
-    std::string wkt_ex("POLYGON ((80 200, 160 200, 240 200, 240 60, 80 60, 80 200), \
-					(160 200, 140 199, 120 120, 220 120, 180 199, 160 200)))");
+    std::string wkt_ex("POLYGON ((80 200, 240 200, 240 60, 80 60, 80 200), \
+					(120 120, 220 120, 180 199, 160 200, 140 199, 120 120))");
 
     GeomPtr g(wktreader.read(wkt_in));
 
@@ -396,4 +396,3 @@ void object::test<13>
 
 
 } // namespace tut
-
diff --git a/tests/xmltester/XMLTester.cpp b/tests/xmltester/XMLTester.cpp
index f4d1ac3..7aeb905 100644
--- a/tests/xmltester/XMLTester.cpp
+++ b/tests/xmltester/XMLTester.cpp
@@ -1291,14 +1291,13 @@ XMLTester::parseTest(const tinyxml2::XMLNode* node)
             geom::Geometry* p_gT = gA;
 
             GeomPtr gRes(parseGeometry(opRes, "expected"));
-            // gRes->normalize();
+            gRes->normalize();
 
             geom::util::Densifier den(p_gT);
             double distanceTolerance = std::atof(opArg2.c_str());
             den.setDistanceTolerance(distanceTolerance);
             GeomPtr gRealRes = den.getResultGeometry();
-
-            // gRealRes->normalize();
+            gRealRes->normalize();
 
             if(gRes->compareTo(gRealRes.get()) == 0) {
                 success = 1;
diff --git a/util/geosop/GeomFunction.cpp b/util/geosop/GeomFunction.cpp
index dff83ad..5493792 100644
--- a/util/geosop/GeomFunction.cpp
+++ b/util/geosop/GeomFunction.cpp
@@ -25,6 +25,7 @@
 #include <geos/geom/prep/PreparedGeometryFactory.h>
 #include <geos/algorithm/construct/MaximumInscribedCircle.h>
 #include <geos/algorithm/MinimumBoundingCircle.h>
+#include <geos/geom/util/Densifier.h>
 #include <geos/operation/linemerge/LineMerger.h>
 #include <geos/operation/distance/DistanceOp.h>
 #include <geos/operation/relate/RelateOp.h>
@@ -79,7 +80,7 @@ GeomFunction::init()
         [](const std::unique_ptr<Geometry>& geom, const std::unique_ptr<Geometry>& geomB, double d)->Result* {
             return new Result( geom->getBoundary() );
         });
-    add("buffer", "cmputes the buffer of geometry A", 1, 1,
+    add("buffer", "computes the buffer of geometry A to a distance", 1, 1,
         [](const std::unique_ptr<Geometry>& geom, const std::unique_ptr<Geometry>& geomB, double d)->Result* {
             return new Result( geom->buffer( d ) );
         });
@@ -104,6 +105,13 @@ GeomFunction::init()
             return new Result( geom->covers( geomB.get() ) );
         });
 
+    add("densify", "densifies geometry A to a distance ", 1, 1,
+        [](const std::unique_ptr<Geometry>& geom, const std::unique_ptr<Geometry>& geomB, double d)->Result* {
+            geom::util::Densifier densifier( geom.get() );
+            densifier.setDistanceTolerance( d );
+            return new Result( densifier.getResultGeometry() );
+        });
+
     add("distance", "computes distance between geometry A and B", 2, 0,
         [](const std::unique_ptr<Geometry>& geom, const std::unique_ptr<Geometry>& geomB, double d)->Result* {
             return new Result( geom->distance( geomB.get() ) );

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

Summary of changes:
 src/geom/util/Densifier.cpp                          |  2 ++
 src/simplify/DouglasPeuckerSimplifier.cpp            |  5 ++++-
 tests/unit/simplify/DouglasPeuckerSimplifierTest.cpp |  7 +++----
 tests/xmltester/XMLTester.cpp                        |  5 ++---
 util/geosop/GeomFunction.cpp                         | 10 +++++++++-
 5 files changed, 20 insertions(+), 9 deletions(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list