[geos-commits] [SCM] GEOS branch main updated. 46c3b99274b0f0dfacf96184bd9a8cf603489267

git at osgeo.org git at osgeo.org
Mon May 15 04:04:17 PDT 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  46c3b99274b0f0dfacf96184bd9a8cf603489267 (commit)
      from  2cac99d49fef48d4054f4d74bfc3cbd7bc8bcdcf (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 46c3b99274b0f0dfacf96184bd9a8cf603489267
Author: Mike Taves <mwtoews at gmail.com>
Date:   Mon May 15 13:04:08 2023 +1200

    Fix reading MultiPoint Z/M WKT (#901)

diff --git a/src/io/WKTReader.cpp b/src/io/WKTReader.cpp
index efe6d9219..3ed640630 100644
--- a/src/io/WKTReader.cpp
+++ b/src/io/WKTReader.cpp
@@ -338,9 +338,8 @@ WKTReader::readMultiPointText(StringTokenizer* tokenizer, OrdinateSet& ordinateF
     int tok = tokenizer->peekNextToken();
 
     if(tok == StringTokenizer::TT_NUMBER) {
-
-        // Try to parse deprecated form "MULTIPOINT(0 0, 1 1)"
-        auto coords = detail::make_unique<CoordinateSequence>();
+        // Try to parse "MULTIPOINT (0 0, 1 1)"
+        auto coords = detail::make_unique<CoordinateSequence>(0u, ordinateFlags.hasZ(), ordinateFlags.hasM());
 
         CoordinateXYZM coord(0, 0, DoubleNotANumber, DoubleNotANumber);
         do {
@@ -353,8 +352,8 @@ WKTReader::readMultiPointText(StringTokenizer* tokenizer, OrdinateSet& ordinateF
         return std::unique_ptr<MultiPoint>(geometryFactory->createMultiPoint(*coords));
     }
 
-    else if(tok == '(' ||  // Try to parse correct form "MULTIPOINT((0 0), (1 1))"
-            tok == StringTokenizer::TT_WORD)  // EMPTY?
+    else if(tok == '(' ||        // Try to parse "MULTIPOINT ((0 0), (1 1))"
+            tok == StringTokenizer::TT_WORD)  // "MULTIPOINT (EMPTY, (1 1))"
     {
         std::vector<std::unique_ptr<Point>> points;
 
diff --git a/tests/unit/io/WKTReaderTest.cpp b/tests/unit/io/WKTReaderTest.cpp
index 067dedabc..3180a6686 100644
--- a/tests/unit/io/WKTReaderTest.cpp
+++ b/tests/unit/io/WKTReaderTest.cpp
@@ -49,6 +49,12 @@ struct test_wktreader_data {
                       dim);
     }
 
+    void ensure_dimension(const std::string & wkt, bool has_z, bool has_m) const {
+        auto geom = wktreader.read(wkt);
+        ensure_equals(wkt + " hasZ", geom->hasZ(), has_z);
+        ensure_equals(wkt + " hasM", geom->hasM(), has_m);
+    }
+
     void ensure_parseexception(const std::string & wkt) const {
         try {
             auto geom = wktreader.read(wkt);
@@ -423,4 +429,22 @@ void object::test<21>
     }
 }
 
+// https://github.com/libgeos/geos/issues/886
+template<>
+template<>
+void object::test<22>
+()
+{
+
+    ensure_dimension("MULTIPOINT (0 0, 1 2)", false, false);
+    ensure_dimension("MULTIPOINT Z (0 0 4, 1 2 4)", true, false);
+    ensure_dimension("MULTIPOINT M (0 0 3, 1 2 5)", false, true);
+    ensure_dimension("MULTIPOINT ZM (0 0 4 3, 1 2 4 5)", true, true);
+
+    ensure_dimension("MULTIPOINT ((0 0), (1 2))", false, false);
+    ensure_dimension("MULTIPOINT Z ((0 0 4), (1 2 4))", true, false);
+    ensure_dimension("MULTIPOINT M ((0 0 3), (1 2 5))", false, true);
+    ensure_dimension("MULTIPOINT ZM ((0 0 4 3), (1 2 4 5))", true, true);
+}
+
 } // namespace tut

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

Summary of changes:
 src/io/WKTReader.cpp            |  9 ++++-----
 tests/unit/io/WKTReaderTest.cpp | 24 ++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 5 deletions(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list