[geos-commits] [SCM] GEOS branch master updated. 49ac5aa40404b634be3769375c70ee7c4466958d

git at osgeo.org git at osgeo.org
Thu Sep 17 10:00:42 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  49ac5aa40404b634be3769375c70ee7c4466958d (commit)
      from  1bb072153d7bb195d5065416123de06c34b972a9 (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 49ac5aa40404b634be3769375c70ee7c4466958d
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Thu Sep 17 09:35:14 2020 -0700

    Unit test and fix for dateline clipping case reported by @roualt

diff --git a/include/geos/geom/Geometry.h b/include/geos/geom/Geometry.h
index 9fbda99..ea00845 100644
--- a/include/geos/geom/Geometry.h
+++ b/include/geos/geom/Geometry.h
@@ -361,6 +361,14 @@ public:
         return isDimensionStrict(Dimension::A);
     }
 
+    bool isCollection() const {
+        int t = getGeometryTypeId();
+        return t == GEOS_GEOMETRYCOLLECTION ||
+               t == GEOS_MULTIPOINT ||
+               t == GEOS_MULTILINESTRING ||
+               t == GEOS_MULTIPOLYGON;
+    }
+
     /// Returns the coordinate dimension of this Geometry (2=XY, 3=XYZ, 4=XYZM in future).
     virtual int getCoordinateDimension() const = 0; //Abstract
 
diff --git a/src/operation/overlayng/OverlayNG.cpp b/src/operation/overlayng/OverlayNG.cpp
index eb80103..3c1a05b 100644
--- a/src/operation/overlayng/OverlayNG.cpp
+++ b/src/operation/overlayng/OverlayNG.cpp
@@ -188,10 +188,12 @@ OverlayNG::computeEdgeOverlay()
     * Edge* list allocated in the EdgeNodingBuilder survives
     * long enough to be copied into the OverlayGraph
     */
-    // XXX sort the edges first
+    // Sort the edges first, for comparison with JTS results
     // std::sort(edges.begin(), edges.end(), EdgeComparator);
     OverlayGraph graph;
     for (Edge* e : edges) {
+        // Write out edge graph as hex for examination
+        // std::cout << *e << std::endl;
         graph.addEdge(e);
     }
 
diff --git a/src/operation/overlayng/RobustClipEnvelopeComputer.cpp b/src/operation/overlayng/RobustClipEnvelopeComputer.cpp
index f1bd0ed..2786701 100644
--- a/src/operation/overlayng/RobustClipEnvelopeComputer.cpp
+++ b/src/operation/overlayng/RobustClipEnvelopeComputer.cpp
@@ -58,7 +58,7 @@ RobustClipEnvelopeComputer::add(const Geometry* g)
 
     if (g->getGeometryTypeId() == GEOS_POLYGON)
         addPolygon(static_cast<const Polygon*>(g));
-    else if (g->getGeometryTypeId() == GEOS_GEOMETRYCOLLECTION)
+    else if (g->isCollection())
         addCollection(static_cast<const GeometryCollection*>(g));
 }
 
diff --git a/tests/unit/Makefile.am b/tests/unit/Makefile.am
index c2f26f8..d7290cd 100644
--- a/tests/unit/Makefile.am
+++ b/tests/unit/Makefile.am
@@ -196,6 +196,7 @@ geos_unit_SOURCES = \
 	operation/overlayng/OverlayNGFloatingNoderTest.cpp \
 	operation/overlayng/OverlayNGPointsTest.cpp \
 	operation/overlayng/OverlayNGMixedPointsTest.cpp \
+	operation/overlayng/OverlayNGRobustTest.cpp \
 	operation/overlayng/OverlayNGSnappingNoderTest.cpp \
 	operation/overlayng/OverlayNGSnappingOneTest.cpp \
 	operation/overlayng/OverlayNGTest.cpp \
diff --git a/tests/unit/operation/overlayng/OverlayNGRobustTest.cpp b/tests/unit/operation/overlayng/OverlayNGRobustTest.cpp
new file mode 100644
index 0000000..b8bd71b
--- /dev/null
+++ b/tests/unit/operation/overlayng/OverlayNGRobustTest.cpp
@@ -0,0 +1,65 @@
+//
+// Test Suite for geos::operation::overlayng::OverlayNG class.
+
+#include <tut/tut.hpp>
+#include <utility.h>
+
+// geos
+#include <geos/operation/overlayng/OverlayNGRobust.h>
+
+// std
+#include <memory>
+
+using namespace geos::geom;
+using namespace geos::operation::overlayng;
+using geos::io::WKTReader;
+using geos::io::WKTWriter;
+
+namespace tut {
+//
+// Test Group
+//
+
+// Common data used by all tests
+struct test_overlayngrobust_data {
+
+    WKTReader r;
+    WKTWriter w;
+
+    void
+    testOverlay(const std::string& a, const std::string& b, const std::string& expected, int opCode)
+    {
+        std::unique_ptr<Geometry> geom_a = r.read(a);
+        std::unique_ptr<Geometry> geom_b = r.read(b);
+        std::unique_ptr<Geometry> geom_expected = r.read(expected);
+        std::unique_ptr<Geometry> geom_result = OverlayNGRobust::Overlay(geom_a.get(), geom_b.get(), opCode);
+        // std::string wkt_result = w.write(geom_result.get());
+        // std::cout << std::endl << wkt_result << std::endl;
+        ensure_equals_geometry(geom_expected.get(), geom_result.get());
+    }
+
+};
+
+typedef test_group<test_overlayngrobust_data> group;
+typedef group::object object;
+
+group test_overlayngrobust_data("geos::operation::overlayng::OverlayNGRobust");
+
+//
+// Test Cases
+//
+
+//  Square overlapping square
+template<>
+template<>
+void object::test<1> ()
+{
+    std::string a = "LINESTRING(832864.275023695 0,835092.849076364 0)";
+    std::string b = "MULTIPOLYGON (((832864.275023695 0.0,833978.556808034 -0.000110682755987,833978.556808034 0.0,833978.556808034 0.000110682755987,832864.275023695 0.0,832864.275023695 0.0)),((835092.849076364 0.0,833978.557030887 -0.000110682755987,833978.557030887 0.0,833978.557030887 0.000110682755987,835092.849076364 0.0,835092.849076364 0.0)))";
+    std::string exp = "MULTILINESTRING ((832864.275023695 0.0,833978.556808034 0.0),(833978.557030887 0.0,835092.849076364 0.0))";
+    testOverlay(a, b, exp, OverlayNG::INTERSECTION);
+}
+
+
+
+} // namespace tut

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

Summary of changes:
 include/geos/geom/Geometry.h                       |  8 +++
 src/operation/overlayng/OverlayNG.cpp              |  4 +-
 .../overlayng/RobustClipEnvelopeComputer.cpp       |  2 +-
 tests/unit/Makefile.am                             |  1 +
 .../operation/overlayng/OverlayNGRobustTest.cpp    | 65 ++++++++++++++++++++++
 5 files changed, 78 insertions(+), 2 deletions(-)
 create mode 100644 tests/unit/operation/overlayng/OverlayNGRobustTest.cpp


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list