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