[geos-commits] [SCM] GEOS branch main updated. 54ed380c031c9bec3b2eac02119c518e7eeb643e

git at osgeo.org git at osgeo.org
Tue Nov 21 05:36:33 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  54ed380c031c9bec3b2eac02119c518e7eeb643e (commit)
      from  4767afd144f86a7a2be0f796639eac34ea5760eb (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 54ed380c031c9bec3b2eac02119c518e7eeb643e
Author: Dan Baston <dbaston at gmail.com>
Date:   Tue Nov 21 08:36:00 2023 -0500

    CoordinateSequence: Fix logic error when adding XYM seq to XYZ seq (#999)
    
    Logic error only causes an incorrect result when GEOS_COORDSEQ_PADZ is
    not defined.
    
    Fixes https://github.com/libgeos/geos/issues/997

diff --git a/src/geom/CoordinateSequence.cpp b/src/geom/CoordinateSequence.cpp
index fc36b4bb3..0ba723fb1 100644
--- a/src/geom/CoordinateSequence.cpp
+++ b/src/geom/CoordinateSequence.cpp
@@ -151,7 +151,7 @@ CoordinateSequence::initialize()
 void
 CoordinateSequence::add(const CoordinateSequence& cs, std::size_t from, std::size_t to)
 {
-    if (cs.stride() == stride() && cs.hasM() == cs.hasM()) {
+    if (cs.stride() == stride() && cs.hasM() == hasM()) {
         m_vect.insert(m_vect.end(),
                       std::next(cs.m_vect.cbegin(), static_cast<std::ptrdiff_t>(from * stride())),
                       std::next(cs.m_vect.cbegin(), static_cast<std::ptrdiff_t>((to + 1u)*stride())));
diff --git a/tests/unit/geom/CoordinateSequenceTest.cpp b/tests/unit/geom/CoordinateSequenceTest.cpp
index 1d9c08782..579bba868 100644
--- a/tests/unit/geom/CoordinateSequenceTest.cpp
+++ b/tests/unit/geom/CoordinateSequenceTest.cpp
@@ -1344,7 +1344,7 @@ void object::test<49>
     ensure_same(c1.z, 2);
 }
 
-// Test move contructor
+// Test move constructor
 template<>
 template<>
 void object::test<50>
@@ -1510,4 +1510,30 @@ void object::test<55>
     ensure_equals(seq1, expected);
 }
 
+// add XYM seq to XYZ seq
+template<>
+template<>
+void object::test<56>
+()
+{
+    CoordinateSequence seq1 = CoordinateSequence::XYZ(0);
+    CoordinateSequence seq2 = CoordinateSequence::XYM(0);
+
+    seq1.add(Coordinate(1, 2, 3));
+    seq1.add(Coordinate(4, 5, 6));
+
+    seq2.add(CoordinateXYM(7, 8, 9));
+    seq2.add(CoordinateXYM(10, 11, 12));
+
+    seq1.add(seq2);
+
+    ensure(seq1.hasZ());
+    ensure(!seq1.hasM());
+
+    ensure_equals_xyz(seq1.getAt(0), Coordinate{1, 2, 3});
+    ensure_equals_xyz(seq1.getAt(1), Coordinate{4, 5, 6});
+    ensure_equals_xyz(seq1.getAt(2), Coordinate{7, 8, DoubleNotANumber});
+    ensure_equals_xyz(seq1.getAt(3), Coordinate{10, 11, DoubleNotANumber});
+}
+
 } // namespace tut

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

Summary of changes:
 src/geom/CoordinateSequence.cpp            |  2 +-
 tests/unit/geom/CoordinateSequenceTest.cpp | 28 +++++++++++++++++++++++++++-
 2 files changed, 28 insertions(+), 2 deletions(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list