From da0838dde2de401274b4e5d38c6f000cb6d4cf11 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Sat, 7 Jul 2018 14:48:06 +0200 Subject: [PATCH] Treat WKT EMPTY geometries properly Empty points have NaN as each coordinate, other geometry types have empty arrays. --- src/ol/format/WKT.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/ol/format/WKT.js b/src/ol/format/WKT.js index be01fc0174..fb3f33fc8f 100644 --- a/src/ol/format/WKT.js +++ b/src/ol/format/WKT.js @@ -858,7 +858,14 @@ Parser.prototype.parseGeometry_ = function() { if (!parser || !ctor) { throw new Error('Invalid geometry type: ' + geomType); } - const coordinates = parser.call(this); + let coordinates = parser.call(this); + if (!coordinates) { + if (ctor === GeometryConstructor[GeometryType.POINT]) { + coordinates = [NaN, NaN]; + } else { + coordinates = []; + } + } return new ctor(coordinates, this.layout_); } }