/* Copyright (c) 2006-2008 MetaCarta, Inc., 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/WMC/v1.js
 */

/**
 * Class: OpenLayers.Format.WMC.v1_1_0
 * Read and write WMC version 1.1.0.
 *
 * Differences between 1.1.0 and 1.0.0:
 *     - 1.1.0 Layers have optional sld:MinScaleDenominator and
 *       sld:MaxScaleDenominator
 * 
 * Inherits from:
 *  - <OpenLayers.Format.WMC.v1>
 */
OpenLayers.Format.WMC.v1_1_0g = OpenLayers.Class(
    OpenLayers.Format.WMC.v1, {
    
    /**
     * Constant: VERSION
     * {String} 1.1.0
     */
    VERSION: "1.1.0g",

    /**
     * Property: schemaLocation
     * {String} http://www.opengis.net/context
     *     http://schemas.opengis.net/context/1.1.0/context.xsd
     */
    //schemaLocation: "http://www.opengis.net/context http://schemas.opengis.net/context/1.1.0/context.xsd",

    /**
     * Constructor: OpenLayers.Format.WMC.v1_1_0
     * Instances of this class are not created directly.  Use the
     *     <OpenLayers.Format.WMC> constructor instead.
     *
     * Parameters:
     * options - {Object} An optional object whose properties will be set on
     *     this instance.
     */
    initialize: function(options) {
        OpenLayers.Format.WMC.v1.prototype.initialize.apply(
            this, [options]
        );
    },
    
    /**
     * Method: read_ol_groupDisplayLayerSwitcher
     */
     read_ol_groupDisplayLayerSwitcher: function(layerInfo, node) {           
           layerInfo.options.groupDisplayLayerSwitcher =
             (this.getChildValue(node));
     },
     
     /**
      * Method: write_wmc_LayerExtension
      * Add OpenLayers specific layer parameters to an Extension element.
      *
      * Parameters:
      * layer - {<OpenLayers.Layer.WMS>} A WMS layer.
      *
      * Returns:
      * {Element} A WMC Extension element (for a layer).
      */
     write_wmc_LayerExtension: function(layer) {
         var node = this.createElementDefaultNS("Extension");
         
         var bounds = layer.maxExtent;
         var maxExtent = this.createElementNS(
             this.namespaces.ol, "ol:maxExtent"
         );
         this.setAttributes(maxExtent, {
             minx: bounds.left.toPrecision(10),
             miny: bounds.bottom.toPrecision(10),
             maxx: bounds.right.toPrecision(10),
             maxy: bounds.top.toPrecision(10)
         });
         node.appendChild(maxExtent);
         
         var param = layer.params["TRANSPARENT"];
         if(param) {
             var trans = this.createElementNS(
                 this.namespaces.ol, "ol:transparent"
             );
             trans.appendChild(this.createTextNode(param));
             node.appendChild(trans);
         }
         
         var properties = [
             "numZoomLevels", "units", "isBaseLayer",
             "opacity", "displayInLayerSwitcher", "singleTile", "groupDisplayLayerSwitcher"
         ];
         var child;
         for(var i=0, len=properties.length; i<len; ++i) {
             child = this.createOLPropertyNode(layer, properties[i]);
             if(child) {
                 node.appendChild(child);
             }
         }

         return node;
     },
     
    CLASS_NAME: "OpenLayers.Format.WMC.v1_1_0g" 

});

