Treat WKT EMPTY geometries properly

Empty points have NaN as each coordinate, other geometry types have
empty arrays.
This commit is contained in:
ahocevar
2018-07-07 14:48:06 +02:00
parent 1da43d90af
commit da0838dde2

View File

@@ -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_);
}
}