[geos-commits] [SCM] GEOS branch master updated. 74d26b3687e23d95175aa0afa5349613ae4149a6

git at osgeo.org git at osgeo.org
Tue Dec 1 08:12:28 PST 2020


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, master has been updated
       via  74d26b3687e23d95175aa0afa5349613ae4149a6 (commit)
       via  9211fae903a22fc8fc68de47a1a0357fe1bfa4b8 (commit)
      from  2522fba2d8851500a8d9f39337e07bbf5c0a5653 (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 74d26b3687e23d95175aa0afa5349613ae4149a6
Merge: 2522fba 9211fae
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Tue Dec 1 08:11:55 2020 -0800

    Return WKT parsing to 3.8 model
    for inputs with mixed dimensionality.


commit 9211fae903a22fc8fc68de47a1a0357fe1bfa4b8
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Mon Nov 30 15:43:41 2020 -0800

    Match WKT reader behaviour to 3.8
    For mixed dimension WKT, take the first coordinate as gospel
    and then coerce all following coordinates into that dimension.
    This should be updated in the next release with a stricter
    parser (no mixed dimensions? or at least be consistent, since
    MULTIPOINT doesn't quite follow this behaviour).

diff --git a/src/io/WKTReader.cpp b/src/io/WKTReader.cpp
index 384c8bd..d51657d 100644
--- a/src/io/WKTReader.cpp
+++ b/src/io/WKTReader.cpp
@@ -78,18 +78,17 @@ WKTReader::getCoordinates(StringTokenizer* tokenizer)
 
     Coordinate coord;
     getPreciseCoordinate(tokenizer, coord, dim);
-
-    std::vector<Coordinate> v;
-    v.push_back(coord);
+    auto coordinates = detail::make_unique<CoordinateArraySequence>(0, dim);
+    coordinates->add(coord);
 
     nextToken = getNextCloserOrComma(tokenizer);
     while(nextToken == ",") {
         getPreciseCoordinate(tokenizer, coord, dim);
-        v.push_back(coord);
+        coordinates->add(coord);
         nextToken = getNextCloserOrComma(tokenizer);
     }
 
-    return geometryFactory->getCoordinateSequenceFactory()->create(std::move(v), dim);
+    return std::move(coordinates);
 }
 
 
diff --git a/tests/unit/io/WKTReaderTest.cpp b/tests/unit/io/WKTReaderTest.cpp
index f7808fb..e725ede 100644
--- a/tests/unit/io/WKTReaderTest.cpp
+++ b/tests/unit/io/WKTReaderTest.cpp
@@ -219,4 +219,39 @@ void object::test<9>
 }
 
 
+// Handle WKT with mixed dimensionality in
+// coordinate sequence. This is the old behaviour, wherein
+// the first coordinate of a coordinate sequence dictates the
+// dimensionality of the following coordinates. This ignores
+// dimensionality tags (Z/M). It also has strange behaviour
+// in the multipoint case, but we leave this unchanged for now
+// as this test is being written just prior to 3.9 release.
+template<>
+template<>
+void object::test<10>
+()
+{
+    GeomPtr geom;
+    geom = wktreader.read("MULTIPOINT (1 1, 2 2)");
+    ensure("dimension(MULTIPOINT (1 1, 2 2)) == 2", geom->getCoordinateDimension() == 2);
+
+    geom = wktreader.read("LINESTRING (1 1, 2 2)");
+    ensure("dimension(LINESTRING (1 1, 2 2)) == 2", geom->getCoordinateDimension() == 2);
+
+    geom = wktreader.read("MULTIPOINT (1 1 1, 2 2)");
+    ensure("dimension(MULTIPOINT (1 1 1, 2 2)) == 3", geom->getCoordinateDimension() == 3);
+
+    geom = wktreader.read("MULTIPOINT (1 1, 2 2 2)");
+    ensure("dimension(MULTIPOINT (1 1, 2 2 2)) == 3", geom->getCoordinateDimension() == 3);
+
+    geom = wktreader.read("LINESTRING (1 1 1, 2 2)");
+    ensure("dimension(LINESTRING (1 1 1, 2 2)) == 3", geom->getCoordinateDimension() == 3);
+
+    geom = wktreader.read("LINESTRING (1 1, 2 2 2)");
+    ensure("dimension(LINESTRING (1 1, 2 2 2)) == 2", geom->getCoordinateDimension() == 2);
+
+    geom = wktreader.read("POLYGON ((0 0, 1 0, 1 1 1, 0 1, 0 0))");
+    ensure("dimension(POLYGON ((0 0, 1 0, 1 1 1, 0 1, 0 0)) == 2", geom->getCoordinateDimension() == 2);
+}
+
 } // namespace tut

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

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


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list