From e2af6b9d048ab8b5c2c0fc41d87941f371422521 Mon Sep 17 00:00:00 2001 From: Julien Enselme Date: Thu, 20 Apr 2017 10:19:13 +0200 Subject: [PATCH] Rename the is3D option for WFS transaction into hasZ This is more consistent with existing code. --- externs/olx.js | 4 ++-- src/ol/format/gml2.js | 30 ++++++++++++++--------------- src/ol/format/gml3.js | 34 ++++++++++++++++----------------- src/ol/format/wfs.js | 6 +++--- test/spec/ol/format/wfs.test.js | 4 ++-- 5 files changed, 39 insertions(+), 39 deletions(-) diff --git a/externs/olx.js b/externs/olx.js index 0510ba77a5..31fcfd67cc 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -2299,7 +2299,7 @@ olx.format.WFSWriteGetFeatureOptions.prototype.resultType; * featureType: string, * srsName: (string|undefined), * handle: (string|undefined), - * is3D: (boolean|undefined), + * hasZ: (boolean|undefined), * nativeElements: Array., * gmlOptions: (olx.format.GMLOptions|undefined), * version: (string|undefined)}} @@ -2354,7 +2354,7 @@ olx.format.WFSWriteTransactionOptions.prototype.handle; * @type {boolean|undefined} * @api */ -olx.format.WFSWriteTransactionOptions.prototype.is3D; +olx.format.WFSWriteTransactionOptions.prototype.hasZ; /** diff --git a/src/ol/format/gml2.js b/src/ol/format/gml2.js index f90f07b016..34cbc6f5cc 100644 --- a/src/ol/format/gml2.js +++ b/src/ol/format/gml2.js @@ -352,7 +352,7 @@ ol.format.GML2.prototype.createCoordinatesNode_ = function(namespaceURI) { */ ol.format.GML2.prototype.writeCoordinates_ = function(node, value, objectStack) { var context = objectStack[objectStack.length - 1]; - var is3D = context['is3D']; + var hasZ = context['hasZ']; var srsName = context['srsName']; // only 2d for simple features profile var points = value.getCoordinates(); @@ -361,7 +361,7 @@ ol.format.GML2.prototype.writeCoordinates_ = function(node, value, objectStack) var point; for (var i = 0; i < len; ++i) { point = points[i]; - parts[i] = this.getCoords_(point, srsName, is3D); + parts[i] = this.getCoords_(point, srsName, hasZ); } ol.format.XSD.writeStringTextNode(node, parts.join(' ')); }; @@ -389,7 +389,7 @@ ol.format.GML2.prototype.writeCurveSegments_ = function(node, line, objectStack) */ ol.format.GML2.prototype.writeSurfaceOrPolygon_ = function(node, geometry, objectStack) { var context = objectStack[objectStack.length - 1]; - var is3D = context['is3D']; + var hasZ = context['hasZ']; var srsName = context['srsName']; if (node.nodeName !== 'PolygonPatch' && srsName) { node.setAttribute('srsName', srsName); @@ -397,7 +397,7 @@ ol.format.GML2.prototype.writeSurfaceOrPolygon_ = function(node, geometry, objec if (node.nodeName === 'Polygon' || node.nodeName === 'PolygonPatch') { var rings = geometry.getLinearRings(); ol.xml.pushSerializeAndPop( - {node: node, is3D: is3D, srsName: srsName}, + {node: node, hasZ: hasZ, srsName: srsName}, ol.format.GML2.RING_SERIALIZERS_, this.RING_NODE_FACTORY_, rings, objectStack, undefined, this); @@ -458,11 +458,11 @@ ol.format.GML2.prototype.writeRing_ = function(node, ring, objectStack) { /** * @param {Array.} point Point geometry. * @param {string=} opt_srsName Optional srsName - * @param {boolean=} opt_is3D whether the geometry is 3D or not. + * @param {boolean=} opt_hasZ whether the geometry has a Z coordinate (is 3D) or not. * @return {string} The coords string. * @private */ -ol.format.GML2.prototype.getCoords_ = function(point, opt_srsName, opt_is3D) { +ol.format.GML2.prototype.getCoords_ = function(point, opt_srsName, opt_hasZ) { var axisOrientation = 'enu'; if (opt_srsName) { axisOrientation = ol.proj.get(opt_srsName).getAxisOrientation(); @@ -470,7 +470,7 @@ ol.format.GML2.prototype.getCoords_ = function(point, opt_srsName, opt_is3D) { var coords = ((axisOrientation.substr(0, 2) === 'en') ? point[0] + ',' + point[1] : point[1] + ',' + point[0]); - if (opt_is3D) { + if (opt_hasZ) { // For newly created points, Z can be undefined. var z = point[2] || 0; coords += ',' + z; @@ -488,14 +488,14 @@ ol.format.GML2.prototype.getCoords_ = function(point, opt_srsName, opt_is3D) { */ ol.format.GML2.prototype.writeMultiCurveOrLineString_ = function(node, geometry, objectStack) { var context = objectStack[objectStack.length - 1]; - var is3D = context['is3D']; + var hasZ = context['hasZ']; var srsName = context['srsName']; var curve = context['curve']; if (srsName) { node.setAttribute('srsName', srsName); } var lines = geometry.getLineStrings(); - ol.xml.pushSerializeAndPop({node: node, is3D: is3D, srsName: srsName, curve: curve}, + ol.xml.pushSerializeAndPop({node: node, hasZ: hasZ, srsName: srsName, curve: curve}, ol.format.GML2.LINESTRINGORCURVEMEMBER_SERIALIZERS_, this.MULTIGEOMETRY_MEMBER_NODE_FACTORY_, lines, objectStack, undefined, this); @@ -510,7 +510,7 @@ ol.format.GML2.prototype.writeMultiCurveOrLineString_ = function(node, geometry, */ ol.format.GML2.prototype.writePoint_ = function(node, geometry, objectStack) { var context = objectStack[objectStack.length - 1]; - var is3D = context['is3D']; + var hasZ = context['hasZ']; var srsName = context['srsName']; if (srsName) { node.setAttribute('srsName', srsName); @@ -518,7 +518,7 @@ ol.format.GML2.prototype.writePoint_ = function(node, geometry, objectStack) { var coordinates = this.createCoordinatesNode_(node.namespaceURI); node.appendChild(coordinates); var point = geometry.getCoordinates(); - var coord = this.getCoords_(point, srsName, is3D); + var coord = this.getCoords_(point, srsName, hasZ); ol.format.XSD.writeStringTextNode(coordinates, coord); }; @@ -532,13 +532,13 @@ ol.format.GML2.prototype.writePoint_ = function(node, geometry, objectStack) { ol.format.GML2.prototype.writeMultiPoint_ = function(node, geometry, objectStack) { var context = objectStack[objectStack.length - 1]; - var is3D = context['is3D']; + var hasZ = context['hasZ']; var srsName = context['srsName']; if (srsName) { node.setAttribute('srsName', srsName); } var points = geometry.getPoints(); - ol.xml.pushSerializeAndPop({node: node, is3D: is3D, srsName: srsName}, + ol.xml.pushSerializeAndPop({node: node, hasZ: hasZ, srsName: srsName}, ol.format.GML2.POINTMEMBER_SERIALIZERS_, ol.xml.makeSimpleNodeFactory('pointMember'), points, objectStack, undefined, this); @@ -599,14 +599,14 @@ ol.format.GML2.prototype.writeLinearRing_ = function(node, geometry, objectStack */ ol.format.GML2.prototype.writeMultiSurfaceOrPolygon_ = function(node, geometry, objectStack) { var context = objectStack[objectStack.length - 1]; - var is3D = context['is3D']; + var hasZ = context['hasZ']; var srsName = context['srsName']; var surface = context['surface']; if (srsName) { node.setAttribute('srsName', srsName); } var polygons = geometry.getPolygons(); - ol.xml.pushSerializeAndPop({node: node, is3D: is3D, srsName: srsName, surface: surface}, + ol.xml.pushSerializeAndPop({node: node, hasZ: hasZ, srsName: srsName, surface: surface}, ol.format.GML2.SURFACEORPOLYGONMEMBER_SERIALIZERS_, this.MULTIGEOMETRY_MEMBER_NODE_FACTORY_, polygons, objectStack, undefined, this); diff --git a/src/ol/format/gml3.js b/src/ol/format/gml3.js index 2e77ea67b7..429c7b0a12 100644 --- a/src/ol/format/gml3.js +++ b/src/ol/format/gml3.js @@ -565,7 +565,7 @@ ol.format.GML3.prototype.SEGMENTS_PARSERS_ = { */ ol.format.GML3.prototype.writePos_ = function(node, value, objectStack) { var context = objectStack[objectStack.length - 1]; - var is3D = context['is3D']; + var hasZ = context['hasZ']; var srsName = context['srsName']; var axisOrientation = 'enu'; if (srsName) { @@ -579,7 +579,7 @@ ol.format.GML3.prototype.writePos_ = function(node, value, objectStack) { } else { coords = (point[1] + ' ' + point[0]); } - if (is3D) { + if (hasZ) { // For newly created points, Z can be undefined. var z = point[2] || 0; coords += ' ' + z; @@ -591,11 +591,11 @@ ol.format.GML3.prototype.writePos_ = function(node, value, objectStack) { /** * @param {Array.} point Point geometry. * @param {string=} opt_srsName Optional srsName - * @param {boolean=} opt_is3D whether the geometry is 3D or not. + * @param {boolean=} opt_hasZ whether the geometry has a Z coordinate (is 3D) or not. * @return {string} The coords string. * @private */ -ol.format.GML3.prototype.getCoords_ = function(point, opt_srsName, opt_is3D) { +ol.format.GML3.prototype.getCoords_ = function(point, opt_srsName, opt_hasZ) { var axisOrientation = 'enu'; if (opt_srsName) { axisOrientation = ol.proj.get(opt_srsName).getAxisOrientation(); @@ -603,7 +603,7 @@ ol.format.GML3.prototype.getCoords_ = function(point, opt_srsName, opt_is3D) { var coords = ((axisOrientation.substr(0, 2) === 'en') ? point[0] + ' ' + point[1] : point[1] + ' ' + point[0]); - if (opt_is3D) { + if (opt_hasZ) { // For newly created points, Z can be undefined. var z = point[2] || 0; coords += ' ' + z; @@ -621,7 +621,7 @@ ol.format.GML3.prototype.getCoords_ = function(point, opt_srsName, opt_is3D) { */ ol.format.GML3.prototype.writePosList_ = function(node, value, objectStack) { var context = objectStack[objectStack.length - 1]; - var is3D = context['is3D']; + var hasZ = context['hasZ']; var srsName = context['srsName']; // only 2d for simple features profile var points = value.getCoordinates(); @@ -630,7 +630,7 @@ ol.format.GML3.prototype.writePosList_ = function(node, value, objectStack) { var point; for (var i = 0; i < len; ++i) { point = points[i]; - parts[i] = this.getCoords_(point, srsName, is3D); + parts[i] = this.getCoords_(point, srsName, hasZ); } ol.format.XSD.writeStringTextNode(node, parts.join(' ')); }; @@ -732,7 +732,7 @@ ol.format.GML3.prototype.RING_NODE_FACTORY_ = function(value, objectStack, opt_n */ ol.format.GML3.prototype.writeSurfaceOrPolygon_ = function(node, geometry, objectStack) { var context = objectStack[objectStack.length - 1]; - var is3D = context['is3D']; + var hasZ = context['hasZ']; var srsName = context['srsName']; if (node.nodeName !== 'PolygonPatch' && srsName) { node.setAttribute('srsName', srsName); @@ -740,7 +740,7 @@ ol.format.GML3.prototype.writeSurfaceOrPolygon_ = function(node, geometry, objec if (node.nodeName === 'Polygon' || node.nodeName === 'PolygonPatch') { var rings = geometry.getLinearRings(); ol.xml.pushSerializeAndPop( - {node: node, is3D: is3D, srsName: srsName}, + {node: node, hasZ: hasZ, srsName: srsName}, ol.format.GML3.RING_SERIALIZERS_, this.RING_NODE_FACTORY_, rings, objectStack, undefined, this); @@ -787,14 +787,14 @@ ol.format.GML3.prototype.writeCurveOrLineString_ = function(node, geometry, obje */ ol.format.GML3.prototype.writeMultiSurfaceOrPolygon_ = function(node, geometry, objectStack) { var context = objectStack[objectStack.length - 1]; - var is3D = context['is3D']; + var hasZ = context['hasZ']; var srsName = context['srsName']; var surface = context['surface']; if (srsName) { node.setAttribute('srsName', srsName); } var polygons = geometry.getPolygons(); - ol.xml.pushSerializeAndPop({node: node, is3D: is3D, srsName: srsName, surface: surface}, + ol.xml.pushSerializeAndPop({node: node, hasZ: hasZ, srsName: srsName, surface: surface}, ol.format.GML3.SURFACEORPOLYGONMEMBER_SERIALIZERS_, this.MULTIGEOMETRY_MEMBER_NODE_FACTORY_, polygons, objectStack, undefined, this); @@ -811,12 +811,12 @@ ol.format.GML3.prototype.writeMultiPoint_ = function(node, geometry, objectStack) { var context = objectStack[objectStack.length - 1]; var srsName = context['srsName']; - var is3D = context['is3D']; + var hasZ = context['hasZ']; if (srsName) { node.setAttribute('srsName', srsName); } var points = geometry.getPoints(); - ol.xml.pushSerializeAndPop({node: node, is3D: is3D, srsName: srsName}, + ol.xml.pushSerializeAndPop({node: node, hasZ: hasZ, srsName: srsName}, ol.format.GML3.POINTMEMBER_SERIALIZERS_, ol.xml.makeSimpleNodeFactory('pointMember'), points, objectStack, undefined, this); @@ -831,14 +831,14 @@ ol.format.GML3.prototype.writeMultiPoint_ = function(node, geometry, */ ol.format.GML3.prototype.writeMultiCurveOrLineString_ = function(node, geometry, objectStack) { var context = objectStack[objectStack.length - 1]; - var is3D = context['is3D']; + var hasZ = context['hasZ']; var srsName = context['srsName']; var curve = context['curve']; if (srsName) { node.setAttribute('srsName', srsName); } var lines = geometry.getLineStrings(); - ol.xml.pushSerializeAndPop({node: node, is3D: is3D, srsName: srsName, curve: curve}, + ol.xml.pushSerializeAndPop({node: node, hasZ: hasZ, srsName: srsName, curve: curve}, ol.format.GML3.LINESTRINGORCURVEMEMBER_SERIALIZERS_, this.MULTIGEOMETRY_MEMBER_NODE_FACTORY_, lines, objectStack, undefined, this); @@ -1187,7 +1187,7 @@ ol.format.GML3.prototype.GEOMETRY_NODE_FACTORY_ = function(value, objectStack, o ol.format.GML3.prototype.writeGeometryNode = function(geometry, opt_options) { opt_options = this.adaptOptions(opt_options); var geom = ol.xml.createElementNS('http://www.opengis.net/gml', 'geom'); - var context = {node: geom, is3D: this.is3D, srsName: this.srsName, + var context = {node: geom, hasZ: this.hasZ, srsName: this.srsName, curve: this.curve_, surface: this.surface_, multiSurface: this.multiSurface_, multiCurve: this.multiCurve_}; if (opt_options) { @@ -1227,7 +1227,7 @@ ol.format.GML3.prototype.writeFeaturesNode = function(features, opt_options) { 'xsi:schemaLocation', this.schemaLocation); var context = { srsName: this.srsName, - is3D: this.is3D, + hasZ: this.hasZ, curve: this.curve_, surface: this.surface_, multiSurface: this.multiSurface_, diff --git a/src/ol/format/wfs.js b/src/ol/format/wfs.js index d666940b1a..9f3780dab0 100644 --- a/src/ol/format/wfs.js +++ b/src/ol/format/wfs.js @@ -469,7 +469,7 @@ ol.format.WFS.writeUpdate_ = function(node, feature, objectStack) { } ol.xml.pushSerializeAndPop(/** @type {ol.XmlNodeStackItem} */ ( {'gmlVersion': context['gmlVersion'], node: node, - 'is3D': context['is3D'], 'srsName': context['srsName']}), + 'hasZ': context['hasZ'], 'srsName': context['srsName']}), ol.format.WFS.TRANSACTION_SERIALIZERS_, ol.xml.makeSimpleNodeFactory('Property'), values, objectStack); @@ -934,7 +934,7 @@ ol.format.WFS.prototype.writeTransaction = function(inserts, updates, deletes, if (inserts) { obj = {node: node, 'featureNS': options.featureNS, 'featureType': options.featureType, 'featurePrefix': options.featurePrefix, - 'gmlVersion': gmlVersion, 'is3D': options.is3D, 'srsName': options.srsName}; + 'gmlVersion': gmlVersion, 'hasZ': options.hasZ, 'srsName': options.srsName}; ol.obj.assign(obj, baseObj); ol.xml.pushSerializeAndPop(obj, ol.format.WFS.TRANSACTION_SERIALIZERS_, @@ -944,7 +944,7 @@ ol.format.WFS.prototype.writeTransaction = function(inserts, updates, deletes, if (updates) { obj = {node: node, 'featureNS': options.featureNS, 'featureType': options.featureType, 'featurePrefix': options.featurePrefix, - 'gmlVersion': gmlVersion, 'is3D': options.is3D, 'srsName': options.srsName}; + 'gmlVersion': gmlVersion, 'hasZ': options.hasZ, 'srsName': options.srsName}; ol.obj.assign(obj, baseObj); ol.xml.pushSerializeAndPop(obj, ol.format.WFS.TRANSACTION_SERIALIZERS_, diff --git a/test/spec/ol/format/wfs.test.js b/test/spec/ol/format/wfs.test.js index 5c2f15f45f..e9d85a2bc6 100644 --- a/test/spec/ol/format/wfs.test.js +++ b/test/spec/ol/format/wfs.test.js @@ -914,7 +914,7 @@ describe('ol.format.WFS', function() { featureNS: 'http://www.openplans.org/topp', featureType: 'states', featurePrefix: 'topp', - is3D: true, + hasZ: true, version: '1.0.0' }); @@ -954,7 +954,7 @@ describe('ol.format.WFS', function() { var serialized = format.writeTransaction(inserts, updates, null, { featureNS: 'http://www.openplans.org/topp', featureType: 'states', - is3D: true, + hasZ: true, featurePrefix: 'topp' }); expect(serialized).to.xmleql(ol.xml.parse(text));