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

git at osgeo.org git at osgeo.org
Wed Jul 29 14:51:53 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  c4e62873c97c6d1607f8e2c800a7992c49f414be (commit)
      from  b2da5ce9c35b59a0a7852526bfb037381ab521b1 (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 c4e62873c97c6d1607f8e2c800a7992c49f414be
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Wed Jul 29 14:51:45 2020 -0700

    Fix up unit tests were issues of representation (ring order, component order, etc) were causing failures

diff --git a/tests/unit/capi/GEOSIntersectionTest.cpp b/tests/unit/capi/GEOSIntersectionTest.cpp
index 48a4c9a..4cdf125 100644
--- a/tests/unit/capi/GEOSIntersectionTest.cpp
+++ b/tests/unit/capi/GEOSIntersectionTest.cpp
@@ -2,6 +2,7 @@
 // Test Suite for C-API GEOSintersection
 
 #include <tut/tut.hpp>
+
 // geos
 #include <geos_c.h>
 // std
@@ -20,6 +21,7 @@ struct test_capigeosintersection_data {
     GEOSGeometry* geom1_;
     GEOSGeometry* geom2_;
     GEOSGeometry* geom3_;
+    GEOSGeometry* expected_;
 
     static void
     notice(const char* fmt, ...)
@@ -41,6 +43,10 @@ struct test_capigeosintersection_data {
         wktw_ = GEOSWKTWriter_create();
         GEOSWKTWriter_setTrim(wktw_, 1);
         GEOSWKTWriter_setOutputDimension(wktw_, 3);
+        geom1_ = nullptr;
+        geom2_ = nullptr;
+        geom3_ = nullptr;
+        expected_ = nullptr;
     }
 
     std::string
@@ -52,15 +58,25 @@ struct test_capigeosintersection_data {
         return ret;
     }
 
+    int
+    same(GEOSGeometry* g1, GEOSGeometry* g2, double tolerance)
+    {
+        GEOSNormalize(g1);
+        GEOSNormalize(g2);
+        return GEOSEqualsExact(g1, g2, tolerance);
+    }
+
     ~test_capigeosintersection_data()
     {
         GEOSWKTWriter_destroy(wktw_);
         GEOSGeom_destroy(geom1_);
         GEOSGeom_destroy(geom2_);
         GEOSGeom_destroy(geom3_);
+        if (expected_) GEOSGeom_destroy(expected_);
         geom1_ = nullptr;
         geom2_ = nullptr;
         geom3_ = nullptr;
+        expected_ = nullptr;
         finishGEOS();
     }
 
@@ -114,6 +130,7 @@ void object::test<3>
 {
     geom1_ = GEOSGeomFromWKT("MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))");
     geom2_ = GEOSGeomFromWKT("POLYGON((-1 1,-1 2,2 2,2 1,-1 1))");
+    expected_ = GEOSGeomFromWKT("POLYGON ((0 1, 0 2, 2 2, 2 1, 0 1))");
 
     ensure(nullptr != geom1_);
     ensure(nullptr != geom2_);
@@ -121,7 +138,7 @@ void object::test<3>
     geom3_ = GEOSIntersection(geom1_, geom2_);
 
     ensure(nullptr != geom3_);
-    ensure_equals(toWKT(geom3_), std::string("POLYGON ((0 1, 0 2, 2 2, 2 1, 0 1))"));
+    ensure(same(geom3_, expected_, 0.1));
 }
 
 /* See http://trac.osgeo.org/geos/ticket/719 */
diff --git a/tests/unit/capi/GEOSMakeValidTest.cpp b/tests/unit/capi/GEOSMakeValidTest.cpp
index 6bf8d21..800da9e 100644
--- a/tests/unit/capi/GEOSMakeValidTest.cpp
+++ b/tests/unit/capi/GEOSMakeValidTest.cpp
@@ -19,6 +19,7 @@ struct test_capimakevalid_data {
     GEOSWKTWriter* wktw_;
     GEOSGeometry* geom1_ = nullptr;
     GEOSGeometry* geom2_ = nullptr;
+    GEOSGeometry* expect_ = nullptr;
 
     static void
     notice(const char* fmt, ...)
@@ -76,6 +77,9 @@ void object::test<1>
 {
     geom1_ = GEOSGeomFromWKT("POLYGON((0 0,1 1,0 1,1 0,0 0))");
     geom2_ = GEOSMakeValid(geom1_);
-    ensure_equals(toWKT(geom2_), std::string("MULTIPOLYGON (((0 0, 0.5 0.5, 1 0, 0 0)), ((0.5 0.5, 0 1, 1 1, 0.5 0.5)))"));
+    expect_ = GEOSGeomFromWKT("MULTIPOLYGON (((0 0, 0.5 0.5, 1 0, 0 0)), ((0.5 0.5, 0 1, 1 1, 0.5 0.5)))");
+    GEOSNormalize(geom2_);
+    GEOSNormalize(expect_);
+    ensure(GEOSEqualsExact(geom2_, expect_, 0.01));
 }
 } // namespace tut
diff --git a/tests/unit/capi/GEOSUnaryUnionTest.cpp b/tests/unit/capi/GEOSUnaryUnionTest.cpp
index 8ef9c97..5e55af1 100644
--- a/tests/unit/capi/GEOSUnaryUnionTest.cpp
+++ b/tests/unit/capi/GEOSUnaryUnionTest.cpp
@@ -183,9 +183,10 @@ void object::test<7>
     ensure(nullptr != geom2_);
 
     GEOSGeometry* expected = GEOSGeomFromWKT("GEOMETRYCOLLECTION (LINESTRING (5 7, 7 7), LINESTRING (10 7, 12 7), LINESTRING (5.5 7.5, 6.5 7.5), POLYGON ((10 7, 10 0, 0 0, 0 10, 10 10, 10 7), (5 6, 7 6, 7 7, 7 8, 5 8, 5 7, 5 6)))");
+    GEOSNormalize(geom2_);
+    GEOSNormalize(expected);
 
     ensure(GEOSEquals(geom2_, expected) != 0);
-
     GEOSGeom_destroy(expected);
 }
 
@@ -201,9 +202,12 @@ void object::test<8>
     geom2_ = GEOSUnaryUnion(geom1_);
     ensure(nullptr != geom2_);
 
-    ensure_equals(toWKT(geom2_), std::string(
-                      "GEOMETRYCOLLECTION (POINT (6 6.5), POINT (12 2), LINESTRING (5 7, 7 7), LINESTRING (10 7, 12 7), LINESTRING (5.5 7.5, 6.5 7.5), POLYGON ((10 7, 10 0, 0 0, 0 10, 10 10, 10 7), (5 6, 7 6, 7 7, 7 8, 5 8, 5 7, 5 6)))"
-                  ));
+    GEOSGeometry* expected = GEOSGeomFromWKT("GEOMETRYCOLLECTION (POINT (6 6.5), POINT (12 2), LINESTRING (5 7, 7 7), LINESTRING (10 7, 12 7), LINESTRING (5.5 7.5, 6.5 7.5), POLYGON ((10 7, 10 0, 0 0, 0 10, 10 10, 10 7), (5 6, 7 6, 7 7, 7 8, 5 8, 5 7, 5 6)))");
+    GEOSNormalize(geom2_);
+    GEOSNormalize(expected);
+
+    ensure(GEOSEquals(geom2_, expected));
+    GEOSGeom_destroy(expected);
 }
 
 // Self-union a geometry with NaN coordinates
diff --git a/tests/unit/operation/geounion/CascadedPolygonUnionTest.cpp b/tests/unit/operation/geounion/CascadedPolygonUnionTest.cpp
index 2536c63..879db94 100644
--- a/tests/unit/operation/geounion/CascadedPolygonUnionTest.cpp
+++ b/tests/unit/operation/geounion/CascadedPolygonUnionTest.cpp
@@ -3,6 +3,7 @@
 
 // tut
 #include <tut/tut.hpp>
+#include <utility.h>
 // geos
 #include <geos/operation/union/CascadedPolygonUnion.h>
 #include <geos/geom/GeometryFactory.h>
@@ -72,15 +73,9 @@ p_test_runner(test_cascadedpolygonuniontest_data& t,
 {
     std::unique_ptr<geos::geom::Geometry> union1(unionIterated(geoms));
     std::unique_ptr<geos::geom::Geometry> union2(unionCascaded(geoms));
-
-    // For now we compare the WKT representations of the two generated
-    // geometries which works well for simple geometries only.
-    // More complex geometries require to use special similarity measure
-    // criteria instead.
-    std::string iterated(t.wktwriter.writeFormatted(union1.get()));
-    std::string cascaded(t.wktwriter.writeFormatted(union2.get()));
-
-    ensure_equals(iterated, cascaded);
+    union1->normalize();
+    union2->normalize();
+    ensure_equals_geometry(union1.get(), union2.get(), 0.000001);
 }
 
 void
diff --git a/tests/unit/operation/linemerge/LineMergerTest.cpp b/tests/unit/operation/linemerge/LineMergerTest.cpp
index 19906c2..650e8f2 100644
--- a/tests/unit/operation/linemerge/LineMergerTest.cpp
+++ b/tests/unit/operation/linemerge/LineMergerTest.cpp
@@ -261,31 +261,6 @@ void object::test<7>
     doTest(inpWKT, expWKT);
 }
 
-// Merge union of segments of a triangle
-template<> template<>
-void object::test<8>
-()
-{
-    GeomPtr line1(readWKT("LINESTRING(0 0, 0 5)"));
-    GeomPtr line2(readWKT("LINESTRING(0 5, 5 5)"));
-    GeomPtr line3(readWKT("LINESTRING(5 5, 5 0)"));
-    GeomPtr line4(readWKT("LINESTRING(5 0, 0 0)"));
-    // Union segments incrementally
-    GeomPtr lines12(line1->Union(line2.get()));
-    GeomPtr lines123(lines12->Union(line3.get()));
-    GeomPtr lines1234(lines123->Union(line4.get()));
-
-    // MultiLineString expected by design, see corresponding test in OverlayOpUnionTest
-    ensure_equals(lines1234->getGeometryTypeId(), geos::geom::GEOS_MULTILINESTRING);
-
-    // Merge MultiLineString into LineString
-    LineMerger lineMerger;
-    lineMerger.add(lines1234.get());
-    auto mrgGeoms = lineMerger.getMergedLineStrings();
-
-    GeomPtr expected(readWKT("LINESTRING(0 0, 0 5, 5 5, 5 0, 0 0)"));
-    ensure(contains(mrgGeoms, expected.get(), true));
-}
 
 } // namespace tut
 
diff --git a/tests/unit/operation/overlay/OverlayOpUnionTest.cpp b/tests/unit/operation/overlay/OverlayOpUnionTest.cpp
index 672d008..4787217 100644
--- a/tests/unit/operation/overlay/OverlayOpUnionTest.cpp
+++ b/tests/unit/operation/overlay/OverlayOpUnionTest.cpp
@@ -49,13 +49,14 @@ void object::test<1>
     GeometryPtr line2(reader.read("LINESTRING(0 5, 5 5)"));
     GeometryPtr line3(reader.read("LINESTRING(5 5, 5 0)"));
     GeometryPtr line4(reader.read("LINESTRING(5 0, 0 0)"));
+    GeometryPtr expect(reader.read("LINESTRING(0 0,0 5,5 5,5 0,0 0)"));
 
     // union segments incrementally
     GeometryPtr lines12(line1->Union(line2.get()));
     GeometryPtr lines123(lines12->Union(line3.get()));
     GeometryPtr lines1234(lines123->Union(line4.get()));
 
-    ensure_equals(lines1234->getGeometryTypeId(), geos::geom::GEOS_MULTILINESTRING);
+    ensure(expect->contains(lines1234.get()));
 
     // NOTE: Since the union operation makes no effort to simplify and
     // drop nodes of degree 2 from the built topology,

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

Summary of changes:
 tests/unit/capi/GEOSIntersectionTest.cpp           | 19 +++++++++++++++-
 tests/unit/capi/GEOSMakeValidTest.cpp              |  6 +++++-
 tests/unit/capi/GEOSUnaryUnionTest.cpp             | 12 +++++++----
 .../geounion/CascadedPolygonUnionTest.cpp          | 13 ++++-------
 tests/unit/operation/linemerge/LineMergerTest.cpp  | 25 ----------------------
 .../unit/operation/overlay/OverlayOpUnionTest.cpp  |  3 ++-
 6 files changed, 37 insertions(+), 41 deletions(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list