[geos-commits] [SCM] GEOS branch 3.13 updated. a5f51f7c6c26cdd498bf4328568e54aca3f1ad6a

git at osgeo.org git at osgeo.org
Fri Nov 15 14:48:27 PST 2024


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, 3.13 has been updated
       via  a5f51f7c6c26cdd498bf4328568e54aca3f1ad6a (commit)
       via  fa087153f3e6cc8dce1e55e9f3301ba2f8565896 (commit)
      from  3c648f216b961e9b86cca48d368f32e918d573ce (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 a5f51f7c6c26cdd498bf4328568e54aca3f1ad6a
Merge: fa087153f 3c648f216
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Fri Nov 15 14:47:47 2024 -0800

    Fix LineString->getPoint(n) for M geometries (closes GH-1191)

diff --cc NEWS.md
index 1f555c9cb,eef6897a2..82a4eddfc
--- a/NEWS.md
+++ b/NEWS.md
@@@ -4,7 -4,7 +4,9 @@@
  - Fixes/Improvements:
    - Fix ConcaveHullOfPolygons nested shell handling (GH-1169, Martin Davis)
    - Fix RelateNG for computing IM for empty-nonempty cases (Martin Davis)
 -    - Fix TopologyPreservingSimplifier/TaggedLineString to avoid jumping components (JTS-1096, Martin Davis)
 +  - Fix LineString->getPoint(n) for M geometries (GH-1191, @hsieyuan)
++  - Fix TopologyPreservingSimplifier/TaggedLineString to avoid jumping components (JTS-1096, Martin Davis)
++
  
  ## Changes in 3.13.0
  2024-09-06

commit fa087153f3e6cc8dce1e55e9f3301ba2f8565896
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Fri Nov 15 14:46:31 2024 -0800

    Fix LineString->getPoint(n) for M geometries (closes GH-1191)

diff --git a/NEWS.md b/NEWS.md
index b605e1a62..1f555c9cb 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -4,6 +4,7 @@
 - Fixes/Improvements:
   - Fix ConcaveHullOfPolygons nested shell handling (GH-1169, Martin Davis)
   - Fix RelateNG for computing IM for empty-nonempty cases (Martin Davis)
+  - Fix LineString->getPoint(n) for M geometries (GH-1191, @hsieyuan)
 
 ## Changes in 3.13.0
 2024-09-06
diff --git a/src/geom/SimpleCurve.cpp b/src/geom/SimpleCurve.cpp
index be9b50b44..dcbaf7114 100644
--- a/src/geom/SimpleCurve.cpp
+++ b/src/geom/SimpleCurve.cpp
@@ -251,7 +251,16 @@ SimpleCurve::getPointN(std::size_t n) const
 {
     assert(getFactory());
     assert(points.get());
-    return std::unique_ptr<Point>(getFactory()->createPoint(points->getAt(n)));
+    if (hasM() || hasZ()) {
+        CoordinateXYZM c;
+        points->getAt(n, c);
+        return getFactory()->createPoint(c);
+    }
+    else {
+        CoordinateXY c;
+        points->getAt(n, c);
+        return getFactory()->createPoint(c);
+    }
 }
 
 std::unique_ptr<Point>
diff --git a/tests/unit/geom/LineStringTest.cpp b/tests/unit/geom/LineStringTest.cpp
index 26a8756bf..1e1136fce 100644
--- a/tests/unit/geom/LineStringTest.cpp
+++ b/tests/unit/geom/LineStringTest.cpp
@@ -13,6 +13,7 @@
 #include <geos/geom/GeometryFactory.h>
 #include <geos/geom/PrecisionModel.h>
 #include <geos/io/WKTReader.h>
+#include <geos/io/WKTWriter.h>
 #include <geos/util/GEOSException.h>
 #include <geos/util/IllegalArgumentException.h>
 #include <geos/constants.h>
@@ -35,6 +36,7 @@ struct test_linestring_data {
     geos::geom::PrecisionModel pm_;
     geos::geom::GeometryFactory::Ptr factory_;
     geos::io::WKTReader reader_;
+    geos::io::WKTWriter writer_;
 
     std::unique_ptr<geos::geom::LineString> empty_line_;
     std::unique_ptr<geos::geom::LineString> line_;
@@ -588,5 +590,23 @@ void object::test<32>
     ensure(!line_->hasDimension(geos::geom::Dimension::A));
 }
 
+
+// https://github.com/libgeos/geos/issues/1191
+// line->getPoint(n) loses M dimension
+template<>
+template<>
+void object::test<33>
+()
+{
+    auto geom = reader_.read("LINESTRING M (0 1 2, 10 11 12, 20 21 22)");
+    ensure(geom != nullptr);
+    geos::geom::LineString *line = static_cast<LineString*>(geom.get());
+    ensure_equals(line->getCoordinateDimension(), 3);
+    auto pt = line->getPointN(2);
+    auto out = writer_.write(*pt);
+    ensure_equals(out, "POINT M (20 21 22)");
+}
+
+
 } // namespace tut
 

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

Summary of changes:
 NEWS.md                            |  4 +++-
 src/geom/SimpleCurve.cpp           | 11 ++++++++++-
 tests/unit/geom/LineStringTest.cpp | 20 ++++++++++++++++++++
 3 files changed, 33 insertions(+), 2 deletions(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list