WPSDescribeProcess.js 6.3 KB

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