WCSGetCoverage.js 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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.WCSGetCoverage version 1.1.0
  11. *
  12. * Inherits from:
  13. * - <OpenLayers.Format.XML>
  14. */
  15. OpenLayers.Format.WCSGetCoverage = OpenLayers.Class(OpenLayers.Format.XML, {
  16. /**
  17. * Property: namespaces
  18. * {Object} Mapping of namespace aliases to namespace URIs.
  19. */
  20. namespaces: {
  21. ows: "http://www.opengis.net/ows/1.1",
  22. wcs: "http://www.opengis.net/wcs/1.1",
  23. xlink: "http://www.w3.org/1999/xlink",
  24. xsi: "http://www.w3.org/2001/XMLSchema-instance"
  25. },
  26. /**
  27. * Property: regExes
  28. * Compiled regular expressions for manipulating strings.
  29. */
  30. regExes: {
  31. trimSpace: (/^\s*|\s*$/g),
  32. removeSpace: (/\s*/g),
  33. splitSpace: (/\s+/),
  34. trimComma: (/\s*,\s*/g)
  35. },
  36. /**
  37. * Constant: VERSION
  38. * {String} 1.1.2
  39. */
  40. VERSION: "1.1.2",
  41. /**
  42. * Property: schemaLocation
  43. * {String} Schema location
  44. */
  45. schemaLocation: "http://www.opengis.net/wcs/1.1 http://schemas.opengis.net/wcs/1.1/wcsGetCoverage.xsd",
  46. /**
  47. * Constructor: OpenLayers.Format.WCSGetCoverage
  48. *
  49. * Parameters:
  50. * options - {Object} An optional object whose properties will be set on
  51. * this instance.
  52. */
  53. /**
  54. * Method: write
  55. *
  56. * Parameters:
  57. * options - {Object} Optional object.
  58. *
  59. * Returns:
  60. * {String} A WCS GetCoverage request XML string.
  61. */
  62. write: function(options) {
  63. var node = this.writeNode("wcs:GetCoverage", options);
  64. this.setAttributeNS(
  65. node, this.namespaces.xsi,
  66. "xsi:schemaLocation", this.schemaLocation
  67. );
  68. return OpenLayers.Format.XML.prototype.write.apply(this, [node]);
  69. },
  70. /**
  71. * Property: writers
  72. * As a compliment to the readers property, this structure contains public
  73. * writing functions grouped by namespace alias and named like the
  74. * node names they produce.
  75. */
  76. writers: {
  77. "wcs": {
  78. "GetCoverage": function(options) {
  79. var node = this.createElementNSPlus("wcs:GetCoverage", {
  80. attributes: {
  81. version: options.version || this.VERSION,
  82. service: 'WCS'
  83. }
  84. });
  85. this.writeNode("ows:Identifier", options.identifier, node);
  86. this.writeNode("wcs:DomainSubset", options.domainSubset, node);
  87. this.writeNode("wcs:Output", options.output, node);
  88. return node;
  89. },
  90. "DomainSubset": function(domainSubset) {
  91. var node = this.createElementNSPlus("wcs:DomainSubset", {});
  92. this.writeNode("ows:BoundingBox", domainSubset.boundingBox, node);
  93. if (domainSubset.temporalSubset) {
  94. this.writeNode("wcs:TemporalSubset", domainSubset.temporalSubset, node);
  95. }
  96. return node;
  97. },
  98. "TemporalSubset": function(temporalSubset) {
  99. var node = this.createElementNSPlus("wcs:TemporalSubset", {});
  100. for (var i=0, len=temporalSubset.timePeriods.length; i<len; ++i) {
  101. this.writeNode("wcs:TimePeriod", temporalSubset.timePeriods[i], node);
  102. }
  103. return node;
  104. },
  105. "TimePeriod": function(timePeriod) {
  106. var node = this.createElementNSPlus("wcs:TimePeriod", {});
  107. this.writeNode("wcs:BeginPosition", timePeriod.begin, node);
  108. this.writeNode("wcs:EndPosition", timePeriod.end, node);
  109. if (timePeriod.resolution) {
  110. this.writeNode("wcs:TimeResolution", timePeriod.resolution, node);
  111. }
  112. return node;
  113. },
  114. "BeginPosition": function(begin) {
  115. var node = this.createElementNSPlus("wcs:BeginPosition", {
  116. value: begin
  117. });
  118. return node;
  119. },
  120. "EndPosition": function(end) {
  121. var node = this.createElementNSPlus("wcs:EndPosition", {
  122. value: end
  123. });
  124. return node;
  125. },
  126. "TimeResolution": function(resolution) {
  127. var node = this.createElementNSPlus("wcs:TimeResolution", {
  128. value: resolution
  129. });
  130. return node;
  131. },
  132. "Output": function(output) {
  133. var node = this.createElementNSPlus("wcs:Output", {
  134. attributes: {
  135. format: output.format,
  136. store: output.store
  137. }
  138. });
  139. if (output.gridCRS) {
  140. this.writeNode("wcs:GridCRS", output.gridCRS, node);
  141. }
  142. return node;
  143. },
  144. "GridCRS": function(gridCRS) {
  145. var node = this.createElementNSPlus("wcs:GridCRS", {});
  146. this.writeNode("wcs:GridBaseCRS", gridCRS.baseCRS, node);
  147. if (gridCRS.type) {
  148. this.writeNode("wcs:GridType", gridCRS.type, node);
  149. }
  150. if (gridCRS.origin) {
  151. this.writeNode("wcs:GridOrigin", gridCRS.origin, node);
  152. }
  153. this.writeNode("wcs:GridOffsets", gridCRS.offsets, node);
  154. if (gridCRS.CS) {
  155. this.writeNode("wcs:GridCS", gridCRS.CS, node);
  156. }
  157. return node;
  158. },
  159. "GridBaseCRS": function(baseCRS) {
  160. return this.createElementNSPlus("wcs:GridBaseCRS", {
  161. value: baseCRS
  162. });
  163. },
  164. "GridOrigin": function(origin) {
  165. return this.createElementNSPlus("wcs:GridOrigin", {
  166. value: origin
  167. });
  168. },
  169. "GridType": function(type) {
  170. return this.createElementNSPlus("wcs:GridType", {
  171. value: type
  172. });
  173. },
  174. "GridOffsets": function(offsets) {
  175. return this.createElementNSPlus("wcs:GridOffsets", {
  176. value: offsets
  177. });
  178. },
  179. "GridCS": function(CS) {
  180. return this.createElementNSPlus("wcs:GridCS", {
  181. value: CS
  182. });
  183. }
  184. },
  185. "ows": OpenLayers.Format.OWSCommon.v1_1_0.prototype.writers.ows
  186. },
  187. CLASS_NAME: "OpenLayers.Format.WCSGetCoverage"
  188. });