/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for * full list of contributors). Published under the Clear BSD license. * See http://svn.openlayers.org/trunk/openlayers/license.txt for the * full text of the license. */ /** * @requires OpenLayers/Format/WMSCapabilities.js * @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 0) { layer.prefix = parts[0]; } } }, "Attribution": function(node, obj) { obj.attribution = {}; this.readChildNodes(node, obj.attribution); }, "LogoURL": function(node, obj) { obj.logo = { width: node.getAttribute("width"), height: node.getAttribute("height") }; this.readChildNodes(node, obj.logo); }, "Style": function(node, obj) { var style = {}; obj.styles.push(style); this.readChildNodes(node, style); }, "LegendURL": function(node, obj) { var legend = { width: node.getAttribute("width"), height: node.getAttribute("height") }; obj.legend = legend; this.readChildNodes(node, legend); }, "MetadataURL": function(node, obj) { var metadataURL = {type: node.getAttribute("type")}; obj.metadataURLs.push(metadataURL); this.readChildNodes(node, metadataURL); }, "DataURL": function(node, obj) { obj.dataURL = {}; this.readChildNodes(node, obj.dataURL); }, "FeatureListURL": function(node, obj) { obj.featureListURL = {}; this.readChildNodes(node, obj.featureListURL); }, "AuthorityURL": function(node, obj) { var name = node.getAttribute("name"); var authority = {}; this.readChildNodes(node, authority); obj.authorityURLs[name] = authority.href; }, "Identifier": function(node, obj) { var authority = node.getAttribute("authority"); obj.identifiers[authority] = this.getChildValue(node); }, "KeywordList": function(node, obj) { this.readChildNodes(node, obj); }, "SRS": function(node, obj) { obj.srs[this.getChildValue(node)] = true; } } }, CLASS_NAME: "OpenLayers.Format.WMSCapabilities.v1" });