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/XML.js
|
8
|
* @requires OpenLayers/Format/OWSCommon/v1_1_0.js
|
9
|
*/
|
10
|
|
11
|
/**
|
12
|
* Class: OpenLayers.Format.WPSDescribeProcess
|
13
|
* Read WPS DescribeProcess responses.
|
14
|
*
|
15
|
* Inherits from:
|
16
|
* - <OpenLayers.Format.XML>
|
17
|
*/
|
18
|
OpenLayers.Format.WPSDescribeProcess = OpenLayers.Class(
|
19
|
OpenLayers.Format.XML, {
|
20
|
|
21
|
/**
|
22
|
* Constant: VERSION
|
23
|
* {String} 1.0.0
|
24
|
*/
|
25
|
VERSION: "1.0.0",
|
26
|
|
27
|
/**
|
28
|
* Property: namespaces
|
29
|
* {Object} Mapping of namespace aliases to namespace URIs.
|
30
|
*/
|
31
|
namespaces: {
|
32
|
wps: "http://www.opengis.net/wps/1.0.0",
|
33
|
ows: "http://www.opengis.net/ows/1.1",
|
34
|
xsi: "http://www.w3.org/2001/XMLSchema-instance"
|
35
|
},
|
36
|
|
37
|
/**
|
38
|
* Property: schemaLocation
|
39
|
* {String} Schema location
|
40
|
*/
|
41
|
schemaLocation: "http://www.opengis.net/wps/1.0.0 http://schemas.opengis.net/wps/1.0.0/wpsAll.xsd",
|
42
|
|
43
|
/**
|
44
|
* Property: defaultPrefix
|
45
|
*/
|
46
|
defaultPrefix: "wps",
|
47
|
|
48
|
/**
|
49
|
* Property: regExes
|
50
|
* Compiled regular expressions for manipulating strings.
|
51
|
*/
|
52
|
regExes: {
|
53
|
trimSpace: (/^\s*|\s*$/g),
|
54
|
removeSpace: (/\s*/g),
|
55
|
splitSpace: (/\s+/),
|
56
|
trimComma: (/\s*,\s*/g)
|
57
|
},
|
58
|
|
59
|
/**
|
60
|
* Constructor: OpenLayers.Format.WPSDescribeProcess
|
61
|
*
|
62
|
* Parameters:
|
63
|
* options - {Object} An optional object whose properties will be set on
|
64
|
* this instance.
|
65
|
*/
|
66
|
|
67
|
/**
|
68
|
* APIMethod: read
|
69
|
* Parse a WPS DescribeProcess and return an object with its information.
|
70
|
*
|
71
|
* Parameters:
|
72
|
* data - {String} or {DOMElement} data to read/parse.
|
73
|
*
|
74
|
* Returns:
|
75
|
* {Object}
|
76
|
*/
|
77
|
read: function(data) {
|
78
|
if(typeof data == "string") {
|
79
|
data = OpenLayers.Format.XML.prototype.read.apply(this, [data]);
|
80
|
}
|
81
|
if(data && data.nodeType == 9) {
|
82
|
data = data.documentElement;
|
83
|
}
|
84
|
var info = {};
|
85
|
this.readNode(data, info);
|
86
|
return info;
|
87
|
},
|
88
|
|
89
|
/**
|
90
|
* Property: readers
|
91
|
* Contains public functions, grouped by namespace prefix, that will
|
92
|
* be applied when a namespaced node is found matching the function
|
93
|
* name. The function will be applied in the scope of this parser
|
94
|
* with two arguments: the node being read and a context object passed
|
95
|
* from the parent.
|
96
|
*/
|
97
|
readers: {
|
98
|
"wps": {
|
99
|
"ProcessDescriptions": function(node, obj) {
|
100
|
obj.processDescriptions = {};
|
101
|
this.readChildNodes(node, obj.processDescriptions);
|
102
|
},
|
103
|
"ProcessDescription": function(node, processDescriptions) {
|
104
|
var processVersion = this.getAttributeNS(node, this.namespaces.wps, "processVersion");
|
105
|
var processDescription = {
|
106
|
processVersion: processVersion,
|
107
|
statusSupported: (node.getAttribute("statusSupported") === "true"),
|
108
|
storeSupported: (node.getAttribute("storeSupported") === "true")
|
109
|
};
|
110
|
this.readChildNodes(node, processDescription);
|
111
|
processDescriptions[processDescription.identifier] = processDescription;
|
112
|
},
|
113
|
"DataInputs": function(node, processDescription) {
|
114
|
processDescription.dataInputs = [];
|
115
|
this.readChildNodes(node, processDescription.dataInputs);
|
116
|
},
|
117
|
"ProcessOutputs": function(node, processDescription) {
|
118
|
processDescription.processOutputs = [];
|
119
|
this.readChildNodes(node, processDescription.processOutputs);
|
120
|
},
|
121
|
"Output": function(node, processOutputs) {
|
122
|
var output = {};
|
123
|
this.readChildNodes(node, output);
|
124
|
processOutputs.push(output);
|
125
|
},
|
126
|
"ComplexOutput": function(node, output) {
|
127
|
output.complexOutput = {};
|
128
|
this.readChildNodes(node, output.complexOutput);
|
129
|
},
|
130
|
"LiteralOutput": function(node, output) {
|
131
|
output.literalOutput = {};
|
132
|
this.readChildNodes(node, output.literalOutput);
|
133
|
},
|
134
|
"Input": function(node, dataInputs) {
|
135
|
var input = {
|
136
|
maxOccurs: parseInt(node.getAttribute("maxOccurs")),
|
137
|
minOccurs: parseInt(node.getAttribute("minOccurs"))
|
138
|
};
|
139
|
this.readChildNodes(node, input);
|
140
|
dataInputs.push(input);
|
141
|
},
|
142
|
"BoundingBoxData": function(node, input) {
|
143
|
input.boundingBoxData = {};
|
144
|
this.readChildNodes(node, input.boundingBoxData);
|
145
|
},
|
146
|
"CRS": function(node, obj) {
|
147
|
if (!obj.CRSs) {
|
148
|
obj.CRSs = {};
|
149
|
}
|
150
|
obj.CRSs[this.getChildValue(node)] = true;
|
151
|
},
|
152
|
"LiteralData": function(node, input) {
|
153
|
input.literalData = {};
|
154
|
this.readChildNodes(node, input.literalData);
|
155
|
},
|
156
|
"ComplexData": function(node, input) {
|
157
|
input.complexData = {};
|
158
|
this.readChildNodes(node, input.complexData);
|
159
|
},
|
160
|
"Default": function(node, complexData) {
|
161
|
complexData["default"] = {};
|
162
|
this.readChildNodes(node, complexData["default"]);
|
163
|
},
|
164
|
"Supported": function(node, complexData) {
|
165
|
complexData["supported"] = {};
|
166
|
this.readChildNodes(node, complexData["supported"]);
|
167
|
},
|
168
|
"Format": function(node, obj) {
|
169
|
var format = {};
|
170
|
this.readChildNodes(node, format);
|
171
|
if (!obj.formats) {
|
172
|
obj.formats = {};
|
173
|
}
|
174
|
obj.formats[format.mimeType] = true;
|
175
|
},
|
176
|
"MimeType": function(node, format) {
|
177
|
format.mimeType = this.getChildValue(node);
|
178
|
}
|
179
|
},
|
180
|
"ows": OpenLayers.Format.OWSCommon.v1_1_0.prototype.readers["ows"]
|
181
|
},
|
182
|
|
183
|
CLASS_NAME: "OpenLayers.Format.WPSDescribeProcess"
|
184
|
|
185
|
});
|