[geos-commits] [SCM] GEOS branch 3.8 updated. 03c1615171eae48fa0ef42d6dd6435152d469988
git at osgeo.org
git at osgeo.org
Mon Apr 20 11:18:41 PDT 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, 3.8 has been updated
via 03c1615171eae48fa0ef42d6dd6435152d469988 (commit)
from 925397281833cbea15050c221299a1cf841afa97 (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 03c1615171eae48fa0ef42d6dd6435152d469988
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date: Mon Apr 20 10:17:42 2020 -0700
Fix crash on WKT write of MULTIPOINT(EMPTY, 1 1)
References #1027
diff --git a/NEWS b/NEWS
index eab62a4..5d3a981 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,7 @@ Changes in 3.8.2
- DistanceOp against geometry with empty components
crashes (#1026, Paul Ramsey)
- Remove undefined behaviour in CAPI (#1021, Greg Troxel)
+ - WKT writing of MULTIPOINT with EMPTY component crash (#1027, Paul Ramsey)
Changes in 3.8.1
diff --git a/src/io/WKTWriter.cpp b/src/io/WKTWriter.cpp
index 7c842a1..1573e6f 100644
--- a/src/io/WKTWriter.cpp
+++ b/src/io/WKTWriter.cpp
@@ -426,13 +426,17 @@ WKTWriter::appendMultiPointText(const MultiPoint* multiPoint,
writer->write("(");
for(size_t i = 0, n = multiPoint->getNumGeometries();
i < n; ++i) {
+
if(i > 0) {
writer->write(", ");
}
-
- appendCoordinate(
- dynamic_cast<const Point*>(multiPoint->getGeometryN(i))->getCoordinate(),
- writer);
+ const Coordinate* coord = multiPoint->getGeometryN(i)->getCoordinate();
+ if(coord == nullptr) {
+ writer->write("EMPTY");
+ }
+ else {
+ appendCoordinate(coord, writer);
+ }
}
writer->write(")");
}
diff --git a/tests/unit/io/WKTWriterTest.cpp b/tests/unit/io/WKTWriterTest.cpp
index 9b88cf4..fc26b25 100644
--- a/tests/unit/io/WKTWriterTest.cpp
+++ b/tests/unit/io/WKTWriterTest.cpp
@@ -9,6 +9,8 @@
#include <geos/geom/PrecisionModel.h>
#include <geos/geom/GeometryFactory.h>
#include <geos/geom/Geometry.h>
+#include <geos/geom/Coordinate.h>
+#include <geos/geom/Point.h>
// std
#include <sstream>
#include <string>
@@ -23,6 +25,8 @@ namespace tut {
struct test_wktwriter_data {
typedef geos::geom::PrecisionModel PrecisionModel;
typedef geos::geom::GeometryFactory GeometryFactory;
+ typedef geos::geom::Geometry Geometry;
+ typedef geos::geom::GeometryCollection GeometryCollection;
typedef geos::io::WKTReader WKTReader;
typedef geos::io::WKTWriter WKTWriter;
typedef std::unique_ptr<geos::geom::Geometry> GeomPtr;
@@ -149,5 +153,32 @@ void object::test<5>
ensure_equals(result, std::string("POINT (123000 654000)"));
}
+
+// 6 - Test writing out a multipoint with an empty member
+template<>
+template<>
+void object::test<6>
+()
+{
+ PrecisionModel pm_e(1000);
+ GeometryFactory::Ptr gf_e(GeometryFactory::create(&pm_e, 0));
+
+ std::unique_ptr<geos::geom::Point> empty_pt(gf_e->createPoint());
+ ensure(empty_pt != nullptr);
+
+ geos::geom::Coordinate coord(1, 2);
+ std::unique_ptr<Geometry> point(gf_e->createPoint(coord));
+ ensure(point != nullptr);
+
+ std::vector<const geos::geom::Geometry*> geoms{empty_pt.get(), point.get()};
+
+ std::unique_ptr<geos::geom::Geometry> col(gf_e->createMultiPoint(geoms));
+
+ wktwriter.setRoundingPrecision(2);
+ wktwriter.setTrim(true);
+ std::string result = wktwriter.write(col.get());
+ ensure_equals(result, std::string("MULTIPOINT (EMPTY, 1 2)"));
+}
+
} // namespace tut
-----------------------------------------------------------------------
Summary of changes:
NEWS | 1 +
src/io/WKTWriter.cpp | 12 ++++++++----
tests/unit/io/WKTWriterTest.cpp | 31 +++++++++++++++++++++++++++++++
3 files changed, 40 insertions(+), 4 deletions(-)
hooks/post-receive
--
GEOS
More information about the geos-commits
mailing list