[geos-commits] [SCM] GEOS branch main updated. 654ad34cf7381500acc545d2bc8e4317026cefdd

git at osgeo.org git at osgeo.org
Thu Aug 22 15:14:06 PDT 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, main has been updated
       via  654ad34cf7381500acc545d2bc8e4317026cefdd (commit)
      from  937cf5f58d6071b1ca163ed2ce55488c1f95c57e (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 654ad34cf7381500acc545d2bc8e4317026cefdd
Author: Oreille <33065839+Oreilles at users.noreply.github.com>
Date:   Fri Aug 23 00:13:39 2024 +0200

    FIX: 3D coordinates handling of GeoJSON MultiLineString (#1151)

diff --git a/src/io/GeoJSONReader.cpp b/src/io/GeoJSONReader.cpp
index fe53b63c7..0f0817e32 100644
--- a/src/io/GeoJSONReader.cpp
+++ b/src/io/GeoJSONReader.cpp
@@ -317,7 +317,7 @@ std::unique_ptr<geom::MultiLineString> GeoJSONReader::readMultiLineString(
         coordinates->reserve(coords.size());
         for (const auto& coord : coords) {
             const geom::Coordinate& c = readCoordinate(coord);
-            coordinates->add(geom::Coordinate{c.x, c.y});
+            coordinates->add(c);
         }
         lines.push_back(geometryFactory.createLineString(std::move(coordinates)));
     }
diff --git a/tests/unit/io/GeoJSONReaderTest.cpp b/tests/unit/io/GeoJSONReaderTest.cpp
index 2a8e7c030..c5ff39db8 100644
--- a/tests/unit/io/GeoJSONReaderTest.cpp
+++ b/tests/unit/io/GeoJSONReaderTest.cpp
@@ -596,4 +596,28 @@ void object::test<38>
     ensure_equals(static_cast<size_t>(geom->getCoordinateDimension()), 3u);
 }
 
+// Read a GeoJSON MultiLineString with three dimensions
+template<>
+template<>
+void object::test<39>
+()
+{
+    std::string geojson { "{\"type\":\"MultiLineString\",\"coordinates\":[[[30,10,1],[40,40,2],[20,40,4],[10,20,8],[30,10,16]]]}" };
+    GeomPtr geom(geojsonreader.read(geojson));
+    ensure_equals(geom->toText(), "MULTILINESTRING Z ((30 10 1, 40 40 2, 20 40 4, 10 20 8, 30 10 16))");
+    ensure_equals(static_cast<size_t>(geom->getCoordinateDimension()), 3u);
+}
+
+// Read a GeoJSON MultiLineString with mixed dimensions
+template<>
+template<>
+void object::test<40>
+()
+{
+    std::string geojson { "{\"type\":\"MultiLineString\",\"coordinates\":[[[30,10],[40,40,2],[20,40],[10,20,8],[30,10]]]}" };
+    GeomPtr geom(geojsonreader.read(geojson));
+    ensure_equals(geom->toText(), "MULTILINESTRING Z ((30 10 NaN, 40 40 2, 20 40 NaN, 10 20 8, 30 10 NaN))");
+    ensure_equals(static_cast<size_t>(geom->getCoordinateDimension()), 3u);
+}
+
 }

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

Summary of changes:
 src/io/GeoJSONReader.cpp            |  2 +-
 tests/unit/io/GeoJSONReaderTest.cpp | 24 ++++++++++++++++++++++++
 2 files changed, 25 insertions(+), 1 deletion(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list