~dongpo-deng/sahana-eden/test

« back to all changes in this revision

Viewing changes to static/scripts/gis/openlayers/lib/OpenLayers/Format/WMC/v1_1_0.js

  • Committer: Deng Dongpo
  • Date: 2010-08-01 09:29:44 UTC
  • Revision ID: dongpo@dhcp-21193.iis.sinica.edu.tw-20100801092944-8t9obt4xtl7otesb
initial

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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. */
 
4
 
 
5
/**
 
6
 * @requires OpenLayers/Format/WMC/v1.js
 
7
 */
 
8
 
 
9
/**
 
10
 * Class: OpenLayers.Format.WMC.v1_1_0
 
11
 * Read and write WMC version 1.1.0.
 
12
 *
 
13
 * Differences between 1.1.0 and 1.0.0:
 
14
 *     - 1.1.0 Layers have optional sld:MinScaleDenominator and
 
15
 *       sld:MaxScaleDenominator
 
16
 * 
 
17
 * Inherits from:
 
18
 *  - <OpenLayers.Format.WMC.v1>
 
19
 */
 
20
OpenLayers.Format.WMC.v1_1_0 = OpenLayers.Class(
 
21
    OpenLayers.Format.WMC.v1, {
 
22
    
 
23
    /**
 
24
     * Constant: VERSION
 
25
     * {String} 1.1.0
 
26
     */
 
27
    VERSION: "1.1.0",
 
28
 
 
29
    /**
 
30
     * Property: schemaLocation
 
31
     * {String} http://www.opengis.net/context
 
32
     *     http://schemas.opengis.net/context/1.1.0/context.xsd
 
33
     */
 
34
    schemaLocation: "http://www.opengis.net/context http://schemas.opengis.net/context/1.1.0/context.xsd",
 
35
 
 
36
    /**
 
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.
 
40
     *
 
41
     * Parameters:
 
42
     * options - {Object} An optional object whose properties will be set on
 
43
     *     this instance.
 
44
     */
 
45
    initialize: function(options) {
 
46
        OpenLayers.Format.WMC.v1.prototype.initialize.apply(
 
47
            this, [options]
 
48
        );
 
49
    },
 
50
 
 
51
    /**
 
52
     * Method: read_sld_MinScaleDenominator
 
53
     * Read a sld:MinScaleDenominator node.
 
54
     *
 
55
     * Parameters:
 
56
     * layerContext - {Object} An object representing a layer.
 
57
     * node - {Element} An element node.
 
58
     */
 
59
    read_sld_MinScaleDenominator: function(layerContext, node) {
 
60
        var minScaleDenominator = parseFloat(this.getChildValue(node));
 
61
        if (minScaleDenominator > 0) {
 
62
            layerContext.maxScale = minScaleDenominator;
 
63
        }
 
64
    },
 
65
 
 
66
    /**
 
67
     * Method: read_sld_MaxScaleDenominator
 
68
     * Read a sld:MaxScaleDenominator node.
 
69
     *
 
70
     * Parameters:
 
71
     * layerContext - {Object} An object representing a layer.
 
72
     * node - {Element} An element node.
 
73
     */
 
74
    read_sld_MaxScaleDenominator: function(layerContext, node) {
 
75
        layerContext.minScale = parseFloat(this.getChildValue(node));
 
76
    },
 
77
 
 
78
    /**
 
79
     * Method: write_wmc_Layer
 
80
     * Create a Layer node given a layer context object. This method adds
 
81
     *     elements specific to version 1.1.0.
 
82
     *
 
83
     * Parameters:
 
84
     * context - {Object} A layer context object.}
 
85
     *
 
86
     * Returns:
 
87
     * {Element} A WMC Layer element node.
 
88
     */
 
89
    write_wmc_Layer: function(context) {
 
90
        var node = OpenLayers.Format.WMC.v1.prototype.write_wmc_Layer.apply(
 
91
            this, [context]
 
92
        );
 
93
        
 
94
        // min/max scale denominator elements go before the 4th element in v1
 
95
        if(context.maxScale) {
 
96
            var minSD = this.createElementNS(
 
97
                this.namespaces.sld, "sld:MinScaleDenominator"
 
98
            );
 
99
            minSD.appendChild(this.createTextNode(context.maxScale.toPrecision(16)));
 
100
            node.appendChild(minSD);
 
101
        }
 
102
        
 
103
        if(context.minScale) {
 
104
            var maxSD = this.createElementNS(
 
105
                this.namespaces.sld, "sld:MaxScaleDenominator"
 
106
            );
 
107
            maxSD.appendChild(this.createTextNode(context.minScale.toPrecision(16)));
 
108
            node.appendChild(maxSD);
 
109
        }
 
110
 
 
111
        // optional FormatList element
 
112
        node.appendChild(this.write_wmc_FormatList(context));
 
113
 
 
114
        // optional StyleList element
 
115
        node.appendChild(this.write_wmc_StyleList(context));
 
116
        
 
117
        // OpenLayers specific properties go in an Extension element
 
118
        node.appendChild(this.write_wmc_LayerExtension(context));
 
119
        
 
120
        return node;
 
121
        
 
122
    },
 
123
 
 
124
    CLASS_NAME: "OpenLayers.Format.WMC.v1_1_0" 
 
125
 
 
126
});