1
|
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
2
|
* full list of contributors). Published under the 2-clause BSD license.
|
3
|
* See license.txt in the OpenLayers distribution or repository for the
|
4
|
* full text of the license. */
|
5
|
|
6
|
/**
|
7
|
* @requires OpenLayers/Format/WMC/v1.js
|
8
|
*/
|
9
|
|
10
|
/**
|
11
|
* Class: OpenLayers.Format.WMC.v1_1_0
|
12
|
* Read and write WMC version 1.1.0.
|
13
|
*
|
14
|
* Differences between 1.1.0 and 1.0.0:
|
15
|
* - 1.1.0 Layers have optional sld:MinScaleDenominator and
|
16
|
* sld:MaxScaleDenominator
|
17
|
*
|
18
|
* Inherits from:
|
19
|
* - <OpenLayers.Format.WMC.v1>
|
20
|
*/
|
21
|
OpenLayers.Format.WMC.v1_1_0 = OpenLayers.Class(
|
22
|
OpenLayers.Format.WMC.v1, {
|
23
|
|
24
|
/**
|
25
|
* Constant: VERSION
|
26
|
* {String} 1.1.0
|
27
|
*/
|
28
|
VERSION: "1.1.0",
|
29
|
|
30
|
/**
|
31
|
* Property: schemaLocation
|
32
|
* {String} http://www.opengis.net/context
|
33
|
* http://schemas.opengis.net/context/1.1.0/context.xsd
|
34
|
*/
|
35
|
schemaLocation: "http://www.opengis.net/context http://schemas.opengis.net/context/1.1.0/context.xsd",
|
36
|
|
37
|
/**
|
38
|
* Constructor: OpenLayers.Format.WMC.v1_1_0
|
39
|
* Instances of this class are not created directly. Use the
|
40
|
* <OpenLayers.Format.WMC> constructor instead.
|
41
|
*
|
42
|
* Parameters:
|
43
|
* options - {Object} An optional object whose properties will be set on
|
44
|
* this instance.
|
45
|
*/
|
46
|
initialize: function(options) {
|
47
|
OpenLayers.Format.WMC.v1.prototype.initialize.apply(
|
48
|
this, [options]
|
49
|
);
|
50
|
},
|
51
|
|
52
|
/**
|
53
|
* Method: read_sld_MinScaleDenominator
|
54
|
* Read a sld:MinScaleDenominator node.
|
55
|
*
|
56
|
* Parameters:
|
57
|
* layerContext - {Object} An object representing a layer.
|
58
|
* node - {Element} An element node.
|
59
|
*/
|
60
|
read_sld_MinScaleDenominator: function(layerContext, node) {
|
61
|
var minScaleDenominator = parseFloat(this.getChildValue(node));
|
62
|
if (minScaleDenominator > 0) {
|
63
|
layerContext.maxScale = minScaleDenominator;
|
64
|
}
|
65
|
},
|
66
|
|
67
|
/**
|
68
|
* Method: read_sld_MaxScaleDenominator
|
69
|
* Read a sld:MaxScaleDenominator node.
|
70
|
*
|
71
|
* Parameters:
|
72
|
* layerContext - {Object} An object representing a layer.
|
73
|
* node - {Element} An element node.
|
74
|
*/
|
75
|
read_sld_MaxScaleDenominator: function(layerContext, node) {
|
76
|
layerContext.minScale = parseFloat(this.getChildValue(node));
|
77
|
},
|
78
|
|
79
|
/**
|
80
|
* Method: read_wmc_SRS
|
81
|
*/
|
82
|
read_wmc_SRS: function(layerContext, node) {
|
83
|
if (! ("srs" in layerContext)) {
|
84
|
layerContext.srs = {};
|
85
|
}
|
86
|
layerContext.srs[this.getChildValue(node)] = true;
|
87
|
},
|
88
|
|
89
|
/**
|
90
|
* Method: write_wmc_Layer
|
91
|
* Create a Layer node given a layer context object. This method adds
|
92
|
* elements specific to version 1.1.0.
|
93
|
*
|
94
|
* Parameters:
|
95
|
* context - {Object} A layer context object.}
|
96
|
*
|
97
|
* Returns:
|
98
|
* {Element} A WMC Layer element node.
|
99
|
*/
|
100
|
write_wmc_Layer: function(context) {
|
101
|
var node = OpenLayers.Format.WMC.v1.prototype.write_wmc_Layer.apply(
|
102
|
this, [context]
|
103
|
);
|
104
|
|
105
|
// min/max scale denominator elements go before the 4th element in v1
|
106
|
if(context.maxScale) {
|
107
|
var minSD = this.createElementNS(
|
108
|
this.namespaces.sld, "sld:MinScaleDenominator"
|
109
|
);
|
110
|
minSD.appendChild(this.createTextNode(context.maxScale.toPrecision(16)));
|
111
|
node.appendChild(minSD);
|
112
|
}
|
113
|
|
114
|
if(context.minScale) {
|
115
|
var maxSD = this.createElementNS(
|
116
|
this.namespaces.sld, "sld:MaxScaleDenominator"
|
117
|
);
|
118
|
maxSD.appendChild(this.createTextNode(context.minScale.toPrecision(16)));
|
119
|
node.appendChild(maxSD);
|
120
|
}
|
121
|
|
122
|
// optional SRS element(s)
|
123
|
if (context.srs) {
|
124
|
for(var name in context.srs) {
|
125
|
node.appendChild(this.createElementDefaultNS("SRS", name));
|
126
|
}
|
127
|
}
|
128
|
|
129
|
// optional FormatList element
|
130
|
node.appendChild(this.write_wmc_FormatList(context));
|
131
|
|
132
|
// optional StyleList element
|
133
|
node.appendChild(this.write_wmc_StyleList(context));
|
134
|
|
135
|
// optional DimensionList element
|
136
|
if (context.dimensions) {
|
137
|
node.appendChild(this.write_wmc_DimensionList(context));
|
138
|
}
|
139
|
|
140
|
// OpenLayers specific properties go in an Extension element
|
141
|
node.appendChild(this.write_wmc_LayerExtension(context));
|
142
|
|
143
|
return node;
|
144
|
|
145
|
},
|
146
|
|
147
|
CLASS_NAME: "OpenLayers.Format.WMC.v1_1_0"
|
148
|
|
149
|
});
|