[geos-commits] [SCM] GEOS branch 3.10 updated. 2f4f2a402097e2033c95414d5f5f42bd6384b617

git at osgeo.org git at osgeo.org
Wed Nov 3 08:28:56 PDT 2021


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.10 has been updated
       via  2f4f2a402097e2033c95414d5f5f42bd6384b617 (commit)
       via  9194c25de8cf56726a07b59b71644dca2b683715 (commit)
      from  a5c7bf16c3fb9b6457f644b66f1312705bee0153 (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 2f4f2a402097e2033c95414d5f5f42bd6384b617
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Wed Nov 3 08:28:50 2021 -0700

    Add news entry for #1139 fix

diff --git a/NEWS b/NEWS
index 26d924760..b61e8f8ff 100644
--- a/NEWS
+++ b/NEWS
@@ -3,7 +3,7 @@ Changes in 3.10.2
 2021-xx-xx
 
 - Fixes/Improvements:
-
+  - Fix crash in GeoJSONWriter in case of empty points (#1139, Paul Ramsey)
 
 
 Changes in 3.10.1

commit 9194c25de8cf56726a07b59b71644dca2b683715
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Wed Nov 3 08:27:50 2021 -0700

    Fix crash in GeoJSONWriter in the case of empty points. Add some tests around empty geometries in general. References #1139

diff --git a/src/dirlist.mk b/src/dirlist.mk
deleted file mode 100644
index 15f2a11ff..000000000
--- a/src/dirlist.mk
+++ /dev/null
@@ -1,48 +0,0 @@
-#
-# List of directories use by makefile.vc to clean .obj files
-#
-
-GEOS_DIRLIST =  \
-	algorithm \
-	algorithm\distance \
-	algorithm\locate \
-	examples \
-	geom \
-	geom\util \
-	geom\prep \
-	geomgraph \
-	geomgraph\index \
-	headers \
-	headers\geos \
-	index \
-	index\bintree \
-	index\chain \
-	index\intervalrtree \
-	index\quadtree \
-	index\strtree \
-	index\sweepline \
-	io \
-	linearref \
-	noding \
-	noding\snapround \
-	operation \
-	operation\buffer \
-	operation\distance \
-	operation\intersection \
-	operation\linemerge \
-	operation\overlay \
-	operation\overlay\snap \
-	operation\overlay\validate \
-	operation\polygonize \
-	operation\predicate \
-	operation\relate \
-	operation\sharedpaths \
-	operation\union \
-	operation\valid \
-	planargraph \
-	planargraph\algorithm \
-	precision \
-	simplify \
-	triangulate \
-	triangulate\quadedge \
-	util
diff --git a/src/io/GeoJSONWriter.cpp b/src/io/GeoJSONWriter.cpp
index c8bbab50d..464f26b7c 100644
--- a/src/io/GeoJSONWriter.cpp
+++ b/src/io/GeoJSONWriter.cpp
@@ -205,7 +205,12 @@ void GeoJSONWriter::encodeGeometry(const geom::Geometry* geometry, geos_nlohmann
 void GeoJSONWriter::encodePoint(const geom::Point* point, geos_nlohmann::ordered_json& j)
 {
     j["type"] = "Point";
-    j["coordinates"] = convertCoordinate(point->getCoordinate());
+    if (!point->isEmpty()) {
+        j["coordinates"] = convertCoordinate(point->getCoordinate());
+    }
+    else {
+        j["coordinates"] = j.array();
+    }
 }
 
 void GeoJSONWriter::encodeLineString(const geom::LineString* line, geos_nlohmann::ordered_json& j)
diff --git a/tests/unit/io/GeoJSONWriterTest.cpp b/tests/unit/io/GeoJSONWriterTest.cpp
index 6faab6ecb..201db101b 100644
--- a/tests/unit/io/GeoJSONWriterTest.cpp
+++ b/tests/unit/io/GeoJSONWriterTest.cpp
@@ -252,4 +252,47 @@ void object::test<14>
     ensure_equals(result, "{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"geometry\":{\"type\":\"Point\",\"coordinates\":[-117.0,33.0]},\"properties\":{\"id\":1.0,\"name\":\"One\"}},{\"type\":\"Feature\",\"geometry\":{\"type\":\"Point\",\"coordinates\":[-127.0,53.0]},\"properties\":{\"id\":2.0,\"name\":\"Two\"}}]}");
 }
 
+// Write an empty point
+template<>
+template<>
+void object::test<15>
+()
+{
+    GeomPtr geom(wktreader.read("POINT EMPTY"));
+    std::string result = geojsonwriter.write(geom.get());
+    ensure_equals(result, "{\"type\":\"Point\",\"coordinates\":[]}");
+}
+
+// Write an empty linestring
+template<>
+template<>
+void object::test<16>
+()
+{
+    GeomPtr geom(wktreader.read("LINESTRING EMPTY"));
+    std::string result = geojsonwriter.write(geom.get());
+    ensure_equals(result, "{\"type\":\"LineString\",\"coordinates\":[]}");
+}
+
+// Write an empty polygon
+template<>
+template<>
+void object::test<17>
+()
+{
+    GeomPtr geom(wktreader.read("POLYGON EMPTY"));
+    std::string result = geojsonwriter.write(geom.get());
+    ensure_equals(result, "{\"type\":\"Polygon\",\"coordinates\":[[]]}");
+}
+
+// Write an empty polygon
+template<>
+template<>
+void object::test<18>
+()
+{
+    GeomPtr geom(wktreader.read("GEOMETRYCOLLECTION EMPTY"));
+    std::string result = geojsonwriter.write(geom.get());
+    ensure_equals(result, "{\"type\":\"GeometryCollection\",\"geometries\":[]}");
+}
 }

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

Summary of changes:
 NEWS                                |  2 +-
 src/dirlist.mk                      | 48 -------------------------------------
 src/io/GeoJSONWriter.cpp            |  7 +++++-
 tests/unit/io/GeoJSONWriterTest.cpp | 43 +++++++++++++++++++++++++++++++++
 4 files changed, 50 insertions(+), 50 deletions(-)
 delete mode 100644 src/dirlist.mk


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list