diff --git a/lib/OpenLayers.js b/lib/OpenLayers.js index 4ced6f3020..6cc0e35767 100644 --- a/lib/OpenLayers.js +++ b/lib/OpenLayers.js @@ -257,9 +257,12 @@ "OpenLayers/Format/WMC/v1_0_0.js", "OpenLayers/Format/WMC/v1_1_0.js", "OpenLayers/Format/WMSCapabilities.js", + "OpenLayers/Format/WMSCapabilities/v1.js", "OpenLayers/Format/WMSCapabilities/v1_1.js", "OpenLayers/Format/WMSCapabilities/v1_1_0.js", "OpenLayers/Format/WMSCapabilities/v1_1_1.js", + "OpenLayers/Format/WMSCapabilities/v1_3.js", + "OpenLayers/Format/WMSCapabilities/v1_3_0.js", "OpenLayers/Format/WMSGetFeatureInfo.js", "OpenLayers/Layer/WFS.js", "OpenLayers/Control/GetFeature.js", diff --git a/lib/OpenLayers/Format/WMSCapabilities/v1.js b/lib/OpenLayers/Format/WMSCapabilities/v1.js new file mode 100644 index 0000000000..855d6de447 --- /dev/null +++ b/lib/OpenLayers/Format/WMSCapabilities/v1.js @@ -0,0 +1,406 @@ +/** + * @requires OpenLayers/Format/XML.js + */ + +/** + * Class: OpenLayers.Format.WMSCapabilities.v1 + * Abstract class not to be instantiated directly. Creates + * the common parts for both WMS 1.1.X and WMS 1.3.X. + * + * Inherits from: + * - + */ +OpenLayers.Format.WMSCapabilities.v1 = OpenLayers.Class( + OpenLayers.Format.XML, { + + /** + * Property: namespaces + * {Object} Mapping of namespace aliases to namespace URIs. + */ + namespaces: { + wms: "http://www.opengis.net/wms", + xlink: "http://www.w3.org/1999/xlink", + xsi: "http://www.w3.org/2001/XMLSchema-instance" + }, + + /** + * Property: defaultPrefix + */ + defaultPrefix: "wms", + + /** + * Constructor: OpenLayers.Format.WMSCapabilities.v1 + * Create an instance of one of the subclasses. + * + * Parameters: + * options - {Object} An optional object whose properties will be set on + * this instance. + */ + initialize: function(options) { + OpenLayers.Format.XML.prototype.initialize.apply(this, [options]); + }, + + /** + * APIMethod: read + * Read capabilities data from a string, and return a list of layers. + * + * Parameters: + * data - {String} or {DOMElement} data to read/parse. + * + * Returns: + * {Array} List of named layers. + */ + read: function(data) { + if(typeof data == "string") { + data = OpenLayers.Format.XML.prototype.read.apply(this, [data]); + } + if(data && data.nodeType == 9) { + data = data.documentElement; + } + var capabilities = {}; + this.readNode(data, capabilities); + + // postprocess the layer list + this.postProcessLayers(capabilities); + + return capabilities; + }, + + /** + * Method: postProcessLayers + * Post process the layers, so that the nested layer structure is converted + * to a flat layer list with only named layers. + * + * Parameters: + * capabilities - {Object} The object (structure) returned by the parser with + * all the info from the GetCapabilities response. + */ + postProcessLayers: function(capabilities) { + if (capabilities.capability) { + capabilities.capability.layers = []; + var layers = capabilities.capability.nestedLayers; + for (var i=0, len = layers.length; i + * - */ OpenLayers.Format.WMSCapabilities.v1_1 = OpenLayers.Class( - OpenLayers.Format.XML, { - - /** - * Property: namespaces - * {Object} Mapping of namespace aliases to namespace URIs. - */ - namespaces: { - wms: "http://www.opengis.net/wms", - xlink: "http://www.w3.org/1999/xlink", - xsi: "http://www.w3.org/2001/XMLSchema-instance" - }, - - /** - * Property: defaultPrefix - */ - defaultPrefix: "wms", - - /** - * Constructor: OpenLayers.Format.WMSCapabilities.v1_1 - * Create an instance of one of the subclasses. - * - * Parameters: - * options - {Object} An optional object whose properties will be set on - * this instance. - */ - initialize: function(options) { - OpenLayers.Format.XML.prototype.initialize.apply(this, [options]); - }, - - /** - * APIMethod: read - * Read capabilities data from a string, and return a list of layers. - * - * Parameters: - * data - {String} or {DOMElement} data to read/parse. - * - * Returns: - * {Array} List of named layers. - */ - read: function(data) { - if(typeof data == "string") { - data = OpenLayers.Format.XML.prototype.read.apply(this, [data]); - } - if(data && data.nodeType == 9) { - data = data.documentElement; - } - var capabilities = {}; - this.readNode(data, capabilities); - - // postprocess the layer list - this.postProcessLayers(capabilities); - - return capabilities; - }, - - /** - * Method: postProcessLayers - * Post process the layers, so that the nested layer structure is converted - * to a flat layer list with only named layers. - * - * Parameters: - * capabilities - {Object} The object (structure) returned by the parser with - * all the info from the GetCapabilities response. - */ - postProcessLayers: function(capabilities) { - if (capabilities.capability) { - capabilities.capability.layers = []; - var layers = capabilities.capability.nestedLayers; - for (var i=0, len = layers.length; i + */ +OpenLayers.Format.WMSCapabilities.v1_3 = OpenLayers.Class( + OpenLayers.Format.WMSCapabilities.v1, { + + /** + * Property: readers + * Contains public functions, grouped by namespace prefix, that will + * be applied when a namespaced node is found matching the function + * name. The function will be applied in the scope of this parser + * with two arguments: the node being read and a context object passed + * from the parent. + */ + readers: { + "wms": OpenLayers.Util.applyDefaults({ + "WMS_Capabilities": function(node, obj) { + this.readChildNodes(node, obj); + }, + "LayerLimit": function(node, obj) { + obj.layerLimit = parseInt(this.getChildValue(node)); + }, + "MaxWidth": function(node, obj) { + obj.maxWidth = parseInt(this.getChildValue(node)); + }, + "MaxHeight": function(node, obj) { + obj.maxHeight = parseInt(this.getChildValue(node)); + }, + "BoundingBox": function(node, obj) { + var bbox = OpenLayers.Format.WMSCapabilities.v1.prototype.readers["wms"].BoundingBox.apply(this, [node, obj]); + bbox.srs = node.getAttribute("CRS"); + obj.bbox[bbox.srs] = bbox; + }, + "CRS": function(node, obj) { + // CRS is the synonym of SRS + this.readers.wms.SRS.apply(this, [node, obj]); + }, + "EX_GeographicBoundingBox": function(node, obj) { + // replacement of LatLonBoundingBox + obj.llbbox = []; + this.readChildNodes(node, obj.llbbox); + + }, + "westBoundLongitude": function(node, obj) { + obj[0] = this.getChildValue(node); + }, + "eastBoundLongitude": function(node, obj) { + obj[2] = this.getChildValue(node); + }, + "southBoundLatitude": function(node, obj) { + obj[1] = this.getChildValue(node); + }, + "northBoundLatitude": function(node, obj) { + obj[3] = this.getChildValue(node); + }, + "MinScaleDenominator": function(node, obj) { + obj.maxScale = parseFloat(this.getChildValue(node)).toPrecision(16); + }, + "MaxScaleDenominator": function(node, obj) { + obj.minScale = parseFloat(this.getChildValue(node)).toPrecision(16); + }, + "Dimension": function(node, obj) { + // dimension has extra attributes: default, multipleValues, + // nearestValue, current which used to be part of Extent. It now + // also contains the values. + var name = node.getAttribute("name").toLowerCase(); + var dim = { + name: name, + units: node.getAttribute("units"), + unitsymbol: node.getAttribute("unitSymbol"), + nearestVal: node.getAttribute("nearestValue") === "1", + multipleVal: node.getAttribute("multipleValues") === "1", + "default": node.getAttribute("default") || "", + current: node.getAttribute("current") === "1", + values: this.getChildValue(node).split(",") + + }; + // Theoretically there can be more dimensions with the same + // name, but with a different unit. Until we meet such a case, + // let's just keep the same structure as the WMS 1.1 + // GetCapabilities parser uses. We will store the last + // one encountered. + obj.dimensions[dim.name] = dim; + }, + "Keyword": function(node, obj) { + // TODO: should we change the structure of keyword in v1.js? + // Make it an object with a value instead of a string? + var keyword = {value: this.getChildValue(node), + vocabulary: node.getAttribute("vocabulary")}; + if (obj.keywords) { + obj.keywords.push(keyword); + } + } + }, OpenLayers.Format.WMSCapabilities.v1.prototype.readers["wms"]), + "sld": { + "UserDefinedSymbolization": function(node, obj) { + this.readers.wms.UserDefinedSymbolization.apply(this, [node, obj]); + // add the two extra attributes + obj.userSymbols.inlineFeature = parseInt(node.getAttribute("InlineFeature")) == 1; + obj.userSymbols.remoteWCS = parseInt(node.getAttribute("RemoteWCS")) == 1; + }, + "DescribeLayer": function(node, obj) { + this.readers.wms.DescribeLayer.apply(this, [node, obj]); + }, + "GetLegendGraphic": function(node, obj) { + this.readers.wms.GetLegendGraphic.apply(this, [node, obj]); + } + } + }, + + CLASS_NAME: "OpenLayers.Format.WMSCapabilities.v1_3" + +}); diff --git a/lib/OpenLayers/Format/WMSCapabilities/v1_3_0.js b/lib/OpenLayers/Format/WMSCapabilities/v1_3_0.js new file mode 100644 index 0000000000..5b4059923c --- /dev/null +++ b/lib/OpenLayers/Format/WMSCapabilities/v1_3_0.js @@ -0,0 +1,25 @@ +/** + * @requires OpenLayers/Format/WMSCapabilities/v1_3.js + */ + +/** + * Class: OpenLayers.Format.WMSCapabilities/v1_3_0 + * Read WMS Capabilities version 1.3.0. + * SLD 1.1.0 adds in the extra operations DescribeLayer and GetLegendGraphic, + * see: http://schemas.opengis.net/sld/1.1.0/sld_capabilities.xsd + * + * Inherits from: + * - + */ +OpenLayers.Format.WMSCapabilities.v1_3_0 = OpenLayers.Class( + OpenLayers.Format.WMSCapabilities.v1_3, { + + /** + * Property: version + * {String} The specific parser version. + */ + version: "1.3.0", + + CLASS_NAME: "OpenLayers.Format.WMSCapabilities.v1_3_0" + +}); diff --git a/tests/Format/WMSCapabilities/v1_3_0.html b/tests/Format/WMSCapabilities/v1_3_0.html new file mode 100644 index 0000000000..95f6f4b21b --- /dev/null +++ b/tests/Format/WMSCapabilities/v1_3_0.html @@ -0,0 +1,578 @@ + + + + + + + + +
+ + + diff --git a/tests/list-tests.html b/tests/list-tests.html index 2d4523fa67..d4e0d9ca0a 100644 --- a/tests/list-tests.html +++ b/tests/list-tests.html @@ -78,6 +78,7 @@
  • Format/WMC/v1.html
  • Format/WMSCapabilities.html
  • Format/WMSCapabilities/v1_1_1.html
  • +
  • Format/WMSCapabilities/v1_3_0.html
  • Format/WMSDescribeLayer.html
  • Format/WMSGetFeatureInfo.html
  • Format/CSWGetDomain.html