diff --git a/externs/olx.js b/externs/olx.js index eb9455d462..8c9a601d71 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -1649,7 +1649,7 @@ olx.format.WFSWriteGetFeatureOptions.prototype.geometryName; /** * GML format to use within the WFS format. - * @type {ol.format.GML|undefined} + * @type {ol.format.GMLBase|undefined} * @api */ olx.format.WFSWriteGetFeatureOptions.prototype.gmlFormat; diff --git a/src/ol/format/gml/base.js b/src/ol/format/gml/base.js index d8df504013..594cd9c424 100644 --- a/src/ol/format/gml/base.js +++ b/src/ol/format/gml/base.js @@ -1,7 +1,7 @@ // FIXME Envelopes should not be treated as geometries! readEnvelope_ is part // of GEOMETRY_PARSERS_ and methods using GEOMETRY_PARSERS_ do not expect // envelopes/extents, only geometries! -goog.provide('ol.format.GML'); +goog.provide('ol.format.GMLBase'); goog.require('goog.asserts'); goog.require('goog.dom'); @@ -34,9 +34,9 @@ goog.require('ol.xml'); * @param {olx.format.GMLOptions=} opt_options * Optional configuration object. * @extends {ol.format.XMLFeature} - * @api stable + * @api */ -ol.format.GML = function(opt_options) { +ol.format.GMLBase = function(opt_options) { var options = /** @type {olx.format.GMLOptions} */ (goog.isDef(opt_options) ? opt_options : {}); @@ -67,7 +67,7 @@ ol.format.GML = function(opt_options) { goog.base(this); }; -goog.inherits(ol.format.GML, ol.format.XMLFeature); +goog.inherits(ol.format.GMLBase, ol.format.XMLFeature); /** @@ -76,13 +76,13 @@ goog.inherits(ol.format.GML, ol.format.XMLFeature); * @return {Array.} Features. * @private */ -ol.format.GML.prototype.readFeatures_ = function(node, objectStack) { +ol.format.GMLBase.prototype.readFeatures_ = function(node, objectStack) { goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); var localName = ol.xml.getLocalName(node); var features; if (localName == 'FeatureCollection') { features = ol.xml.pushParseAndPop(null, - ol.format.GML.FEATURE_COLLECTION_PARSERS, node, + ol.format.GMLBase.FEATURE_COLLECTION_PARSERS, node, objectStack, this); } else if (localName == 'featureMembers' || localName == 'featureMember') { var context = objectStack[0]; @@ -112,11 +112,12 @@ ol.format.GML.prototype.readFeatures_ = function(node, objectStack) { /** * @type {Object.>} */ -ol.format.GML.FEATURE_COLLECTION_PARSERS = { +ol.format.GMLBase.FEATURE_COLLECTION_PARSERS = { 'http://www.opengis.net/gml': { 'featureMember': ol.xml.makeArrayPusher( - ol.format.GML.prototype.readFeatures_), - 'featureMembers': ol.xml.makeReplacer(ol.format.GML.prototype.readFeatures_) + ol.format.GMLBase.prototype.readFeatures_), + 'featureMembers': ol.xml.makeReplacer( + ol.format.GMLBase.prototype.readFeatures_) } }; @@ -126,7 +127,7 @@ ol.format.GML.FEATURE_COLLECTION_PARSERS = { * @param {Array.<*>} objectStack Object stack. * @return {ol.geom.Geometry|undefined} Geometry. */ -ol.format.GML.prototype.readGeometryElement = function(node, objectStack) { +ol.format.GMLBase.prototype.readGeometryElement = function(node, objectStack) { var context = objectStack[0]; goog.asserts.assert(goog.isObject(context)); goog.object.set(context, 'srsName', @@ -148,7 +149,7 @@ ol.format.GML.prototype.readGeometryElement = function(node, objectStack) { * @return {ol.Feature} Feature. * @private */ -ol.format.GML.prototype.readFeature_ = function(node, objectStack) { +ol.format.GMLBase.prototype.readFeature_ = function(node, objectStack) { var n; var fid = node.getAttribute('fid') || ol.xml.getAttributeNS(node, 'http://www.opengis.net/gml', 'id'); @@ -186,7 +187,7 @@ ol.format.GML.prototype.readFeature_ = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @return {ol.geom.Point|undefined} Point. */ -ol.format.GML.prototype.readPoint = function(node, objectStack) { +ol.format.GMLBase.prototype.readPoint = function(node, objectStack) { goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); goog.asserts.assert(node.localName == 'Point'); var flatCoordinates = @@ -205,12 +206,12 @@ ol.format.GML.prototype.readPoint = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @return {ol.geom.MultiPoint|undefined} MultiPoint. */ -ol.format.GML.prototype.readMultiPoint = function(node, objectStack) { +ol.format.GMLBase.prototype.readMultiPoint = function(node, objectStack) { goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); goog.asserts.assert(node.localName == 'MultiPoint'); var coordinates = ol.xml.pushParseAndPop( /** @type {Array.>} */ ([]), - ol.format.GML.MULTIPOINT_PARSERS_, node, objectStack, this); + ol.format.GMLBase.MULTIPOINT_PARSERS_, node, objectStack, this); if (goog.isDef(coordinates)) { return new ol.geom.MultiPoint(coordinates); } else { @@ -224,12 +225,12 @@ ol.format.GML.prototype.readMultiPoint = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @return {ol.geom.MultiLineString|undefined} MultiLineString. */ -ol.format.GML.prototype.readMultiLineString = function(node, objectStack) { +ol.format.GMLBase.prototype.readMultiLineString = function(node, objectStack) { goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); goog.asserts.assert(node.localName == 'MultiLineString'); var lineStrings = ol.xml.pushParseAndPop( /** @type {Array.} */ ([]), - ol.format.GML.MULTILINESTRING_PARSERS_, node, objectStack, this); + ol.format.GMLBase.MULTILINESTRING_PARSERS_, node, objectStack, this); if (goog.isDef(lineStrings)) { var multiLineString = new ol.geom.MultiLineString(null); multiLineString.setLineStrings(lineStrings); @@ -245,12 +246,12 @@ ol.format.GML.prototype.readMultiLineString = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @return {ol.geom.MultiPolygon|undefined} MultiPolygon. */ -ol.format.GML.prototype.readMultiPolygon = function(node, objectStack) { +ol.format.GMLBase.prototype.readMultiPolygon = function(node, objectStack) { goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); goog.asserts.assert(node.localName == 'MultiPolygon'); var polygons = ol.xml.pushParseAndPop( /** @type {Array.} */ ([]), - ol.format.GML.MULTIPOLYGON_PARSERS_, node, objectStack, this); + ol.format.GMLBase.MULTIPOLYGON_PARSERS_, node, objectStack, this); if (goog.isDef(polygons)) { var multiPolygon = new ol.geom.MultiPolygon(null); multiPolygon.setPolygons(polygons); @@ -266,24 +267,11 @@ ol.format.GML.prototype.readMultiPolygon = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @private */ -ol.format.GML.prototype.pointMemberParser_ = function(node, objectStack) { +ol.format.GMLBase.prototype.pointMemberParser_ = function(node, objectStack) { goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); goog.asserts.assert(node.localName == 'pointMember' || node.localName == 'pointMembers'); - ol.xml.parse(ol.format.GML.POINTMEMBER_PARSERS_, node, objectStack, this); -}; - - -/** - * @param {Node} node Node. - * @param {Array.<*>} objectStack Object stack. - * @private - */ -ol.format.GML.prototype.lineStringMemberParser_ = function(node, objectStack) { - goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); - goog.asserts.assert(node.localName == 'lineStringMember' || - node.localName == 'lineStringMembers'); - ol.xml.parse(ol.format.GML.LINESTRINGMEMBER_PARSERS_, + ol.xml.parse(ol.format.GMLBase.POINTMEMBER_PARSERS_, node, objectStack, this); }; @@ -293,11 +281,28 @@ ol.format.GML.prototype.lineStringMemberParser_ = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @private */ -ol.format.GML.prototype.polygonMemberParser_ = function(node, objectStack) { +ol.format.GMLBase.prototype.lineStringMemberParser_ = + function(node, objectStack) { + goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); + goog.asserts.assert(node.localName == 'lineStringMember' || + node.localName == 'lineStringMembers'); + ol.xml.parse(ol.format.GMLBase.LINESTRINGMEMBER_PARSERS_, + node, objectStack, this); +}; + + +/** + * @param {Node} node Node. + * @param {Array.<*>} objectStack Object stack. + * @private + */ +ol.format.GMLBase.prototype.polygonMemberParser_ = + function(node, objectStack) { goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); goog.asserts.assert(node.localName == 'polygonMember' || node.localName == 'polygonMembers'); - ol.xml.parse(ol.format.GML.POLYGONMEMBER_PARSERS_, node, objectStack, this); + ol.xml.parse(ol.format.GMLBase.POLYGONMEMBER_PARSERS_, node, + objectStack, this); }; @@ -306,7 +311,7 @@ ol.format.GML.prototype.polygonMemberParser_ = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @return {ol.geom.LineString|undefined} LineString. */ -ol.format.GML.prototype.readLineString = function(node, objectStack) { +ol.format.GMLBase.prototype.readLineString = function(node, objectStack) { goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); goog.asserts.assert(node.localName == 'LineString'); var flatCoordinates = @@ -327,7 +332,7 @@ ol.format.GML.prototype.readLineString = function(node, objectStack) { * @private * @return {Array.|undefined} LinearRing flat coordinates. */ -ol.format.GML.prototype.readFlatLinearRing_ = function(node, objectStack) { +ol.format.GMLBase.prototype.readFlatLinearRing_ = function(node, objectStack) { goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); goog.asserts.assert(node.localName == 'LinearRing'); var ring = ol.xml.pushParseAndPop(/** @type {Array.} */(null), @@ -346,7 +351,7 @@ ol.format.GML.prototype.readFlatLinearRing_ = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @return {ol.geom.LinearRing|undefined} LinearRing. */ -ol.format.GML.prototype.readLinearRing = function(node, objectStack) { +ol.format.GMLBase.prototype.readLinearRing = function(node, objectStack) { goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); goog.asserts.assert(node.localName == 'LinearRing'); var flatCoordinates = @@ -366,7 +371,7 @@ ol.format.GML.prototype.readLinearRing = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @return {ol.geom.Polygon|undefined} Polygon. */ -ol.format.GML.prototype.readPolygon = function(node, objectStack) { +ol.format.GMLBase.prototype.readPolygon = function(node, objectStack) { goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); goog.asserts.assert(node.localName == 'Polygon'); var flatLinearRings = ol.xml.pushParseAndPop( @@ -397,8 +402,8 @@ ol.format.GML.prototype.readPolygon = function(node, objectStack) { * @private * @return {Array.} Flat coordinates. */ -ol.format.GML.prototype.readFlatCoordinatesFromNode_ = function(node, - objectStack) { +ol.format.GMLBase.prototype.readFlatCoordinatesFromNode_ = + function(node, objectStack) { goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); return /** @type {Array.} */ (ol.xml.pushParseAndPop( null, @@ -412,12 +417,12 @@ ol.format.GML.prototype.readFlatCoordinatesFromNode_ = function(node, * @type {Object.>} * @private */ -ol.format.GML.MULTIPOINT_PARSERS_ = { +ol.format.GMLBase.MULTIPOINT_PARSERS_ = { 'http://www.opengis.net/gml' : { 'pointMember': ol.xml.makeArrayPusher( - ol.format.GML.prototype.pointMemberParser_), + ol.format.GMLBase.prototype.pointMemberParser_), 'pointMembers': ol.xml.makeArrayPusher( - ol.format.GML.prototype.pointMemberParser_) + ol.format.GMLBase.prototype.pointMemberParser_) } }; @@ -427,12 +432,12 @@ ol.format.GML.MULTIPOINT_PARSERS_ = { * @type {Object.>} * @private */ -ol.format.GML.MULTILINESTRING_PARSERS_ = { +ol.format.GMLBase.MULTILINESTRING_PARSERS_ = { 'http://www.opengis.net/gml' : { 'lineStringMember': ol.xml.makeArrayPusher( - ol.format.GML.prototype.lineStringMemberParser_), + ol.format.GMLBase.prototype.lineStringMemberParser_), 'lineStringMembers': ol.xml.makeArrayPusher( - ol.format.GML.prototype.lineStringMemberParser_) + ol.format.GMLBase.prototype.lineStringMemberParser_) } }; @@ -442,12 +447,12 @@ ol.format.GML.MULTILINESTRING_PARSERS_ = { * @type {Object.>} * @private */ -ol.format.GML.MULTIPOLYGON_PARSERS_ = { +ol.format.GMLBase.MULTIPOLYGON_PARSERS_ = { 'http://www.opengis.net/gml' : { 'polygonMember': ol.xml.makeArrayPusher( - ol.format.GML.prototype.polygonMemberParser_), + ol.format.GMLBase.prototype.polygonMemberParser_), 'polygonMembers': ol.xml.makeArrayPusher( - ol.format.GML.prototype.polygonMemberParser_) + ol.format.GMLBase.prototype.polygonMemberParser_) } }; @@ -457,10 +462,10 @@ ol.format.GML.MULTIPOLYGON_PARSERS_ = { * @type {Object.>} * @private */ -ol.format.GML.POINTMEMBER_PARSERS_ = { +ol.format.GMLBase.POINTMEMBER_PARSERS_ = { 'http://www.opengis.net/gml' : { 'Point': ol.xml.makeArrayPusher( - ol.format.GML.prototype.readFlatCoordinatesFromNode_) + ol.format.GMLBase.prototype.readFlatCoordinatesFromNode_) } }; @@ -470,10 +475,10 @@ ol.format.GML.POINTMEMBER_PARSERS_ = { * @type {Object.>} * @private */ -ol.format.GML.LINESTRINGMEMBER_PARSERS_ = { +ol.format.GMLBase.LINESTRINGMEMBER_PARSERS_ = { 'http://www.opengis.net/gml' : { 'LineString': ol.xml.makeArrayPusher( - ol.format.GML.prototype.readLineString) + ol.format.GMLBase.prototype.readLineString) } }; @@ -483,10 +488,10 @@ ol.format.GML.LINESTRINGMEMBER_PARSERS_ = { * @type {Object.>} * @private */ -ol.format.GML.POLYGONMEMBER_PARSERS_ = { +ol.format.GMLBase.POLYGONMEMBER_PARSERS_ = { 'http://www.opengis.net/gml' : { 'Polygon': ol.xml.makeArrayPusher( - ol.format.GML.prototype.readPolygon) + ol.format.GMLBase.prototype.readPolygon) } }; @@ -496,10 +501,10 @@ ol.format.GML.POLYGONMEMBER_PARSERS_ = { * @type {Object.>} * @protected */ -ol.format.GML.RING_PARSERS = { +ol.format.GMLBase.RING_PARSERS = { 'http://www.opengis.net/gml' : { 'LinearRing': ol.xml.makeReplacer( - ol.format.GML.prototype.readFlatLinearRing_) + ol.format.GMLBase.prototype.readFlatLinearRing_) } }; @@ -507,7 +512,8 @@ ol.format.GML.RING_PARSERS = { /** * @inheritDoc */ -ol.format.GML.prototype.readGeometryFromNode = function(node, opt_options) { +ol.format.GMLBase.prototype.readGeometryFromNode = + function(node, opt_options) { var geometry = this.readGeometryElement(node, [this.getReadOptions(node, goog.isDef(opt_options) ? opt_options : {})]); return (goog.isDef(geometry) ? geometry : null); @@ -523,13 +529,14 @@ ol.format.GML.prototype.readGeometryFromNode = function(node, opt_options) { * @return {Array.} Features. * @api stable */ -ol.format.GML.prototype.readFeatures; +ol.format.GMLBase.prototype.readFeatures; /** * @inheritDoc */ -ol.format.GML.prototype.readFeaturesFromNode = function(node, opt_options) { +ol.format.GMLBase.prototype.readFeaturesFromNode = + function(node, opt_options) { var options = { 'featureType': this.featureType, 'featureNS': this.featureNS @@ -544,7 +551,7 @@ ol.format.GML.prototype.readFeaturesFromNode = function(node, opt_options) { /** * @inheritDoc */ -ol.format.GML.prototype.readProjectionFromNode = function(node) { +ol.format.GMLBase.prototype.readProjectionFromNode = function(node) { return ol.proj.get(goog.isDef(this.srsName_) ? this.srsName_ : node.firstElementChild.getAttribute('srsName')); }; diff --git a/src/ol/format/gml/v2.js b/src/ol/format/gml/v2.js index 5d147a25e2..4d676977aa 100644 --- a/src/ol/format/gml/v2.js +++ b/src/ol/format/gml/v2.js @@ -1,10 +1,11 @@ -goog.provide('ol.format.GML.v2'); +goog.provide('ol.format.GML2'); goog.require('goog.asserts'); goog.require('goog.dom'); goog.require('goog.dom.NodeType'); goog.require('goog.object'); goog.require('ol.format.GML'); +goog.require('ol.format.GMLBase'); goog.require('ol.format.XSD'); goog.require('ol.proj'); goog.require('ol.xml'); @@ -19,14 +20,14 @@ goog.require('ol.xml'); * @constructor * @param {olx.format.GMLOptions=} opt_options * Optional configuration object. - * @extends {ol.format.GML} - * @api stable + * @extends {ol.format.GMLBase} + * @api */ -ol.format.GML.v2 = function(opt_options) { +ol.format.GML2 = function(opt_options) { goog.base(this, opt_options); }; -goog.inherits(ol.format.GML.v2, ol.format.GML); +goog.inherits(ol.format.GML2, ol.format.GMLBase); /** @@ -34,7 +35,7 @@ goog.inherits(ol.format.GML.v2, ol.format.GML); * @private * @type {string} */ -ol.format.GML.v2.schemaLocation_ = 'http://www.opengis.net/gml ' + +ol.format.GML2.schemaLocation_ = 'http://www.opengis.net/gml ' + 'http://schemas.opengis.net/gml/2.1.2/feature.xsd'; @@ -44,7 +45,7 @@ ol.format.GML.v2.schemaLocation_ = 'http://www.opengis.net/gml ' + * @private * @return {Array.|undefined} Flat coordinates. */ -ol.format.GML.v2.prototype.readFlatCoordinates_ = function(node, objectStack) { +ol.format.GML2.prototype.readFlatCoordinates_ = function(node, objectStack) { var s = ol.xml.getAllTextContent(node, false).replace(/^\s*|\s*$/g, ''); var context = objectStack[0]; goog.asserts.assert(goog.isObject(context)); @@ -88,13 +89,13 @@ ol.format.GML.v2.prototype.readFlatCoordinates_ = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @private */ -ol.format.GML.v2.prototype.innerBoundaryIsParser_ = +ol.format.GML2.prototype.innerBoundaryIsParser_ = function(node, objectStack) { goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); goog.asserts.assert(node.localName == 'innerBoundaryIs'); var flatLinearRing = ol.xml.pushParseAndPop( /** @type {Array.|undefined} */ (undefined), - ol.format.GML.RING_PARSERS, node, objectStack, this); + ol.format.GMLBase.RING_PARSERS, node, objectStack, this); if (goog.isDef(flatLinearRing)) { var flatLinearRings = /** @type {Array.>} */ (objectStack[objectStack.length - 1]); @@ -110,13 +111,13 @@ ol.format.GML.v2.prototype.innerBoundaryIsParser_ = * @param {Array.<*>} objectStack Object stack. * @private */ -ol.format.GML.v2.prototype.outerBoundaryIsParser_ = +ol.format.GML2.prototype.outerBoundaryIsParser_ = function(node, objectStack) { goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); goog.asserts.assert(node.localName == 'outerBoundaryIs'); var flatLinearRing = ol.xml.pushParseAndPop( /** @type {Array.|undefined} */ (undefined), - ol.format.GML.RING_PARSERS, node, objectStack, this); + ol.format.GMLBase.RING_PARSERS, node, objectStack, this); if (goog.isDef(flatLinearRing)) { var flatLinearRings = /** @type {Array.>} */ (objectStack[objectStack.length - 1]); @@ -132,10 +133,10 @@ ol.format.GML.v2.prototype.outerBoundaryIsParser_ = * @type {Object.>} * @private */ -ol.format.GML.v2.GEOMETRY_FLAT_COORDINATES_PARSERS_ = { +ol.format.GML2.GEOMETRY_FLAT_COORDINATES_PARSERS_ = { 'http://www.opengis.net/gml' : { 'coordinates': ol.xml.makeReplacer( - ol.format.GML.v2.prototype.readFlatCoordinates_) + ol.format.GML2.prototype.readFlatCoordinates_) } }; @@ -145,10 +146,10 @@ ol.format.GML.v2.GEOMETRY_FLAT_COORDINATES_PARSERS_ = { * @type {Object.>} * @private */ -ol.format.GML.v2.FLAT_LINEAR_RINGS_PARSERS_ = { +ol.format.GML2.FLAT_LINEAR_RINGS_PARSERS_ = { 'http://www.opengis.net/gml' : { - 'innerBoundaryIs': ol.format.GML.v2.prototype.innerBoundaryIsParser_, - 'outerBoundaryIs': ol.format.GML.v2.prototype.outerBoundaryIsParser_ + 'innerBoundaryIs': ol.format.GML2.prototype.innerBoundaryIsParser_, + 'outerBoundaryIs': ol.format.GML2.prototype.outerBoundaryIsParser_ } }; @@ -158,17 +159,19 @@ ol.format.GML.v2.FLAT_LINEAR_RINGS_PARSERS_ = { * @type {Object.>} * @private */ -ol.format.GML.v2.GEOMETRY_PARSERS_ = { +ol.format.GML2.GEOMETRY_PARSERS_ = { 'http://www.opengis.net/gml' : { - 'Point': ol.xml.makeReplacer(ol.format.GML.prototype.readPoint), - 'MultiPoint': ol.xml.makeReplacer(ol.format.GML.prototype.readMultiPoint), - 'LineString': ol.xml.makeReplacer(ol.format.GML.prototype.readLineString), + 'Point': ol.xml.makeReplacer(ol.format.GMLBase.prototype.readPoint), + 'MultiPoint': ol.xml.makeReplacer( + ol.format.GMLBase.prototype.readMultiPoint), + 'LineString': ol.xml.makeReplacer( + ol.format.GMLBase.prototype.readLineString), 'MultiLineString': ol.xml.makeReplacer( - ol.format.GML.prototype.readMultiLineString), + ol.format.GMLBase.prototype.readMultiLineString), 'LinearRing' : ol.xml.makeReplacer( - ol.format.GML.prototype.readLinearRing), - 'Polygon': ol.xml.makeReplacer(ol.format.GML.prototype.readPolygon), + ol.format.GMLBase.prototype.readLinearRing), + 'Polygon': ol.xml.makeReplacer(ol.format.GMLBase.prototype.readPolygon), 'MultiPolygon': ol.xml.makeReplacer( - ol.format.GML.prototype.readMultiPolygon) + ol.format.GMLBase.prototype.readMultiPolygon) } }; diff --git a/src/ol/format/gml/v3.js b/src/ol/format/gml/v3.js index 9ca794493d..79534e49cb 100644 --- a/src/ol/format/gml/v3.js +++ b/src/ol/format/gml/v3.js @@ -1,4 +1,5 @@ -goog.provide('ol.format.GML.v3'); +goog.provide('ol.format.GML'); +goog.provide('ol.format.GML3'); goog.require('goog.asserts'); goog.require('goog.dom'); @@ -8,7 +9,7 @@ goog.require('ol.Feature'); goog.require('ol.array'); goog.require('ol.extent'); goog.require('ol.format.Feature'); -goog.require('ol.format.GML'); +goog.require('ol.format.GMLBase'); goog.require('ol.format.XSD'); goog.require('ol.geom.Geometry'); goog.require('ol.geom.LineString'); @@ -31,10 +32,10 @@ goog.require('ol.xml'); * @constructor * @param {olx.format.GMLOptions=} opt_options * Optional configuration object. - * @extends {ol.format.GML} - * @api stable + * @extends {ol.format.GMLBase} + * @api */ -ol.format.GML.v3 = function(opt_options) { +ol.format.GML3 = function(opt_options) { var options = /** @type {olx.format.GMLOptions} */ (goog.isDef(opt_options) ? opt_options : {}); @@ -69,7 +70,7 @@ ol.format.GML.v3 = function(opt_options) { goog.base(this, opt_options); }; -goog.inherits(ol.format.GML.v3, ol.format.GML); +goog.inherits(ol.format.GML3, ol.format.GMLBase); @@ -93,7 +94,7 @@ ol.format.GML = ol.format.GML3; * @type {string} * @private */ -ol.format.GML.v3.schemaLocation_ = 'http://www.opengis.net/gml ' + +ol.format.GML3.schemaLocation_ = 'http://www.opengis.net/gml ' + 'http://schemas.opengis.net/gml/3.1.1/profiles/gmlsfProfile/' + '1.0.0/gmlsf.xsd'; @@ -104,12 +105,12 @@ ol.format.GML.v3.schemaLocation_ = 'http://www.opengis.net/gml ' + * @private * @return {ol.geom.MultiLineString|undefined} MultiLineString. */ -ol.format.GML.v3.prototype.readMultiCurve_ = function(node, objectStack) { +ol.format.GML3.prototype.readMultiCurve_ = function(node, objectStack) { goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); goog.asserts.assert(node.localName == 'MultiCurve'); var lineStrings = ol.xml.pushParseAndPop( /** @type {Array.} */ ([]), - ol.format.GML.v3.MULTICURVE_PARSERS_, node, objectStack, this); + ol.format.GML3.MULTICURVE_PARSERS_, node, objectStack, this); if (goog.isDef(lineStrings)) { var multiLineString = new ol.geom.MultiLineString(null); multiLineString.setLineStrings(lineStrings); @@ -126,12 +127,12 @@ ol.format.GML.v3.prototype.readMultiCurve_ = function(node, objectStack) { * @private * @return {ol.geom.MultiPolygon|undefined} MultiPolygon. */ -ol.format.GML.v3.prototype.readMultiSurface_ = function(node, objectStack) { +ol.format.GML3.prototype.readMultiSurface_ = function(node, objectStack) { goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); goog.asserts.assert(node.localName == 'MultiSurface'); var polygons = ol.xml.pushParseAndPop( /** @type {Array.} */ ([]), - ol.format.GML.v3.MULTISURFACE_PARSERS_, node, objectStack, this); + ol.format.GML3.MULTISURFACE_PARSERS_, node, objectStack, this); if (goog.isDef(polygons)) { var multiPolygon = new ol.geom.MultiPolygon(null); multiPolygon.setPolygons(polygons); @@ -147,11 +148,11 @@ ol.format.GML.v3.prototype.readMultiSurface_ = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @private */ -ol.format.GML.v3.prototype.curveMemberParser_ = function(node, objectStack) { +ol.format.GML3.prototype.curveMemberParser_ = function(node, objectStack) { goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); goog.asserts.assert(node.localName == 'curveMember' || node.localName == 'curveMembers'); - ol.xml.parse(ol.format.GML.v3.CURVEMEMBER_PARSERS_, node, objectStack, this); + ol.xml.parse(ol.format.GML3.CURVEMEMBER_PARSERS_, node, objectStack, this); }; @@ -160,11 +161,11 @@ ol.format.GML.v3.prototype.curveMemberParser_ = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @private */ -ol.format.GML.v3.prototype.surfaceMemberParser_ = function(node, objectStack) { +ol.format.GML3.prototype.surfaceMemberParser_ = function(node, objectStack) { goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); goog.asserts.assert(node.localName == 'surfaceMember' || node.localName == 'surfaceMembers'); - ol.xml.parse(ol.format.GML.v3.SURFACEMEMBER_PARSERS_, + ol.xml.parse(ol.format.GML3.SURFACEMEMBER_PARSERS_, node, objectStack, this); }; @@ -175,12 +176,12 @@ ol.format.GML.v3.prototype.surfaceMemberParser_ = function(node, objectStack) { * @private * @return {Array.<(Array.)>|undefined} flat coordinates. */ -ol.format.GML.v3.prototype.readPatch_ = function(node, objectStack) { +ol.format.GML3.prototype.readPatch_ = function(node, objectStack) { goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); goog.asserts.assert(node.localName == 'patches'); return ol.xml.pushParseAndPop( /** @type {Array.>} */ ([null]), - ol.format.GML.v3.PATCHES_PARSERS_, node, objectStack, this); + ol.format.GML3.PATCHES_PARSERS_, node, objectStack, this); }; @@ -190,12 +191,12 @@ ol.format.GML.v3.prototype.readPatch_ = function(node, objectStack) { * @private * @return {Array.|undefined} flat coordinates. */ -ol.format.GML.v3.prototype.readSegment_ = function(node, objectStack) { +ol.format.GML3.prototype.readSegment_ = function(node, objectStack) { goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); goog.asserts.assert(node.localName == 'segments'); return ol.xml.pushParseAndPop( /** @type {Array.} */ ([null]), - ol.format.GML.v3.SEGMENTS_PARSERS_, node, objectStack, this); + ol.format.GML3.SEGMENTS_PARSERS_, node, objectStack, this); }; @@ -205,7 +206,7 @@ ol.format.GML.v3.prototype.readSegment_ = function(node, objectStack) { * @private * @return {Array.<(Array.)>|undefined} flat coordinates. */ -ol.format.GML.v3.prototype.readPolygonPatch_ = function(node, objectStack) { +ol.format.GML3.prototype.readPolygonPatch_ = function(node, objectStack) { goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); goog.asserts.assert(node.localName == 'PolygonPatch'); return ol.xml.pushParseAndPop( @@ -220,7 +221,7 @@ ol.format.GML.v3.prototype.readPolygonPatch_ = function(node, objectStack) { * @private * @return {Array.|undefined} flat coordinates. */ -ol.format.GML.v3.prototype.readLineStringSegment_ = +ol.format.GML3.prototype.readLineStringSegment_ = function(node, objectStack) { goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); goog.asserts.assert(node.localName == 'LineStringSegment'); @@ -236,12 +237,12 @@ ol.format.GML.v3.prototype.readLineStringSegment_ = * @param {Array.<*>} objectStack Object stack. * @private */ -ol.format.GML.v3.prototype.interiorParser_ = function(node, objectStack) { +ol.format.GML3.prototype.interiorParser_ = function(node, objectStack) { goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); goog.asserts.assert(node.localName == 'interior'); var flatLinearRing = ol.xml.pushParseAndPop( /** @type {Array.|undefined} */ (undefined), - ol.format.GML.RING_PARSERS, node, objectStack, this); + ol.format.GMLBase.RING_PARSERS, node, objectStack, this); if (goog.isDef(flatLinearRing)) { var flatLinearRings = /** @type {Array.>} */ (objectStack[objectStack.length - 1]); @@ -257,12 +258,12 @@ ol.format.GML.v3.prototype.interiorParser_ = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @private */ -ol.format.GML.v3.prototype.exteriorParser_ = function(node, objectStack) { +ol.format.GML3.prototype.exteriorParser_ = function(node, objectStack) { goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); goog.asserts.assert(node.localName == 'exterior'); var flatLinearRing = ol.xml.pushParseAndPop( /** @type {Array.|undefined} */ (undefined), - ol.format.GML.RING_PARSERS, node, objectStack, this); + ol.format.GMLBase.RING_PARSERS, node, objectStack, this); if (goog.isDef(flatLinearRing)) { var flatLinearRings = /** @type {Array.>} */ (objectStack[objectStack.length - 1]); @@ -279,12 +280,12 @@ ol.format.GML.v3.prototype.exteriorParser_ = function(node, objectStack) { * @private * @return {ol.geom.Polygon|undefined} Polygon. */ -ol.format.GML.v3.prototype.readSurface_ = function(node, objectStack) { +ol.format.GML3.prototype.readSurface_ = function(node, objectStack) { goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); goog.asserts.assert(node.localName == 'Surface'); var flatLinearRings = ol.xml.pushParseAndPop( /** @type {Array.>} */ ([null]), - ol.format.GML.v3.SURFACE_PARSERS_, node, objectStack, this); + ol.format.GML3.SURFACE_PARSERS_, node, objectStack, this); if (goog.isDef(flatLinearRings) && !goog.isNull(flatLinearRings[0])) { var polygon = new ol.geom.Polygon(null); @@ -310,12 +311,12 @@ ol.format.GML.v3.prototype.readSurface_ = function(node, objectStack) { * @private * @return {ol.geom.LineString|undefined} LineString. */ -ol.format.GML.v3.prototype.readCurve_ = function(node, objectStack) { +ol.format.GML3.prototype.readCurve_ = function(node, objectStack) { goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); goog.asserts.assert(node.localName == 'Curve'); var flatCoordinates = ol.xml.pushParseAndPop( /** @type {Array.} */ ([null]), - ol.format.GML.v3.CURVE_PARSERS_, node, objectStack, this); + ol.format.GML3.CURVE_PARSERS_, node, objectStack, this); if (goog.isDef(flatCoordinates)) { var lineString = new ol.geom.LineString(null); lineString.setFlatCoordinates(ol.geom.GeometryLayout.XYZ, flatCoordinates); @@ -332,12 +333,12 @@ ol.format.GML.v3.prototype.readCurve_ = function(node, objectStack) { * @private * @return {ol.Extent|undefined} Envelope. */ -ol.format.GML.v3.prototype.readEnvelope_ = function(node, objectStack) { +ol.format.GML3.prototype.readEnvelope_ = function(node, objectStack) { goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); goog.asserts.assert(node.localName == 'Envelope'); var flatCoordinates = ol.xml.pushParseAndPop( /** @type {Array.} */ ([null]), - ol.format.GML.v3.ENVELOPE_PARSERS_, node, objectStack, this); + ol.format.GML3.ENVELOPE_PARSERS_, node, objectStack, this); return ol.extent.createOrUpdate(flatCoordinates[1][0], flatCoordinates[1][1], flatCoordinates[2][0], flatCoordinates[2][1]); @@ -350,7 +351,7 @@ ol.format.GML.v3.prototype.readEnvelope_ = function(node, objectStack) { * @private * @return {Array.|undefined} Flat coordinates. */ -ol.format.GML.v3.prototype.readFlatPos_ = function(node, objectStack) { +ol.format.GML3.prototype.readFlatPos_ = function(node, objectStack) { var s = ol.xml.getAllTextContent(node, false); var re = /^\s*([+\-]?\d*\.?\d+(?:[eE][+\-]?\d+)?)\s*/; /** @type {Array.} */ @@ -397,7 +398,7 @@ ol.format.GML.v3.prototype.readFlatPos_ = function(node, objectStack) { * @private * @return {Array.|undefined} Flat coordinates. */ -ol.format.GML.v3.prototype.readFlatPosList_ = function(node, objectStack) { +ol.format.GML3.prototype.readFlatPosList_ = function(node, objectStack) { var s = ol.xml.getAllTextContent(node, false).replace(/^\s*|\s*$/g, ''); var context = objectStack[0]; goog.asserts.assert(goog.isObject(context)); @@ -441,10 +442,10 @@ ol.format.GML.v3.prototype.readFlatPosList_ = function(node, objectStack) { * @type {Object.>} * @private */ -ol.format.GML.v3.GEOMETRY_FLAT_COORDINATES_PARSERS_ = { +ol.format.GML3.GEOMETRY_FLAT_COORDINATES_PARSERS_ = { 'http://www.opengis.net/gml' : { - 'pos': ol.xml.makeReplacer(ol.format.GML.v3.prototype.readFlatPos_), - 'posList': ol.xml.makeReplacer(ol.format.GML.v3.prototype.readFlatPosList_) + 'pos': ol.xml.makeReplacer(ol.format.GML3.prototype.readFlatPos_), + 'posList': ol.xml.makeReplacer(ol.format.GML3.prototype.readFlatPosList_) } }; @@ -454,10 +455,10 @@ ol.format.GML.v3.GEOMETRY_FLAT_COORDINATES_PARSERS_ = { * @type {Object.>} * @private */ -ol.format.GML.v3.FLAT_LINEAR_RINGS_PARSERS_ = { +ol.format.GML3.FLAT_LINEAR_RINGS_PARSERS_ = { 'http://www.opengis.net/gml' : { - 'interior': ol.format.GML.v3.prototype.interiorParser_, - 'exterior': ol.format.GML.v3.prototype.exteriorParser_ + 'interior': ol.format.GML3.prototype.interiorParser_, + 'exterior': ol.format.GML3.prototype.exteriorParser_ } }; @@ -467,25 +468,27 @@ ol.format.GML.v3.FLAT_LINEAR_RINGS_PARSERS_ = { * @type {Object.>} * @private */ -ol.format.GML.v3.GEOMETRY_PARSERS_ = { +ol.format.GML3.GEOMETRY_PARSERS_ = { 'http://www.opengis.net/gml' : { - 'Point': ol.xml.makeReplacer(ol.format.GML.prototype.readPoint), - 'MultiPoint': ol.xml.makeReplacer(ol.format.GML.prototype.readMultiPoint), - 'LineString': ol.xml.makeReplacer(ol.format.GML.prototype.readLineString), + 'Point': ol.xml.makeReplacer(ol.format.GMLBase.prototype.readPoint), + 'MultiPoint': ol.xml.makeReplacer( + ol.format.GMLBase.prototype.readMultiPoint), + 'LineString': ol.xml.makeReplacer( + ol.format.GMLBase.prototype.readLineString), 'MultiLineString': ol.xml.makeReplacer( - ol.format.GML.prototype.readMultiLineString), + ol.format.GMLBase.prototype.readMultiLineString), 'LinearRing' : ol.xml.makeReplacer( - ol.format.GML.prototype.readLinearRing), - 'Polygon': ol.xml.makeReplacer(ol.format.GML.prototype.readPolygon), + ol.format.GMLBase.prototype.readLinearRing), + 'Polygon': ol.xml.makeReplacer(ol.format.GMLBase.prototype.readPolygon), 'MultiPolygon': ol.xml.makeReplacer( - ol.format.GML.prototype.readMultiPolygon), - 'Surface': ol.xml.makeReplacer(ol.format.GML.v3.prototype.readSurface_), + ol.format.GMLBase.prototype.readMultiPolygon), + 'Surface': ol.xml.makeReplacer(ol.format.GML3.prototype.readSurface_), 'MultiSurface': ol.xml.makeReplacer( - ol.format.GML.v3.prototype.readMultiSurface_), - 'Curve': ol.xml.makeReplacer(ol.format.GML.v3.prototype.readCurve_), + ol.format.GML3.prototype.readMultiSurface_), + 'Curve': ol.xml.makeReplacer(ol.format.GML3.prototype.readCurve_), 'MultiCurve': ol.xml.makeReplacer( - ol.format.GML.v3.prototype.readMultiCurve_), - 'Envelope': ol.xml.makeReplacer(ol.format.GML.v3.prototype.readEnvelope_) + ol.format.GML3.prototype.readMultiCurve_), + 'Envelope': ol.xml.makeReplacer(ol.format.GML3.prototype.readEnvelope_) } }; @@ -495,12 +498,12 @@ ol.format.GML.v3.GEOMETRY_PARSERS_ = { * @type {Object.>} * @private */ -ol.format.GML.v3.MULTICURVE_PARSERS_ = { +ol.format.GML3.MULTICURVE_PARSERS_ = { 'http://www.opengis.net/gml' : { 'curveMember': ol.xml.makeArrayPusher( - ol.format.GML.v3.prototype.curveMemberParser_), + ol.format.GML3.prototype.curveMemberParser_), 'curveMembers': ol.xml.makeArrayPusher( - ol.format.GML.v3.prototype.curveMemberParser_) + ol.format.GML3.prototype.curveMemberParser_) } }; @@ -510,12 +513,12 @@ ol.format.GML.v3.MULTICURVE_PARSERS_ = { * @type {Object.>} * @private */ -ol.format.GML.v3.MULTISURFACE_PARSERS_ = { +ol.format.GML3.MULTISURFACE_PARSERS_ = { 'http://www.opengis.net/gml' : { 'surfaceMember': ol.xml.makeArrayPusher( - ol.format.GML.v3.prototype.surfaceMemberParser_), + ol.format.GML3.prototype.surfaceMemberParser_), 'surfaceMembers': ol.xml.makeArrayPusher( - ol.format.GML.v3.prototype.surfaceMemberParser_) + ol.format.GML3.prototype.surfaceMemberParser_) } }; @@ -525,11 +528,11 @@ ol.format.GML.v3.MULTISURFACE_PARSERS_ = { * @type {Object.>} * @private */ -ol.format.GML.v3.CURVEMEMBER_PARSERS_ = { +ol.format.GML3.CURVEMEMBER_PARSERS_ = { 'http://www.opengis.net/gml' : { 'LineString': ol.xml.makeArrayPusher( - ol.format.GML.prototype.readLineString), - 'Curve': ol.xml.makeArrayPusher(ol.format.GML.v3.prototype.readCurve_) + ol.format.GMLBase.prototype.readLineString), + 'Curve': ol.xml.makeArrayPusher(ol.format.GML3.prototype.readCurve_) } }; @@ -539,10 +542,10 @@ ol.format.GML.v3.CURVEMEMBER_PARSERS_ = { * @type {Object.>} * @private */ -ol.format.GML.v3.SURFACEMEMBER_PARSERS_ = { +ol.format.GML3.SURFACEMEMBER_PARSERS_ = { 'http://www.opengis.net/gml' : { - 'Polygon': ol.xml.makeArrayPusher(ol.format.GML.prototype.readPolygon), - 'Surface': ol.xml.makeArrayPusher(ol.format.GML.v3.prototype.readSurface_) + 'Polygon': ol.xml.makeArrayPusher(ol.format.GMLBase.prototype.readPolygon), + 'Surface': ol.xml.makeArrayPusher(ol.format.GML3.prototype.readSurface_) } }; @@ -552,9 +555,9 @@ ol.format.GML.v3.SURFACEMEMBER_PARSERS_ = { * @type {Object.>} * @private */ -ol.format.GML.v3.SURFACE_PARSERS_ = { +ol.format.GML3.SURFACE_PARSERS_ = { 'http://www.opengis.net/gml' : { - 'patches': ol.xml.makeReplacer(ol.format.GML.v3.prototype.readPatch_) + 'patches': ol.xml.makeReplacer(ol.format.GML3.prototype.readPatch_) } }; @@ -564,9 +567,9 @@ ol.format.GML.v3.SURFACE_PARSERS_ = { * @type {Object.>} * @private */ -ol.format.GML.v3.CURVE_PARSERS_ = { +ol.format.GML3.CURVE_PARSERS_ = { 'http://www.opengis.net/gml' : { - 'segments': ol.xml.makeReplacer(ol.format.GML.v3.prototype.readSegment_) + 'segments': ol.xml.makeReplacer(ol.format.GML3.prototype.readSegment_) } }; @@ -576,12 +579,12 @@ ol.format.GML.v3.CURVE_PARSERS_ = { * @type {Object.>} * @private */ -ol.format.GML.v3.ENVELOPE_PARSERS_ = { +ol.format.GML3.ENVELOPE_PARSERS_ = { 'http://www.opengis.net/gml' : { 'lowerCorner': ol.xml.makeArrayPusher( - ol.format.GML.v3.prototype.readFlatPosList_), + ol.format.GML3.prototype.readFlatPosList_), 'upperCorner': ol.xml.makeArrayPusher( - ol.format.GML.v3.prototype.readFlatPosList_) + ol.format.GML3.prototype.readFlatPosList_) } }; @@ -591,10 +594,10 @@ ol.format.GML.v3.ENVELOPE_PARSERS_ = { * @type {Object.>} * @private */ -ol.format.GML.v3.PATCHES_PARSERS_ = { +ol.format.GML3.PATCHES_PARSERS_ = { 'http://www.opengis.net/gml' : { 'PolygonPatch': ol.xml.makeReplacer( - ol.format.GML.v3.prototype.readPolygonPatch_) + ol.format.GML3.prototype.readPolygonPatch_) } }; @@ -604,10 +607,10 @@ ol.format.GML.v3.PATCHES_PARSERS_ = { * @type {Object.>} * @private */ -ol.format.GML.v3.SEGMENTS_PARSERS_ = { +ol.format.GML3.SEGMENTS_PARSERS_ = { 'http://www.opengis.net/gml' : { 'LineStringSegment': ol.xml.makeReplacer( - ol.format.GML.v3.prototype.readLineStringSegment_) + ol.format.GML3.prototype.readLineStringSegment_) } }; @@ -618,7 +621,7 @@ ol.format.GML.v3.SEGMENTS_PARSERS_ = { * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.GML.v3.prototype.writePos_ = function(node, value, objectStack) { +ol.format.GML3.prototype.writePos_ = function(node, value, objectStack) { var context = objectStack[objectStack.length - 1]; goog.asserts.assert(goog.isObject(context)); var srsName = goog.object.get(context, 'srsName'); @@ -644,7 +647,7 @@ ol.format.GML.v3.prototype.writePos_ = function(node, value, objectStack) { * @return {string} * @private */ -ol.format.GML.v3.prototype.getCoords_ = function(point, opt_srsName) { +ol.format.GML3.prototype.getCoords_ = function(point, opt_srsName) { var axisOrientation = 'enu'; if (goog.isDefAndNotNull(opt_srsName)) { axisOrientation = ol.proj.get(opt_srsName).getAxisOrientation(); @@ -661,7 +664,7 @@ ol.format.GML.v3.prototype.getCoords_ = function(point, opt_srsName) { * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.GML.v3.prototype.writePosList_ = function(node, value, objectStack) { +ol.format.GML3.prototype.writePosList_ = function(node, value, objectStack) { var context = objectStack[objectStack.length - 1]; goog.asserts.assert(goog.isObject(context)); var srsName = goog.object.get(context, 'srsName'); @@ -684,7 +687,7 @@ ol.format.GML.v3.prototype.writePosList_ = function(node, value, objectStack) { * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.GML.v3.prototype.writePoint_ = function(node, geometry, objectStack) { +ol.format.GML3.prototype.writePoint_ = function(node, geometry, objectStack) { var context = objectStack[objectStack.length - 1]; goog.asserts.assert(goog.isObject(context)); var srsName = goog.object.get(context, 'srsName'); @@ -701,7 +704,7 @@ ol.format.GML.v3.prototype.writePoint_ = function(node, geometry, objectStack) { * @type {Object.>} * @private */ -ol.format.GML.v3.ENVELOPE_SERIALIZERS_ = { +ol.format.GML3.ENVELOPE_SERIALIZERS_ = { 'http://www.opengis.net/gml': { 'lowerCorner': ol.xml.makeChildAppender(ol.format.XSD.writeStringTextNode), 'upperCorner': ol.xml.makeChildAppender(ol.format.XSD.writeStringTextNode) @@ -714,7 +717,7 @@ ol.format.GML.v3.ENVELOPE_SERIALIZERS_ = { * @param {ol.Extent} extent Extent. * @param {Array.<*>} objectStack Node stack. */ -ol.format.GML.v3.prototype.writeEnvelope = function(node, extent, objectStack) { +ol.format.GML3.prototype.writeEnvelope = function(node, extent, objectStack) { goog.asserts.assert(extent.length == 4); var context = objectStack[objectStack.length - 1]; goog.asserts.assert(goog.isObject(context)); @@ -725,7 +728,7 @@ ol.format.GML.v3.prototype.writeEnvelope = function(node, extent, objectStack) { var keys = ['lowerCorner', 'upperCorner']; var values = [extent[0] + ' ' + extent[1], extent[2] + ' ' + extent[3]]; ol.xml.pushSerializeAndPop(/** @type {ol.xml.NodeStackItem} */ - ({node: node}), ol.format.GML.v3.ENVELOPE_SERIALIZERS_, + ({node: node}), ol.format.GML3.ENVELOPE_SERIALIZERS_, ol.xml.OBJECT_PROPERTY_NODE_FACTORY, values, objectStack, keys, this); @@ -738,7 +741,7 @@ ol.format.GML.v3.prototype.writeEnvelope = function(node, extent, objectStack) { * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.GML.v3.prototype.writeLinearRing_ = +ol.format.GML3.prototype.writeLinearRing_ = function(node, geometry, objectStack) { var context = objectStack[objectStack.length - 1]; goog.asserts.assert(goog.isObject(context)); @@ -759,7 +762,7 @@ ol.format.GML.v3.prototype.writeLinearRing_ = * @return {Node} Node. * @private */ -ol.format.GML.v3.prototype.RING_NODE_FACTORY_ = +ol.format.GML3.prototype.RING_NODE_FACTORY_ = function(value, objectStack, opt_nodeName) { var context = objectStack[objectStack.length - 1]; var parentNode = context.node; @@ -779,7 +782,7 @@ ol.format.GML.v3.prototype.RING_NODE_FACTORY_ = * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.GML.v3.prototype.writeSurfaceOrPolygon_ = +ol.format.GML3.prototype.writeSurfaceOrPolygon_ = function(node, geometry, objectStack) { var context = objectStack[objectStack.length - 1]; goog.asserts.assert(goog.isObject(context)); @@ -791,7 +794,7 @@ ol.format.GML.v3.prototype.writeSurfaceOrPolygon_ = var rings = geometry.getLinearRings(); ol.xml.pushSerializeAndPop( {node: node, srsName: srsName}, - ol.format.GML.v3.RING_SERIALIZERS_, + ol.format.GML3.RING_SERIALIZERS_, this.RING_NODE_FACTORY_, rings, objectStack, undefined, this); } else if (node.nodeName === 'Surface') { @@ -809,7 +812,7 @@ ol.format.GML.v3.prototype.writeSurfaceOrPolygon_ = * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.GML.v3.prototype.writeCurveOrLineString_ = +ol.format.GML3.prototype.writeCurveOrLineString_ = function(node, geometry, objectStack) { var context = objectStack[objectStack.length - 1]; goog.asserts.assert(goog.isObject(context)); @@ -838,7 +841,7 @@ ol.format.GML.v3.prototype.writeCurveOrLineString_ = * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.GML.v3.prototype.writeMultiSurfaceOrPolygon_ = +ol.format.GML3.prototype.writeMultiSurfaceOrPolygon_ = function(node, geometry, objectStack) { var context = objectStack[objectStack.length - 1]; goog.asserts.assert(goog.isObject(context)); @@ -849,7 +852,7 @@ ol.format.GML.v3.prototype.writeMultiSurfaceOrPolygon_ = } var polygons = geometry.getPolygons(); ol.xml.pushSerializeAndPop({node: node, srsName: srsName, surface: surface}, - ol.format.GML.v3.SURFACEORPOLYGONMEMBER_SERIALIZERS_, + ol.format.GML3.SURFACEORPOLYGONMEMBER_SERIALIZERS_, this.MULTIGEOMETRY_MEMBER_NODE_FACTORY_, polygons, objectStack, undefined, this); }; @@ -861,7 +864,7 @@ ol.format.GML.v3.prototype.writeMultiSurfaceOrPolygon_ = * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.GML.v3.prototype.writeMultiPoint_ = function(node, geometry, +ol.format.GML3.prototype.writeMultiPoint_ = function(node, geometry, objectStack) { var context = objectStack[objectStack.length - 1]; goog.asserts.assert(goog.isObject(context)); @@ -871,7 +874,7 @@ ol.format.GML.v3.prototype.writeMultiPoint_ = function(node, geometry, } var points = geometry.getPoints(); ol.xml.pushSerializeAndPop({node: node, srsName: srsName}, - ol.format.GML.v3.POINTMEMBER_SERIALIZERS_, + ol.format.GML3.POINTMEMBER_SERIALIZERS_, ol.xml.makeSimpleNodeFactory('pointMember'), points, objectStack, undefined, this); }; @@ -883,7 +886,7 @@ ol.format.GML.v3.prototype.writeMultiPoint_ = function(node, geometry, * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.GML.v3.prototype.writeMultiCurveOrLineString_ = +ol.format.GML3.prototype.writeMultiCurveOrLineString_ = function(node, geometry, objectStack) { var context = objectStack[objectStack.length - 1]; goog.asserts.assert(goog.isObject(context)); @@ -894,7 +897,7 @@ ol.format.GML.v3.prototype.writeMultiCurveOrLineString_ = } var lines = geometry.getLineStrings(); ol.xml.pushSerializeAndPop({node: node, srsName: srsName, curve: curve}, - ol.format.GML.v3.LINESTRINGORCURVEMEMBER_SERIALIZERS_, + ol.format.GML3.LINESTRINGORCURVEMEMBER_SERIALIZERS_, this.MULTIGEOMETRY_MEMBER_NODE_FACTORY_, lines, objectStack, undefined, this); }; @@ -906,7 +909,7 @@ ol.format.GML.v3.prototype.writeMultiCurveOrLineString_ = * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.GML.v3.prototype.writeRing_ = function(node, ring, objectStack) { +ol.format.GML3.prototype.writeRing_ = function(node, ring, objectStack) { var linearRing = ol.xml.createElementNS(node.namespaceURI, 'LinearRing'); node.appendChild(linearRing); this.writeLinearRing_(linearRing, ring, objectStack); @@ -919,7 +922,7 @@ ol.format.GML.v3.prototype.writeRing_ = function(node, ring, objectStack) { * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.GML.v3.prototype.writeSurfaceOrPolygonMember_ = +ol.format.GML3.prototype.writeSurfaceOrPolygonMember_ = function(node, polygon, objectStack) { var context = objectStack[objectStack.length - 1]; goog.asserts.assert(goog.isObject(context)); @@ -938,7 +941,7 @@ ol.format.GML.v3.prototype.writeSurfaceOrPolygonMember_ = * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.GML.v3.prototype.writePointMember_ = +ol.format.GML3.prototype.writePointMember_ = function(node, point, objectStack) { var child = ol.xml.createElementNS(node.namespaceURI, 'Point'); node.appendChild(child); @@ -952,7 +955,7 @@ ol.format.GML.v3.prototype.writePointMember_ = * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.GML.v3.prototype.writeLineStringOrCurveMember_ = +ol.format.GML3.prototype.writeLineStringOrCurveMember_ = function(node, line, objectStack) { var context = objectStack[objectStack.length - 1]; goog.asserts.assert(goog.isObject(context)); @@ -970,7 +973,7 @@ ol.format.GML.v3.prototype.writeLineStringOrCurveMember_ = * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.GML.v3.prototype.writeSurfacePatches_ = +ol.format.GML3.prototype.writeSurfacePatches_ = function(node, polygon, objectStack) { var child = ol.xml.createElementNS(node.namespaceURI, 'PolygonPatch'); node.appendChild(child); @@ -984,7 +987,7 @@ ol.format.GML.v3.prototype.writeSurfacePatches_ = * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.GML.v3.prototype.writeCurveSegments_ = +ol.format.GML3.prototype.writeCurveSegments_ = function(node, line, objectStack) { var child = ol.xml.createElementNS(node.namespaceURI, 'LineStringSegment'); @@ -998,7 +1001,7 @@ ol.format.GML.v3.prototype.writeCurveSegments_ = * @param {ol.geom.Geometry|ol.Extent} geometry Geometry. * @param {Array.<*>} objectStack Node stack. */ -ol.format.GML.v3.prototype.writeGeometryElement = +ol.format.GML3.prototype.writeGeometryElement = function(node, geometry, objectStack) { var context = objectStack[objectStack.length - 1]; goog.asserts.assert(goog.isObject(context)); @@ -1018,7 +1021,7 @@ ol.format.GML.v3.prototype.writeGeometryElement = ol.format.Feature.transformWithOptions(geometry, true, context); } ol.xml.pushSerializeAndPop(/** @type {ol.xml.NodeStackItem} */ - (item), ol.format.GML.v3.GEOMETRY_SERIALIZERS_, + (item), ol.format.GML3.GEOMETRY_SERIALIZERS_, this.GEOMETRY_NODE_FACTORY_, [value], objectStack, undefined, this); }; @@ -1029,7 +1032,7 @@ ol.format.GML.v3.prototype.writeGeometryElement = * @param {ol.Feature} feature Feature. * @param {Array.<*>} objectStack Node stack. */ -ol.format.GML.v3.prototype.writeFeatureElement = +ol.format.GML3.prototype.writeFeatureElement = function(node, feature, objectStack) { var fid = feature.getId(); if (goog.isDef(fid)) { @@ -1079,7 +1082,7 @@ ol.format.GML.v3.prototype.writeFeatureElement = * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.GML.v3.prototype.writeFeatureMembers_ = +ol.format.GML3.prototype.writeFeatureMembers_ = function(node, features, objectStack) { var context = objectStack[objectStack.length - 1]; goog.asserts.assert(goog.isObject(context)); @@ -1103,12 +1106,12 @@ ol.format.GML.v3.prototype.writeFeatureMembers_ = * @type {Object.>} * @private */ -ol.format.GML.v3.SURFACEORPOLYGONMEMBER_SERIALIZERS_ = { +ol.format.GML3.SURFACEORPOLYGONMEMBER_SERIALIZERS_ = { 'http://www.opengis.net/gml': { 'surfaceMember': ol.xml.makeChildAppender( - ol.format.GML.v3.prototype.writeSurfaceOrPolygonMember_), + ol.format.GML3.prototype.writeSurfaceOrPolygonMember_), 'polygonMember': ol.xml.makeChildAppender( - ol.format.GML.v3.prototype.writeSurfaceOrPolygonMember_) + ol.format.GML3.prototype.writeSurfaceOrPolygonMember_) } }; @@ -1117,10 +1120,10 @@ ol.format.GML.v3.SURFACEORPOLYGONMEMBER_SERIALIZERS_ = { * @type {Object.>} * @private */ -ol.format.GML.v3.POINTMEMBER_SERIALIZERS_ = { +ol.format.GML3.POINTMEMBER_SERIALIZERS_ = { 'http://www.opengis.net/gml': { 'pointMember': ol.xml.makeChildAppender( - ol.format.GML.v3.prototype.writePointMember_) + ol.format.GML3.prototype.writePointMember_) } }; @@ -1129,12 +1132,12 @@ ol.format.GML.v3.POINTMEMBER_SERIALIZERS_ = { * @type {Object.>} * @private */ -ol.format.GML.v3.LINESTRINGORCURVEMEMBER_SERIALIZERS_ = { +ol.format.GML3.LINESTRINGORCURVEMEMBER_SERIALIZERS_ = { 'http://www.opengis.net/gml': { 'lineStringMember': ol.xml.makeChildAppender( - ol.format.GML.v3.prototype.writeLineStringOrCurveMember_), + ol.format.GML3.prototype.writeLineStringOrCurveMember_), 'curveMember': ol.xml.makeChildAppender( - ol.format.GML.v3.prototype.writeLineStringOrCurveMember_) + ol.format.GML3.prototype.writeLineStringOrCurveMember_) } }; @@ -1143,10 +1146,10 @@ ol.format.GML.v3.LINESTRINGORCURVEMEMBER_SERIALIZERS_ = { * @type {Object.>} * @private */ -ol.format.GML.v3.RING_SERIALIZERS_ = { +ol.format.GML3.RING_SERIALIZERS_ = { 'http://www.opengis.net/gml': { - 'exterior': ol.xml.makeChildAppender(ol.format.GML.v3.prototype.writeRing_), - 'interior': ol.xml.makeChildAppender(ol.format.GML.v3.prototype.writeRing_) + 'exterior': ol.xml.makeChildAppender(ol.format.GML3.prototype.writeRing_), + 'interior': ol.xml.makeChildAppender(ol.format.GML3.prototype.writeRing_) } }; @@ -1155,31 +1158,31 @@ ol.format.GML.v3.RING_SERIALIZERS_ = { * @type {Object.>} * @private */ -ol.format.GML.v3.GEOMETRY_SERIALIZERS_ = { +ol.format.GML3.GEOMETRY_SERIALIZERS_ = { 'http://www.opengis.net/gml': { 'Curve': ol.xml.makeChildAppender( - ol.format.GML.v3.prototype.writeCurveOrLineString_), + ol.format.GML3.prototype.writeCurveOrLineString_), 'MultiCurve': ol.xml.makeChildAppender( - ol.format.GML.v3.prototype.writeMultiCurveOrLineString_), - 'Point': ol.xml.makeChildAppender(ol.format.GML.v3.prototype.writePoint_), + ol.format.GML3.prototype.writeMultiCurveOrLineString_), + 'Point': ol.xml.makeChildAppender(ol.format.GML3.prototype.writePoint_), 'MultiPoint': ol.xml.makeChildAppender( - ol.format.GML.v3.prototype.writeMultiPoint_), + ol.format.GML3.prototype.writeMultiPoint_), 'LineString': ol.xml.makeChildAppender( - ol.format.GML.v3.prototype.writeCurveOrLineString_), + ol.format.GML3.prototype.writeCurveOrLineString_), 'MultiLineString': ol.xml.makeChildAppender( - ol.format.GML.v3.prototype.writeMultiCurveOrLineString_), + ol.format.GML3.prototype.writeMultiCurveOrLineString_), 'LinearRing': ol.xml.makeChildAppender( - ol.format.GML.v3.prototype.writeLinearRing_), + ol.format.GML3.prototype.writeLinearRing_), 'Polygon': ol.xml.makeChildAppender( - ol.format.GML.v3.prototype.writeSurfaceOrPolygon_), + ol.format.GML3.prototype.writeSurfaceOrPolygon_), 'MultiPolygon': ol.xml.makeChildAppender( - ol.format.GML.v3.prototype.writeMultiSurfaceOrPolygon_), + ol.format.GML3.prototype.writeMultiSurfaceOrPolygon_), 'Surface': ol.xml.makeChildAppender( - ol.format.GML.v3.prototype.writeSurfaceOrPolygon_), + ol.format.GML3.prototype.writeSurfaceOrPolygon_), 'MultiSurface': ol.xml.makeChildAppender( - ol.format.GML.v3.prototype.writeMultiSurfaceOrPolygon_), + ol.format.GML3.prototype.writeMultiSurfaceOrPolygon_), 'Envelope': ol.xml.makeChildAppender( - ol.format.GML.v3.prototype.writeEnvelope) + ol.format.GML3.prototype.writeEnvelope) } }; @@ -1189,7 +1192,7 @@ ol.format.GML.v3.GEOMETRY_SERIALIZERS_ = { * @type {Object.} * @private */ -ol.format.GML.v3.MULTIGEOMETRY_TO_MEMBER_NODENAME_ = { +ol.format.GML3.MULTIGEOMETRY_TO_MEMBER_NODENAME_ = { 'MultiLineString': 'lineStringMember', 'MultiCurve': 'curveMember', 'MultiPolygon': 'polygonMember', @@ -1205,12 +1208,12 @@ ol.format.GML.v3.MULTIGEOMETRY_TO_MEMBER_NODENAME_ = { * @return {Node|undefined} Node. * @private */ -ol.format.GML.v3.prototype.MULTIGEOMETRY_MEMBER_NODE_FACTORY_ = +ol.format.GML3.prototype.MULTIGEOMETRY_MEMBER_NODE_FACTORY_ = function(value, objectStack, opt_nodeName) { var parentNode = objectStack[objectStack.length - 1].node; goog.asserts.assert(ol.xml.isNode(parentNode)); return ol.xml.createElementNS('http://www.opengis.net/gml', - ol.format.GML.v3.MULTIGEOMETRY_TO_MEMBER_NODENAME_[parentNode.nodeName]); + ol.format.GML3.MULTIGEOMETRY_TO_MEMBER_NODENAME_[parentNode.nodeName]); }; @@ -1222,7 +1225,7 @@ ol.format.GML.v3.prototype.MULTIGEOMETRY_MEMBER_NODE_FACTORY_ = * @return {Node|undefined} Node. * @private */ -ol.format.GML.v3.prototype.GEOMETRY_NODE_FACTORY_ = +ol.format.GML3.prototype.GEOMETRY_NODE_FACTORY_ = function(value, objectStack, opt_nodeName) { var context = objectStack[objectStack.length - 1]; goog.asserts.assert(goog.isObject(context)); @@ -1256,7 +1259,7 @@ ol.format.GML.v3.prototype.GEOMETRY_NODE_FACTORY_ = /** * @inheritDoc */ -ol.format.GML.v3.prototype.writeGeometryNode = function(geometry, opt_options) { +ol.format.GML3.prototype.writeGeometryNode = function(geometry, opt_options) { var geom = ol.xml.createElementNS('http://www.opengis.net/gml', 'geom'); var context = {node: geom, srsName: this.srsName, curve: this.curve_, surface: this.surface_, @@ -1278,13 +1281,13 @@ ol.format.GML.v3.prototype.writeGeometryNode = function(geometry, opt_options) { * @return {Node} Result. * @api stable */ -ol.format.GML.v3.prototype.writeFeatures; +ol.format.GML3.prototype.writeFeatures; /** * @inheritDoc */ -ol.format.GML.v3.prototype.writeFeaturesNode = function(features, opt_options) { +ol.format.GML3.prototype.writeFeaturesNode = function(features, opt_options) { var node = ol.xml.createElementNS('http://www.opengis.net/gml', 'featureMembers'); ol.xml.setAttributeNS(node, 'http://www.w3.org/2001/XMLSchema-instance', diff --git a/src/ol/format/wfsformat.js b/src/ol/format/wfsformat.js index 5dd5d9903d..66fa3759c6 100644 --- a/src/ol/format/wfsformat.js +++ b/src/ol/format/wfsformat.js @@ -3,7 +3,8 @@ goog.provide('ol.format.WFS'); goog.require('goog.asserts'); goog.require('goog.dom.NodeType'); goog.require('goog.object'); -goog.require('ol.format.GML'); +goog.require('ol.format.GML3'); +goog.require('ol.format.GMLBase'); goog.require('ol.format.XMLFeature'); goog.require('ol.format.XSD'); goog.require('ol.geom.Geometry'); @@ -16,7 +17,7 @@ goog.require('ol.xml'); * @classdesc * Feature format for reading and writing data in the WFS format. * Currently only supports WFS version 1.1.0. - * Also see {@link ol.format.GML} which is used by this format. + * Also see {@link ol.format.GMLBase} which is used by this format. * * @constructor * @param {olx.format.WFSOptions=} opt_options @@ -42,10 +43,10 @@ ol.format.WFS = function(opt_options) { /** * @private - * @type {ol.format.GML} + * @type {ol.format.GMLBase} */ this.gmlFormat_ = goog.isDef(options.gmlFormat) ? - options.gmlFormat : new ol.format.GML.v3(); + options.gmlFormat : new ol.format.GML3(); /** * @private @@ -126,7 +127,7 @@ ol.format.WFS.prototype.readFeaturesFromNode = function(node, opt_options) { goog.isDef(opt_options) ? opt_options : {})); var objectStack = [context]; var features = ol.xml.pushParseAndPop([], - ol.format.GML.FEATURE_COLLECTION_PARSERS, node, + ol.format.GMLBase.FEATURE_COLLECTION_PARSERS, node, objectStack, this.gmlFormat_); if (!goog.isDef(features)) { features = []; @@ -204,7 +205,7 @@ ol.format.WFS.prototype.readFeatureCollectionMetadataFromDocument = ol.format.WFS.FEATURE_COLLECTION_PARSERS_ = { 'http://www.opengis.net/gml': { 'boundedBy': ol.xml.makeObjectPropertySetter( - ol.format.GML.prototype.readGeometryElement, 'bounds') + ol.format.GMLBase.prototype.readGeometryElement, 'bounds') } }; @@ -371,7 +372,7 @@ ol.format.WFS.writeFeature_ = function(node, feature, objectStack) { var featureNS = goog.object.get(context, 'featureNS'); var child = ol.xml.createElementNS(featureNS, featureType); node.appendChild(child); - ol.format.GML.v3.prototype.writeFeatureElement(child, feature, objectStack); + ol.format.GML3.prototype.writeFeatureElement(child, feature, objectStack); }; @@ -465,7 +466,7 @@ ol.format.WFS.writeProperty_ = function(node, pair, objectStack) { var value = ol.xml.createElementNS('http://www.opengis.net/wfs', 'Value'); node.appendChild(value); if (pair.value instanceof ol.geom.Geometry) { - ol.format.GML.v3.prototype.writeGeometryElement(value, + ol.format.GML3.prototype.writeGeometryElement(value, pair.value, objectStack); } else { ol.format.XSD.writeStringTextNode(value, pair.value); @@ -573,7 +574,7 @@ ol.format.WFS.writeOgcBBOX_ = function(node, bbox, objectStack) { var bboxNode = ol.xml.createElementNS('http://www.opengis.net/ogc', 'BBOX'); node.appendChild(bboxNode); ol.format.WFS.writeOgcPropertyName_(bboxNode, geometryName, objectStack); - ol.format.GML.v3.prototype.writeGeometryElement(bboxNode, bbox, objectStack); + ol.format.GML3.prototype.writeGeometryElement(bboxNode, bbox, objectStack); }; diff --git a/test/spec/ol/format/gmlformat.test.js b/test/spec/ol/format/gmlformat.test.js index e189be53c0..0f7dd78349 100644 --- a/test/spec/ol/format/gmlformat.test.js +++ b/test/spec/ol/format/gmlformat.test.js @@ -8,15 +8,15 @@ var readGeometry = function(format, text, opt_options) { return format.readGeometryFromNode(node, opt_options); }; -describe('ol.format.GML.v2', function() { +describe('ol.format.GML2', function() { var format, formatWGS84, formatNoSrs; beforeEach(function() { - format = new ol.format.GML.v2({srsName: 'CRS:84'}); - formatWGS84 = new ol.format.GML.v2({ + format = new ol.format.GML2({srsName: 'CRS:84'}); + formatWGS84 = new ol.format.GML2({ srsName: 'urn:x-ogc:def:crs:EPSG:4326' }); - formatNoSrs = new ol.format.GML.v2(); + formatNoSrs = new ol.format.GML2(); }); @@ -95,15 +95,15 @@ describe('ol.format.GML.v2', function() { }); }); -describe('ol.format.GML.v3', function() { +describe('ol.format.GML3', function() { var format, formatWGS84, formatNoSrs; beforeEach(function() { - format = new ol.format.GML.v3({srsName: 'CRS:84'}); - formatWGS84 = new ol.format.GML.v3({ + format = new ol.format.GML({srsName: 'CRS:84'}); + formatWGS84 = new ol.format.GML({ srsName: 'urn:x-ogc:def:crs:EPSG:4326' }); - formatNoSrs = new ol.format.GML.v3(); + formatNoSrs = new ol.format.GML(); }); describe('#readGeometry', function() { @@ -305,7 +305,7 @@ describe('ol.format.GML.v3', function() { var g = readGeometry(format, text); expect(g.getCoordinates()[0][0][0][0]).to.equal(-77.0081); expect(g.getCoordinates()[0][0][0][1]).to.equal(38.9661); - format = new ol.format.GML.v3({ + format = new ol.format.GML({ srsName: 'urn:x-ogc:def:crs:EPSG:4326', surface: false}); var serialized = format.writeGeometry(g); @@ -411,7 +411,7 @@ describe('ol.format.GML.v3', function() { expect(g.getCoordinates()).to.eql([[[1, 2, 0], [3, 2, 0], [3, 4, 0], [1, 2, 0]], [[2, 3, 0], [2, 5, 0], [4, 5, 0], [2, 3, 0]], [[3, 4, 0], [3, 6, 0], [5, 6, 0], [3, 4, 0]]]); - format = new ol.format.GML.v3({srsName: 'CRS:84', surface: true}); + format = new ol.format.GML({srsName: 'CRS:84', surface: true}); var serialized = format.writeGeometry(g); expect(serialized.firstElementChild).to.xmleql(ol.xml.load(text)); }); @@ -433,7 +433,7 @@ describe('ol.format.GML.v3', function() { var g = readGeometry(format, text); expect(g).to.be.an(ol.geom.LineString); expect(g.getCoordinates()).to.eql([[1, 2, 0], [3, 4, 0]]); - format = new ol.format.GML.v3({srsName: 'CRS:84', curve: true}); + format = new ol.format.GML({srsName: 'CRS:84', curve: true}); var serialized = format.writeGeometry(g); expect(serialized.firstElementChild).to.xmleql(ol.xml.load(text)); }); @@ -528,7 +528,7 @@ describe('ol.format.GML.v3', function() { expect(g).to.be.an(ol.geom.MultiLineString); expect(g.getCoordinates()).to.eql( [[[1, 2, 0], [2, 3, 0]], [[3, 4, 0], [4, 5, 0]]]); - format = new ol.format.GML.v3({srsName: 'CRS:84', multiCurve: false}); + format = new ol.format.GML({srsName: 'CRS:84', multiCurve: false}); var serialized = format.writeGeometry(g); expect(serialized.firstElementChild).to.xmleql(ol.xml.load(text)); }); @@ -596,7 +596,7 @@ describe('ol.format.GML.v3', function() { [1, 2, 0]], [[2, 3, 0], [2, 5, 0], [4, 5, 0], [2, 3, 0]], [[3, 4, 0], [3, 6, 0], [5, 6, 0], [3, 4, 0]]], [[[1, 2, 0], [3, 2, 0], [3, 4, 0], [1, 2, 0]]]]); - format = new ol.format.GML.v3({srsName: 'CRS:84', multiSurface: false}); + format = new ol.format.GML({srsName: 'CRS:84', multiSurface: false}); var serialized = format.writeGeometry(g); expect(serialized.firstElementChild).to.xmleql(ol.xml.load(text)); }); @@ -696,7 +696,7 @@ describe('ol.format.GML.v3', function() { expect(g).to.be.an(ol.geom.MultiLineString); expect(g.getCoordinates()).to.eql( [[[1, 2, 0], [2, 3, 0]], [[3, 4, 0], [4, 5, 0]]]); - format = new ol.format.GML.v3({srsName: 'CRS:84', curve: true}); + format = new ol.format.GML({srsName: 'CRS:84', curve: true}); var serialized = format.writeGeometry(g); expect(serialized.firstElementChild).to.xmleql(ol.xml.load(text)); }); @@ -839,7 +839,7 @@ describe('ol.format.GML.v3', function() { [1, 2, 0]], [[2, 3, 0], [2, 5, 0], [4, 5, 0], [2, 3, 0]], [[3, 4, 0], [3, 6, 0], [5, 6, 0], [3, 4, 0]]], [[[1, 2, 0], [3, 2, 0], [3, 4, 0], [1, 2, 0]]]]); - format = new ol.format.GML.v3({srsName: 'CRS:84', surface: true}); + format = new ol.format.GML({srsName: 'CRS:84', surface: true}); var serialized = format.writeGeometry(g); expect(serialized.firstElementChild).to.xmleql(ol.xml.load(text)); }); @@ -871,7 +871,7 @@ describe('ol.format.GML.v3', function() { 'featureNS': 'http://www.openplans.org/topp', 'featureType': 'gnis_pop' }; - var features = new ol.format.GML.v3(config).readFeatures(text); + var features = new ol.format.GML(config).readFeatures(text); var feature = features[0]; expect(feature.get('empty')).to.be(undefined); }); @@ -883,7 +883,7 @@ describe('ol.format.GML.v3', function() { afterLoadText('spec/ol/format/gml/topp-states-wfs.xml', function(xml) { try { text = xml; - gmlFormat = new ol.format.GML.v3(); + gmlFormat = new ol.format.GML(); features = gmlFormat.readFeatures(xml); } catch (e) { done(e); @@ -948,7 +948,7 @@ describe('ol.format.GML.v3', function() { 'schemaLocation': schemaLoc }; text = xml; - gmlFormat = new ol.format.GML.v3(config); + gmlFormat = new ol.format.GML(config); features = gmlFormat.readFeatures(xml); } catch (e) { done(e); @@ -982,7 +982,7 @@ describe('ol.format.GML.v3', function() { 'featureNS': 'http://www.openplans.org/topp', 'featureType': 'states' }; - features = new ol.format.GML.v3(config).readFeatures(xml); + features = new ol.format.GML(config).readFeatures(xml); } catch (e) { done(e); } @@ -1013,7 +1013,7 @@ describe('ol.format.GML.v3', function() { 'featureNS': 'http://opengeo.org/#medford', 'featureType': 'zoning' }; - features = new ol.format.GML.v3(config).readFeatures(xml); + features = new ol.format.GML(config).readFeatures(xml); } catch (e) { done(e); } @@ -1039,7 +1039,7 @@ describe('ol.format.GML.v3', function() { 'featureNS': 'http://opengeo.org/#medford', 'featureType': 'zoning' }; - features = new ol.format.GML.v3(config).readFeatures(xml); + features = new ol.format.GML(config).readFeatures(xml); } catch (e) { done(e); } @@ -1060,6 +1060,8 @@ describe('ol.format.GML.v3', function() { goog.require('goog.dom'); goog.require('goog.dom.TagName'); goog.require('ol.format.GML'); +goog.require('ol.format.GML2'); +goog.require('ol.format.GML3'); goog.require('ol.geom.LineString'); goog.require('ol.geom.LinearRing'); goog.require('ol.geom.MultiPoint'); diff --git a/test/spec/ol/format/wfsformat.test.js b/test/spec/ol/format/wfsformat.test.js index 6beb04c78a..33e8242c53 100644 --- a/test/spec/ol/format/wfsformat.test.js +++ b/test/spec/ol/format/wfsformat.test.js @@ -56,7 +56,7 @@ describe('ol.format.WFS', function() { var config = { 'featureNS': 'http://mapserver.gis.umn.edu/mapserver', 'featureType': 'polygon', - 'gmlFormat': new ol.format.GML.v2() + 'gmlFormat': new ol.format.GML2() }; before(function(done) { @@ -440,7 +440,6 @@ goog.require('ol.geom.MultiLineString'); goog.require('ol.geom.MultiPoint'); goog.require('ol.geom.MultiPolygon'); goog.require('ol.geom.Polygon'); -goog.require('ol.format.GML'); -goog.require('ol.format.GML.v2'); +goog.require('ol.format.GML2'); goog.require('ol.format.WFS'); goog.require('ol.proj');