From fe8a72dce5b673e0f54bac7923c34679014396aa Mon Sep 17 00:00:00 2001 From: Erik Timmers Date: Tue, 15 Jul 2014 12:59:26 +0200 Subject: [PATCH] Allow for empty Point & GeometryCollection --- src/ol/format/wktformat.js | 8 +++++--- src/ol/geom/point.js | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/ol/format/wktformat.js b/src/ol/format/wktformat.js index ceea6de969..1017c2d1cf 100644 --- a/src/ol/format/wktformat.js +++ b/src/ol/format/wktformat.js @@ -585,13 +585,15 @@ ol.format.WKT.Parser.prototype.parseGeometryCollectionText_ = function() { if (this.match(ol.format.WKT.TokenType.RIGHT_PAREN)) { return geometries; } + } else if (this.isEmptyGeometry_()) { + return []; } this.raiseError_(); }; /** - * @return {!Array.} All values in a point. + * @return {Array.} All values in a point. * @private */ ol.format.WKT.Parser.prototype.parsePointText_ = function() { @@ -601,7 +603,7 @@ ol.format.WKT.Parser.prototype.parsePointText_ = function() { return coordinates; } } else if (this.isEmptyGeometry_()) { - return []; + return null; } this.raiseError_(); }; @@ -810,7 +812,7 @@ ol.format.WKT.Parser.GeometryConstructor_ = { /** - * @enum {(function(): !Array)} + * @enum {(function(): Array)} * @private */ ol.format.WKT.Parser.GeometryParser_ = { diff --git a/src/ol/geom/point.js b/src/ol/geom/point.js index acf7b089f4..c37d4a4518 100644 --- a/src/ol/geom/point.js +++ b/src/ol/geom/point.js @@ -65,7 +65,7 @@ ol.geom.Point.prototype.closestPointXY = * @api */ ol.geom.Point.prototype.getCoordinates = function() { - return this.flatCoordinates.slice(); + return goog.isNull(this.flatCoordinates) ? [] : this.flatCoordinates.slice(); };