1 | /* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for |
---|
2 | * full list of contributors). Published under the Clear BSD license. |
---|
3 | * See http://svn.openlayers.org/trunk/openlayers/license.txt for the |
---|
4 | * full text of the license. */ |
---|
5 | |
---|
6 | /** |
---|
7 | * @requires OpenLayers/Format/WMSCapabilities/v1.js |
---|
8 | */ |
---|
9 | |
---|
10 | /** |
---|
11 | * Class: OpenLayers.Format.WMSCapabilities/v1_3 |
---|
12 | * Abstract base class for WMS Capabilities version 1.3.X. |
---|
13 | * SLD 1.1.0 adds in the extra operations DescribeLayer and GetLegendGraphic, |
---|
14 | * see: http://schemas.opengis.net/sld/1.1.0/sld_capabilities.xsd |
---|
15 | * |
---|
16 | * Inherits from: |
---|
17 | * - <OpenLayers.Format.WMSCapabilities.v1> |
---|
18 | */ |
---|
19 | OpenLayers.Format.WMSCapabilities.v1_3 = OpenLayers.Class( |
---|
20 | OpenLayers.Format.WMSCapabilities.v1, { |
---|
21 | |
---|
22 | /** |
---|
23 | * Property: readers |
---|
24 | * Contains public functions, grouped by namespace prefix, that will |
---|
25 | * be applied when a namespaced node is found matching the function |
---|
26 | * name. The function will be applied in the scope of this parser |
---|
27 | * with two arguments: the node being read and a context object passed |
---|
28 | * from the parent. |
---|
29 | */ |
---|
30 | readers: { |
---|
31 | "wms": OpenLayers.Util.applyDefaults({ |
---|
32 | "WMS_Capabilities": function(node, obj) { |
---|
33 | this.readChildNodes(node, obj); |
---|
34 | }, |
---|
35 | "LayerLimit": function(node, obj) { |
---|
36 | obj.layerLimit = parseInt(this.getChildValue(node)); |
---|
37 | }, |
---|
38 | "MaxWidth": function(node, obj) { |
---|
39 | obj.maxWidth = parseInt(this.getChildValue(node)); |
---|
40 | }, |
---|
41 | "MaxHeight": function(node, obj) { |
---|
42 | obj.maxHeight = parseInt(this.getChildValue(node)); |
---|
43 | }, |
---|
44 | "BoundingBox": function(node, obj) { |
---|
45 | var bbox = OpenLayers.Format.WMSCapabilities.v1.prototype.readers["wms"].BoundingBox.apply(this, [node, obj]); |
---|
46 | bbox.srs = node.getAttribute("CRS"); |
---|
47 | obj.bbox[bbox.srs] = bbox; |
---|
48 | }, |
---|
49 | "CRS": function(node, obj) { |
---|
50 | // CRS is the synonym of SRS |
---|
51 | this.readers.wms.SRS.apply(this, [node, obj]); |
---|
52 | }, |
---|
53 | "EX_GeographicBoundingBox": function(node, obj) { |
---|
54 | // replacement of LatLonBoundingBox |
---|
55 | obj.llbbox = []; |
---|
56 | this.readChildNodes(node, obj.llbbox); |
---|
57 | |
---|
58 | }, |
---|
59 | "westBoundLongitude": function(node, obj) { |
---|
60 | obj[0] = this.getChildValue(node); |
---|
61 | }, |
---|
62 | "eastBoundLongitude": function(node, obj) { |
---|
63 | obj[2] = this.getChildValue(node); |
---|
64 | }, |
---|
65 | "southBoundLatitude": function(node, obj) { |
---|
66 | obj[1] = this.getChildValue(node); |
---|
67 | }, |
---|
68 | "northBoundLatitude": function(node, obj) { |
---|
69 | obj[3] = this.getChildValue(node); |
---|
70 | }, |
---|
71 | "MinScaleDenominator": function(node, obj) { |
---|
72 | obj.maxScale = parseFloat(this.getChildValue(node)).toPrecision(16); |
---|
73 | }, |
---|
74 | "MaxScaleDenominator": function(node, obj) { |
---|
75 | obj.minScale = parseFloat(this.getChildValue(node)).toPrecision(16); |
---|
76 | }, |
---|
77 | "Dimension": function(node, obj) { |
---|
78 | // dimension has extra attributes: default, multipleValues, |
---|
79 | // nearestValue, current which used to be part of Extent. It now |
---|
80 | // also contains the values. |
---|
81 | var name = node.getAttribute("name").toLowerCase(); |
---|
82 | var dim = { |
---|
83 | name: name, |
---|
84 | units: node.getAttribute("units"), |
---|
85 | unitsymbol: node.getAttribute("unitSymbol"), |
---|
86 | nearestVal: node.getAttribute("nearestValue") === "1", |
---|
87 | multipleVal: node.getAttribute("multipleValues") === "1", |
---|
88 | "default": node.getAttribute("default") || "", |
---|
89 | current: node.getAttribute("current") === "1", |
---|
90 | values: this.getChildValue(node).split(",") |
---|
91 | |
---|
92 | }; |
---|
93 | // Theoretically there can be more dimensions with the same |
---|
94 | // name, but with a different unit. Until we meet such a case, |
---|
95 | // let's just keep the same structure as the WMS 1.1 |
---|
96 | // GetCapabilities parser uses. We will store the last |
---|
97 | // one encountered. |
---|
98 | obj.dimensions[dim.name] = dim; |
---|
99 | }, |
---|
100 | "Keyword": function(node, obj) { |
---|
101 | // TODO: should we change the structure of keyword in v1.js? |
---|
102 | // Make it an object with a value instead of a string? |
---|
103 | var keyword = {value: this.getChildValue(node), |
---|
104 | vocabulary: node.getAttribute("vocabulary")}; |
---|
105 | if (obj.keywords) { |
---|
106 | obj.keywords.push(keyword); |
---|
107 | } |
---|
108 | } |
---|
109 | }, OpenLayers.Format.WMSCapabilities.v1.prototype.readers["wms"]), |
---|
110 | "sld": { |
---|
111 | "UserDefinedSymbolization": function(node, obj) { |
---|
112 | this.readers.wms.UserDefinedSymbolization.apply(this, [node, obj]); |
---|
113 | // add the two extra attributes |
---|
114 | obj.userSymbols.inlineFeature = parseInt(node.getAttribute("InlineFeature")) == 1; |
---|
115 | obj.userSymbols.remoteWCS = parseInt(node.getAttribute("RemoteWCS")) == 1; |
---|
116 | }, |
---|
117 | "DescribeLayer": function(node, obj) { |
---|
118 | this.readers.wms.DescribeLayer.apply(this, [node, obj]); |
---|
119 | }, |
---|
120 | "GetLegendGraphic": function(node, obj) { |
---|
121 | this.readers.wms.GetLegendGraphic.apply(this, [node, obj]); |
---|
122 | } |
---|
123 | } |
---|
124 | }, |
---|
125 | |
---|
126 | CLASS_NAME: "OpenLayers.Format.WMSCapabilities.v1_3" |
---|
127 | |
---|
128 | }); |
---|