From 4955097a523fa9e1bee696ef162173fb3d165def Mon Sep 17 00:00:00 2001 From: Julien Enselme Date: Fri, 7 Apr 2017 10:58:57 +0200 Subject: [PATCH] Prevent Z to be undefined in 3D WFS transactions For newly created points, Z can be undefined. In these cases, we use 0 for Z. --- src/ol/format/gml2.js | 4 +++- src/ol/format/gml3.js | 8 ++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/ol/format/gml2.js b/src/ol/format/gml2.js index 134e208353..f90f07b016 100644 --- a/src/ol/format/gml2.js +++ b/src/ol/format/gml2.js @@ -471,7 +471,9 @@ ol.format.GML2.prototype.getCoords_ = function(point, opt_srsName, opt_is3D) { point[0] + ',' + point[1] : point[1] + ',' + point[0]); if (opt_is3D) { - coords += ',' + point[2]; + // For newly created points, Z can be undefined. + var z = point[2] || 0; + coords += ',' + z; } return coords; diff --git a/src/ol/format/gml3.js b/src/ol/format/gml3.js index be9a256d23..2e77ea67b7 100644 --- a/src/ol/format/gml3.js +++ b/src/ol/format/gml3.js @@ -580,7 +580,9 @@ ol.format.GML3.prototype.writePos_ = function(node, value, objectStack) { coords = (point[1] + ' ' + point[0]); } if (is3D) { - coords += ' ' + point[2]; + // For newly created points, Z can be undefined. + var z = point[2] || 0; + coords += ' ' + z; } ol.format.XSD.writeStringTextNode(node, coords); }; @@ -602,7 +604,9 @@ ol.format.GML3.prototype.getCoords_ = function(point, opt_srsName, opt_is3D) { point[0] + ' ' + point[1] : point[1] + ' ' + point[0]); if (opt_is3D) { - coords += ' ' + point[2]; + // For newly created points, Z can be undefined. + var z = point[2] || 0; + coords += ' ' + z; } return coords;