[geos-commits] [SCM] GEOS branch main updated. 301bc462db3b8fd3d28137ccbfb8d0ee85d0c479

git at osgeo.org git at osgeo.org
Tue Nov 21 08:04:58 PST 2023


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  301bc462db3b8fd3d28137ccbfb8d0ee85d0c479 (commit)
      from  cbfa2ec36e2e33e3290ce78007c36d46b99517d4 (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 301bc462db3b8fd3d28137ccbfb8d0ee85d0c479
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Tue Nov 21 08:04:37 2023 -0800

    Return 2D empty linestring on GEOSGeom_createLineString(NULL) (#998)
    
    References GH-993

diff --git a/src/geom/GeometryFactory.cpp b/src/geom/GeometryFactory.cpp
index 881189fc2..77a8a8995 100644
--- a/src/geom/GeometryFactory.cpp
+++ b/src/geom/GeometryFactory.cpp
@@ -509,6 +509,8 @@ std::unique_ptr<LineString>
 GeometryFactory::createLineString(CoordinateSequence::Ptr && newCoords)
 const
 {
+    if (!newCoords)
+        return createLineString();
     // Can't use make_unique with protected constructor
     return std::unique_ptr<LineString>(new LineString(std::move(newCoords), *this));
 }
diff --git a/tests/unit/capi/GEOSGeom_createTest.cpp b/tests/unit/capi/GEOSGeom_createTest.cpp
index 78ca61cf1..6910a74f7 100644
--- a/tests/unit/capi/GEOSGeom_createTest.cpp
+++ b/tests/unit/capi/GEOSGeom_createTest.cpp
@@ -11,13 +11,16 @@
 #include <cstdlib>
 #include <memory>
 
+#include "capi_test_utils.h"
+
 namespace tut {
 //
 // Test Group
 //
 
 // Common data used in test cases.
-struct test_capigeosgeom_create_data {
+struct test_capigeosgeom_create_data  : public capitest::utility
+{
     GEOSGeometry* geom1_;
     GEOSContextHandle_t handle_;
 
@@ -177,6 +180,14 @@ void object::test<7>
     geom1_ = nullptr;
 }
 
+template<>
+template<>
+void object::test<8>()
+{
+    input_ = GEOSGeom_createLineString(NULL);
+    ensure_equals(GEOSHasZ(input_), 0);
+    ensure_equals(GEOSHasM(input_), 0);
+}
 
 } // namespace tut
 
diff --git a/tests/unit/capi/GEOSHasZMTest.cpp b/tests/unit/capi/GEOSHasZMTest.cpp
index ff36ef7b2..346ca97d8 100644
--- a/tests/unit/capi/GEOSHasZMTest.cpp
+++ b/tests/unit/capi/GEOSHasZMTest.cpp
@@ -106,5 +106,6 @@ void object::test<9>()
     ensure_equals(GEOSHasM(input_), 1);
 }
 
+
 } // namespace tut
 

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

Summary of changes:
 src/geom/GeometryFactory.cpp            |  2 ++
 tests/unit/capi/GEOSGeom_createTest.cpp | 13 ++++++++++++-
 tests/unit/capi/GEOSHasZMTest.cpp       |  1 +
 3 files changed, 15 insertions(+), 1 deletion(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list