1 /* Copyright (c) 2006-2008 MetaCarta, Inc., published under the Clear BSD
2 * license. See http://svn.openlayers.org/trunk/openlayers/license.txt for the
3 * full text of the license. */
6 * @requires OpenLayers/Format/WMC/v1.js
10 * Class: OpenLayers.Format.WMC.v1_1_0
11 * Read and write WMC version 1.1.0.
13 * Differences between 1.1.0 and 1.0.0:
14 * - 1.1.0 Layers have optional sld:MinScaleDenominator and
15 * sld:MaxScaleDenominator
18 * - <OpenLayers.Format.WMC.v1>
20 OpenLayers.Format.WMC.v1_1_0 = OpenLayers.Class(
21 OpenLayers.Format.WMC.v1, {
30 * Property: schemaLocation
31 * {String} http://www.opengis.net/context
32 * http://schemas.opengis.net/context/1.1.0/context.xsd
34 schemaLocation: "http://www.opengis.net/context http://schemas.opengis.net/context/1.1.0/context.xsd",
37 * Constructor: OpenLayers.Format.WMC.v1_1_0
38 * Instances of this class are not created directly. Use the
39 * <OpenLayers.Format.WMC> constructor instead.
42 * options - {Object} An optional object whose properties will be set on
45 initialize: function(options) {
46 OpenLayers.Format.WMC.v1.prototype.initialize.apply(
52 * Method: read_sld_MinScaleDenominator
53 * Read a sld:MinScaleDenominator node.
56 * layerInfo - {Object} An object representing a layer.
57 * node - {Element} An element node.
59 read_sld_MinScaleDenominator: function(layerInfo, node) {
60 layerInfo.options.maxScale = this.getChildValue(node);
64 * Method: read_sld_MaxScaleDenominator
65 * Read a sld:MaxScaleDenominator node.
68 * layerInfo - {Object} An object representing a layer.
69 * node - {Element} An element node.
71 read_sld_MaxScaleDenominator: function(layerInfo, node) {
72 layerInfo.options.minScale = this.getChildValue(node);
76 * Method: write_wmc_Layer
77 * Create a Layer node given a layer object. This method adds elements
78 * specific to version 1.1.0.
81 * layer - {<OpenLayers.Layer.WMS>} Layer object.
84 * {Element} A WMC Layer element node.
86 write_wmc_Layer: function(layer) {
87 var node = OpenLayers.Format.WMC.v1.prototype.write_wmc_Layer.apply(
91 // min/max scale denominator elements go before the 4th element in v1
92 if(layer.options.resolutions || layer.options.scales ||
93 layer.options.minResolution || layer.options.maxScale) {
94 var minSD = this.createElementNS(
95 this.namespaces.sld, "sld:MinScaleDenominator"
97 minSD.appendChild(this.createTextNode(layer.maxScale.toPrecision(10)));
98 node.insertBefore(minSD, node.childNodes[3]);
101 if(layer.options.resolutions || layer.options.scales ||
102 layer.options.maxResolution || layer.options.minScale) {
103 var maxSD = this.createElementNS(
104 this.namespaces.sld, "sld:MaxScaleDenominator"
106 maxSD.appendChild(this.createTextNode(layer.minScale.toPrecision(10)));
107 node.insertBefore(maxSD, node.childNodes[4]);
114 CLASS_NAME: "OpenLayers.Format.WMC.v1_1_0"