Allow for empty Point & GeometryCollection

This commit is contained in:
Erik Timmers
2014-07-15 12:59:26 +02:00
parent 4c03b3b35c
commit fe8a72dce5
2 changed files with 6 additions and 4 deletions
+5 -3
View File
@@ -585,13 +585,15 @@ ol.format.WKT.Parser.prototype.parseGeometryCollectionText_ = function() {
if (this.match(ol.format.WKT.TokenType.RIGHT_PAREN)) { if (this.match(ol.format.WKT.TokenType.RIGHT_PAREN)) {
return geometries; return geometries;
} }
} else if (this.isEmptyGeometry_()) {
return [];
} }
this.raiseError_(); this.raiseError_();
}; };
/** /**
* @return {!Array.<number>} All values in a point. * @return {Array.<number>} All values in a point.
* @private * @private
*/ */
ol.format.WKT.Parser.prototype.parsePointText_ = function() { ol.format.WKT.Parser.prototype.parsePointText_ = function() {
@@ -601,7 +603,7 @@ ol.format.WKT.Parser.prototype.parsePointText_ = function() {
return coordinates; return coordinates;
} }
} else if (this.isEmptyGeometry_()) { } else if (this.isEmptyGeometry_()) {
return []; return null;
} }
this.raiseError_(); this.raiseError_();
}; };
@@ -810,7 +812,7 @@ ol.format.WKT.Parser.GeometryConstructor_ = {
/** /**
* @enum {(function(): !Array)} * @enum {(function(): Array)}
* @private * @private
*/ */
ol.format.WKT.Parser.GeometryParser_ = { ol.format.WKT.Parser.GeometryParser_ = {
+1 -1
View File
@@ -65,7 +65,7 @@ ol.geom.Point.prototype.closestPointXY =
* @api * @api
*/ */
ol.geom.Point.prototype.getCoordinates = function() { ol.geom.Point.prototype.getCoordinates = function() {
return this.flatCoordinates.slice(); return goog.isNull(this.flatCoordinates) ? [] : this.flatCoordinates.slice();
}; };