1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
|
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
* full list of contributors). Published under the 2-clause BSD license.
* See license.txt in the OpenLayers distribution or repository for the
* full text of the license. */
/**
* @requires OpenLayers/Format/XML.js
* @requires OpenLayers/Format/OWSCommon/v1_1_0.js
* @requires OpenLayers/Format/WCSGetCoverage.js
* @requires OpenLayers/Format/WFST/v1_1_0.js
*/
/**
* Class: OpenLayers.Format.WPSExecute version 1.0.0
*
* Inherits from:
* - <OpenLayers.Format.XML>
*/
OpenLayers.Format.WPSExecute = OpenLayers.Class(OpenLayers.Format.XML,
OpenLayers.Format.Filter.v1_1_0, {
/**
* Property: namespaces
* {Object} Mapping of namespace aliases to namespace URIs.
*/
namespaces: {
ows: "http://www.opengis.net/ows/1.1",
gml: "http://www.opengis.net/gml",
wps: "http://www.opengis.net/wps/1.0.0",
wfs: "http://www.opengis.net/wfs",
ogc: "http://www.opengis.net/ogc",
wcs: "http://www.opengis.net/wcs",
xlink: "http://www.w3.org/1999/xlink",
xsi: "http://www.w3.org/2001/XMLSchema-instance"
},
/**
* Property: regExes
* Compiled regular expressions for manipulating strings.
*/
regExes: {
trimSpace: (/^\s*|\s*$/g),
removeSpace: (/\s*/g),
splitSpace: (/\s+/),
trimComma: (/\s*,\s*/g)
},
/**
* Constant: VERSION
* {String} 1.0.0
*/
VERSION: "1.0.0",
/**
* Property: schemaLocation
* {String} Schema location
*/
schemaLocation: "http://www.opengis.net/wps/1.0.0 http://schemas.opengis.net/wps/1.0.0/wpsAll.xsd",
schemaLocationAttr: function(options) {
return undefined;
},
/**
* Constructor: OpenLayers.Format.WPSExecute
*
* Parameters:
* options - {Object} An optional object whose properties will be set on
* this instance.
*/
/**
* Method: write
*
* Parameters:
* options - {Object} Optional object.
*
* Returns:
* {String} An WPS Execute request XML string.
*/
write: function(options) {
var doc;
if (window.ActiveXObject) {
doc = new ActiveXObject("Microsoft.XMLDOM");
this.xmldom = doc;
} else {
doc = document.implementation.createDocument("", "", null);
}
var node = this.writeNode("wps:Execute", options, doc);
this.setAttributeNS(
node, this.namespaces.xsi,
"xsi:schemaLocation", this.schemaLocation
);
return OpenLayers.Format.XML.prototype.write.apply(this, [node]);
},
/**
* APIMethod: read
* Parse a WPS Execute and return an object with its information.
*
* Parameters:
* data - {String} or {DOMElement} data to read/parse.
*
* Returns:
* {Object}
*/
read: function(data) {
if(typeof data == "string") {
data = OpenLayers.Format.XML.prototype.read.apply(this, [data]);
}
if(data && data.nodeType == 9) {
data = data.documentElement;
}
var info = {};
this.readNode(data, info);
return info;
},
/**
* Property: writers
* As a compliment to the readers property, this structure contains public
* writing functions grouped by namespace alias and named like the
* node names they produce.
*/
writers: {
"wps": {
"Execute": function(options) {
var node = this.createElementNSPlus("wps:Execute", {
attributes: {
version: this.VERSION,
service: 'WPS'
}
});
this.writeNode("ows:Identifier", options.identifier, node);
this.writeNode("wps:DataInputs", options.dataInputs, node);
this.writeNode("wps:ResponseForm", options.responseForm, node);
return node;
},
"ResponseForm": function(responseForm) {
var node = this.createElementNSPlus("wps:ResponseForm", {});
if (responseForm.rawDataOutput) {
this.writeNode("wps:RawDataOutput", responseForm.rawDataOutput, node);
}
if (responseForm.responseDocument) {
this.writeNode("wps:ResponseDocument", responseForm.responseDocument, node);
}
return node;
},
"ResponseDocument": function(responseDocument) {
var node = this.createElementNSPlus("wps:ResponseDocument", {
attributes: {
storeExecuteResponse: responseDocument.storeExecuteResponse,
lineage: responseDocument.lineage,
status: responseDocument.status
}
});
if (responseDocument.outputs) {
for (var i = 0, len = responseDocument.outputs.length; i < len; i++) {
this.writeNode("wps:Output", responseDocument.outputs[i], node);
}
}
return node;
},
"Output": function(output) {
var node = this.createElementNSPlus("wps:Output", {
attributes: {
asReference: output.asReference,
mimeType: output.mimeType,
encoding: output.encoding,
schema: output.schema
}
});
this.writeNode("ows:Identifier", output.identifier, node);
this.writeNode("ows:Title", output.title, node);
this.writeNode("ows:Abstract", output["abstract"], node);
return node;
},
"RawDataOutput": function(rawDataOutput) {
var node = this.createElementNSPlus("wps:RawDataOutput", {
attributes: {
mimeType: rawDataOutput.mimeType,
encoding: rawDataOutput.encoding,
schema: rawDataOutput.schema
}
});
this.writeNode("ows:Identifier", rawDataOutput.identifier, node);
return node;
},
"DataInputs": function(dataInputs) {
var node = this.createElementNSPlus("wps:DataInputs", {});
for (var i=0, ii=dataInputs.length; i<ii; ++i) {
this.writeNode("wps:Input", dataInputs[i], node);
}
return node;
},
"Input": function(input) {
var node = this.createElementNSPlus("wps:Input", {});
this.writeNode("ows:Identifier", input.identifier, node);
if (input.title) {
this.writeNode("ows:Title", input.title, node);
}
if (input.data) {
this.writeNode("wps:Data", input.data, node);
}
if (input.reference) {
this.writeNode("wps:Reference", input.reference, node);
}
if (input.boundingBoxData) {
this.writeNode("wps:BoundingBoxData", input.boundingBoxData, node);
}
return node;
},
"Data": function(data) {
var node = this.createElementNSPlus("wps:Data", {});
if (data.literalData) {
this.writeNode("wps:LiteralData", data.literalData, node);
} else if (data.complexData) {
this.writeNode("wps:ComplexData", data.complexData, node);
} else if (data.boundingBoxData) {
this.writeNode("ows:BoundingBox", data.boundingBoxData, node);
}
return node;
},
"LiteralData": function(literalData) {
var node = this.createElementNSPlus("wps:LiteralData", {
attributes: {
uom: literalData.uom
},
value: literalData.value
});
return node;
},
"ComplexData": function(complexData) {
var node = this.createElementNSPlus("wps:ComplexData", {
attributes: {
mimeType: complexData.mimeType,
encoding: complexData.encoding,
schema: complexData.schema
}
});
var data = complexData.value;
if (typeof data === "string") {
node.appendChild(
this.getXMLDoc().createCDATASection(complexData.value)
);
} else {
node.appendChild(data);
}
return node;
},
"Reference": function(reference) {
var node = this.createElementNSPlus("wps:Reference", {
attributes: {
mimeType: reference.mimeType,
"xlink:href": reference.href,
method: reference.method,
encoding: reference.encoding,
schema: reference.schema
}
});
if (reference.body) {
this.writeNode("wps:Body", reference.body, node);
}
return node;
},
"BoundingBoxData": function(node, obj) {
this.writers['ows']['BoundingBox'].apply(this, [node, obj, "wps:BoundingBoxData"]);
},
"Body": function(body) {
var node = this.createElementNSPlus("wps:Body", {});
if (body.wcs) {
this.writeNode("wcs:GetCoverage", body.wcs, node);
}
else if (body.wfs) {
// OpenLayers.Format.WFST expects these to be on the
// instance and not in the options
this.featureType = body.wfs.featureType;
this.version = body.wfs.version;
this.writeNode("wfs:GetFeature", body.wfs, node);
} else {
this.writeNode("wps:Execute", body, node);
}
return node;
}
},
"wcs": OpenLayers.Format.WCSGetCoverage.prototype.writers.wcs,
"wfs": OpenLayers.Format.WFST.v1_1_0.prototype.writers.wfs,
"ogc": OpenLayers.Format.Filter.v1_1_0.prototype.writers.ogc,
"ows": OpenLayers.Format.OWSCommon.v1_1_0.prototype.writers.ows
},
/**
* Property: readers
* Contains public functions, grouped by namespace prefix, that will
* be applied when a namespaced node is found matching the function
* name. The function will be applied in the scope of this parser
* with two arguments: the node being read and a context object passed
* from the parent.
*/
readers: {
"wps": {
"ExecuteResponse": function(node, obj) {
obj.executeResponse = {
lang: node.getAttribute("lang"),
statusLocation: node.getAttribute("statusLocation"),
serviceInstance: node.getAttribute("serviceInstance"),
service: node.getAttribute("service")
};
this.readChildNodes(node, obj.executeResponse);
},
"Process":function(node,obj) {
obj.process = {};
this.readChildNodes(node, obj.process);
},
"Status":function(node,obj) {
obj.status = {
creationTime: node.getAttribute("creationTime")
};
this.readChildNodes(node, obj.status);
},
"ProcessSucceeded": function(node,obj) {
obj.processSucceeded = true;
},
"ProcessOutputs": function(node, processDescription) {
processDescription.processOutputs = [];
this.readChildNodes(node, processDescription.processOutputs);
},
"Output": function(node, processOutputs) {
var output = {};
this.readChildNodes(node, output);
processOutputs.push(output);
},
"Reference": function(node, output) {
output.reference = {
href: node.getAttribute("href"),
mimeType: node.getAttribute("mimeType"),
encoding: node.getAttribute("encoding"),
schema: node.getAttribute("schema")
};
},
"Data": function(node, output) {
output.data = {};
this.readChildNodes(node, output);
},
"LiteralData": function(node, output) {
output.literalData = {
dataType: node.getAttribute("dataType"),
uom: node.getAttribute("uom"),
value: this.getChildValue(node)
};
},
"ComplexData": function(node, output) {
output.complexData = {
mimeType: node.getAttribute("mimeType"),
schema: node.getAttribute("schema"),
encoding: node.getAttribute("encoding"),
value: ""
};
// try to get *some* value, ignore the empty text values
if (this.isSimpleContent(node)) {
var child;
for(child=node.firstChild; child; child=child.nextSibling) {
switch(child.nodeType) {
case 3: // text node
case 4: // cdata section
output.complexData.value += child.nodeValue;
}
}
}
else {
for(child=node.firstChild; child; child=child.nextSibling) {
if (child.nodeType == 1) {
output.complexData.value = child;
}
}
}
},
"BoundingBox": function(node, output) {
output.boundingBoxData = {
dimensions: node.getAttribute("dimensions"),
crs: node.getAttribute("crs")
};
this.readChildNodes(node, output.boundingBoxData);
}
},
// TODO: we should add Exception parsing here
"ows": OpenLayers.Format.OWSCommon.v1_1_0.prototype.readers["ows"]
},
CLASS_NAME: "OpenLayers.Format.WPSExecute"
});
|