[geos-commits] [SCM] GEOS branch main updated. 4c38944f8b5ef440398ba5f8db14b75489de5d68

git at osgeo.org git at osgeo.org
Mon Oct 4 09:13:40 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, main has been updated
       via  4c38944f8b5ef440398ba5f8db14b75489de5d68 (commit)
       via  39ab31cba740285700b13357984a31130d18ed85 (commit)
       via  6b46203d77554b7a3a78018091d50cdfd11e4303 (commit)
      from  2696f86ec20ce4100c742b730c87ab401492f1b7 (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 4c38944f8b5ef440398ba5f8db14b75489de5d68
Merge: 39ab31c 2696f86
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Mon Oct 4 09:13:33 2021 -0700

    Merge branch 'main' of https://git.osgeo.org/gitea/geos/geos into main


commit 39ab31cba740285700b13357984a31130d18ed85
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Mon Oct 4 09:13:24 2021 -0700

    Content of IsValidTest and IsValidReasonTest were reversed for some reason.

diff --git a/tests/unit/capi/GEOSisValidReasonTest.cpp b/tests/unit/capi/GEOSisValidReasonTest.cpp
index 8166cc5..cf20091 100644
--- a/tests/unit/capi/GEOSisValidReasonTest.cpp
+++ b/tests/unit/capi/GEOSisValidReasonTest.cpp
@@ -9,12 +9,12 @@ namespace tut {
 // Test Group
 //
 
-struct test_geosisvalid_data : public capitest::utility {};
+struct test_geosisvalidreason_data : public capitest::utility {};
 
-typedef test_group<test_geosisvalid_data> group;
+typedef test_group<test_geosisvalidreason_data> group;
 typedef group::object object;
 
-group test_geosisvalid("capi::GEOSisValid");
+group test_geosisvalidreason("capi::GEOSisValidReason");
 
 template<>
 template<>
@@ -22,9 +22,12 @@ void object::test<1>()
 {
     GEOSGeometry* input = GEOSGeomFromWKT("LINESTRING (1 2, 4 5, 9 -2)");
 
-    ensure_equals(1, GEOSisValid(input));
+    char* reason = GEOSisValidReason(input);
+
+    ensure_equals(std::string(reason), "Valid Geometry");
 
     GEOSGeom_destroy(input);
+    GEOSFree(reason);
 }
 
 template<>
@@ -33,9 +36,12 @@ void object::test<2>()
 {
     GEOSGeometry* input = GEOSGeomFromWKT("POLYGON ((0 0, 1 0, 0 1, 1 1, 0 0))");
 
-    ensure_equals(0, GEOSisValid(input));
+    char* reason = GEOSisValidReason(input);
+
+    ensure_equals(std::string(reason), "Self-intersection[0.5 0.5]");
 
     GEOSGeom_destroy(input);
+    GEOSFree(reason);
 }
 
 
diff --git a/tests/unit/capi/GEOSisValidTest.cpp b/tests/unit/capi/GEOSisValidTest.cpp
index cf20091..1580adb 100644
--- a/tests/unit/capi/GEOSisValidTest.cpp
+++ b/tests/unit/capi/GEOSisValidTest.cpp
@@ -9,12 +9,12 @@ namespace tut {
 // Test Group
 //
 
-struct test_geosisvalidreason_data : public capitest::utility {};
+struct test_geosisvalid_data : public capitest::utility {};
 
-typedef test_group<test_geosisvalidreason_data> group;
+typedef test_group<test_geosisvalid_data> group;
 typedef group::object object;
 
-group test_geosisvalidreason("capi::GEOSisValidReason");
+group test_geosisvalid("capi::GEOSisValid");
 
 template<>
 template<>
@@ -22,12 +22,9 @@ void object::test<1>()
 {
     GEOSGeometry* input = GEOSGeomFromWKT("LINESTRING (1 2, 4 5, 9 -2)");
 
-    char* reason = GEOSisValidReason(input);
-
-    ensure_equals(std::string(reason), "Valid Geometry");
+    ensure_equals(1, GEOSisValid(input));
 
     GEOSGeom_destroy(input);
-    GEOSFree(reason);
 }
 
 template<>
@@ -36,14 +33,30 @@ void object::test<2>()
 {
     GEOSGeometry* input = GEOSGeomFromWKT("POLYGON ((0 0, 1 0, 0 1, 1 1, 0 0))");
 
-    char* reason = GEOSisValidReason(input);
-
-    ensure_equals(std::string(reason), "Self-intersection[0.5 0.5]");
+    ensure_equals(0, GEOSisValid(input));
 
     GEOSGeom_destroy(input);
-    GEOSFree(reason);
 }
 
 
-} // namespace tut
+// Unclosed polygon
+template<>
+template<>
+void object::test<3>()
+{
+    GEOSCoordSequence* shell_seq = GEOSCoordSeq_create(4, 2);
+    double shell_coords[] = {0,0, 0,10, 10,10, 10,0};
+    for (unsigned int i = 0; i < 4; i++) {
+        GEOSCoordSeq_setXY(shell_seq, i, shell_coords[2*i], shell_coords[2*i+1]);
+    }
+
+    GEOSGeometry* shell = GEOSGeom_createLinearRing(shell_seq);
+    ensure(shell != nullptr);
+    GEOSGeometry* polygon = GEOSGeom_createPolygon(shell, nullptr, 0);
+    ensure(polygon != nullptr);
+    char isvalid = GEOSisValid(polygon);
+    ensure_equals(0, isvalid);
+    GEOSGeom_destroy(polygon);
+}
 
+} // namespace tut

commit 6b46203d77554b7a3a78018091d50cdfd11e4303
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Mon Oct 4 09:12:56 2021 -0700

    Assert a non-null input to IsValidOp

diff --git a/src/operation/valid/IsValidOp.cpp b/src/operation/valid/IsValidOp.cpp
index df23de5..5f27fbb 100644
--- a/src/operation/valid/IsValidOp.cpp
+++ b/src/operation/valid/IsValidOp.cpp
@@ -80,6 +80,7 @@ IsValidOp::logInvalid(int code, const Coordinate* pt)
 bool
 IsValidOp::isValidGeometry(const Geometry* g)
 {
+    assert(g);
     validErr.reset(nullptr);
 
     // empty geometries are always valid

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

Summary of changes:
 src/operation/valid/IsValidOp.cpp         |  1 +
 tests/unit/capi/GEOSisValidReasonTest.cpp | 16 ++++++++-----
 tests/unit/capi/GEOSisValidTest.cpp       | 37 +++++++++++++++++++++----------
 3 files changed, 37 insertions(+), 17 deletions(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list