[geos-commits] [SCM] GEOS branch master updated. a73568cc5c06fad4711b049a132c5f115182b357
git at osgeo.org
git at osgeo.org
Mon Apr 20 11:18:59 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, master has been updated
via a73568cc5c06fad4711b049a132c5f115182b357 (commit)
from a5e8b64efc516c2592016235443dac166034fe7f (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 a73568cc5c06fad4711b049a132c5f115182b357
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)
diff --git a/src/io/WKTWriter.cpp b/src/io/WKTWriter.cpp
index 977618c..5ce1c93 100644
--- a/src/io/WKTWriter.cpp
+++ b/src/io/WKTWriter.cpp
@@ -426,11 +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(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..db9d97d 100644
--- a/tests/unit/io/WKTWriterTest.cpp
+++ b/tests/unit/io/WKTWriterTest.cpp
@@ -9,6 +9,7 @@
#include <geos/geom/PrecisionModel.h>
#include <geos/geom/GeometryFactory.h>
#include <geos/geom/Geometry.h>
+#include <geos/geom/GeometryCollection.h>
// std
#include <sstream>
#include <string>
@@ -23,6 +24,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 +152,35 @@ 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 pm3(PrecisionModel::FLOATING);
+ GeometryFactory::Ptr gf3(GeometryFactory::create(&pm3));
+ std::unique_ptr<Geometry> empty_point(gf3->createPoint());
+ ensure(empty_point != nullptr);
+
+ geos::geom::Coordinate coord(1, 2);
+ std::unique_ptr<Geometry> point(gf3->createPoint(coord));
+ ensure(point != nullptr);
+
+ std::vector<const Geometry*> geoms{empty_point.get(), point.get()};
+ std::unique_ptr<Geometry> col(gf3->createMultiPoint(geoms));
+ ensure(col != nullptr);
+
+ ensure(col->getCoordinate() != nullptr);
+ ensure_equals(col->getCoordinate()->x, 1);
+ ensure_equals(col->getCoordinate()->y, 2);
+
+ 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:
src/io/WKTWriter.cpp | 10 ++++++++--
tests/unit/io/WKTWriterTest.cpp | 33 +++++++++++++++++++++++++++++++++
2 files changed, 41 insertions(+), 2 deletions(-)
hooks/post-receive
--
GEOS
More information about the geos-commits
mailing list