v1_3.js 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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/WMSCapabilities/v1.js
  7. */
  8. /**
  9. * Class: OpenLayers.Format.WMSCapabilities/v1_3
  10. * Abstract base class for WMS Capabilities version 1.3.X.
  11. * SLD 1.1.0 adds in the extra operations DescribeLayer and GetLegendGraphic,
  12. * see: http://schemas.opengis.net/sld/1.1.0/sld_capabilities.xsd
  13. *
  14. * Inherits from:
  15. * - <OpenLayers.Format.WMSCapabilities.v1>
  16. */
  17. OpenLayers.Format.WMSCapabilities.v1_3 = OpenLayers.Class(
  18. OpenLayers.Format.WMSCapabilities.v1, {
  19. /**
  20. * Property: readers
  21. * Contains public functions, grouped by namespace prefix, that will
  22. * be applied when a namespaced node is found matching the function
  23. * name. The function will be applied in the scope of this parser
  24. * with two arguments: the node being read and a context object passed
  25. * from the parent.
  26. */
  27. readers: {
  28. "wms": OpenLayers.Util.applyDefaults({
  29. "WMS_Capabilities": function(node, obj) {
  30. this.readChildNodes(node, obj);
  31. },
  32. "LayerLimit": function(node, obj) {
  33. obj.layerLimit = parseInt(this.getChildValue(node));
  34. },
  35. "MaxWidth": function(node, obj) {
  36. obj.maxWidth = parseInt(this.getChildValue(node));
  37. },
  38. "MaxHeight": function(node, obj) {
  39. obj.maxHeight = parseInt(this.getChildValue(node));
  40. },
  41. "BoundingBox": function(node, obj) {
  42. var bbox = OpenLayers.Format.WMSCapabilities.v1.prototype.readers["wms"].BoundingBox.apply(this, [node, obj]);
  43. bbox.srs = node.getAttribute("CRS");
  44. obj.bbox[bbox.srs] = bbox;
  45. },
  46. "CRS": function(node, obj) {
  47. // CRS is the synonym of SRS
  48. this.readers.wms.SRS.apply(this, [node, obj]);
  49. },
  50. "EX_GeographicBoundingBox": function(node, obj) {
  51. // replacement of LatLonBoundingBox
  52. obj.llbbox = [];
  53. this.readChildNodes(node, obj.llbbox);
  54. },
  55. "westBoundLongitude": function(node, obj) {
  56. obj[0] = this.getChildValue(node);
  57. },
  58. "eastBoundLongitude": function(node, obj) {
  59. obj[2] = this.getChildValue(node);
  60. },
  61. "southBoundLatitude": function(node, obj) {
  62. obj[1] = this.getChildValue(node);
  63. },
  64. "northBoundLatitude": function(node, obj) {
  65. obj[3] = this.getChildValue(node);
  66. },
  67. "MinScaleDenominator": function(node, obj) {
  68. obj.maxScale = parseFloat(this.getChildValue(node)).toPrecision(16);
  69. },
  70. "MaxScaleDenominator": function(node, obj) {
  71. obj.minScale = parseFloat(this.getChildValue(node)).toPrecision(16);
  72. },
  73. "Dimension": function(node, obj) {
  74. // dimension has extra attributes: default, multipleValues,
  75. // nearestValue, current which used to be part of Extent. It now
  76. // also contains the values.
  77. var name = node.getAttribute("name").toLowerCase();
  78. var dim = {
  79. name: name,
  80. units: node.getAttribute("units"),
  81. unitsymbol: node.getAttribute("unitSymbol"),
  82. nearestVal: node.getAttribute("nearestValue") === "1",
  83. multipleVal: node.getAttribute("multipleValues") === "1",
  84. "default": node.getAttribute("default") || "",
  85. current: node.getAttribute("current") === "1",
  86. values: this.getChildValue(node).split(",")
  87. };
  88. // Theoretically there can be more dimensions with the same
  89. // name, but with a different unit. Until we meet such a case,
  90. // let's just keep the same structure as the WMS 1.1
  91. // GetCapabilities parser uses. We will store the last
  92. // one encountered.
  93. obj.dimensions[dim.name] = dim;
  94. },
  95. "Keyword": function(node, obj) {
  96. // TODO: should we change the structure of keyword in v1.js?
  97. // Make it an object with a value instead of a string?
  98. var keyword = {value: this.getChildValue(node),
  99. vocabulary: node.getAttribute("vocabulary")};
  100. if (obj.keywords) {
  101. obj.keywords.push(keyword);
  102. }
  103. }
  104. }, OpenLayers.Format.WMSCapabilities.v1.prototype.readers["wms"]),
  105. "sld": {
  106. "UserDefinedSymbolization": function(node, obj) {
  107. this.readers.wms.UserDefinedSymbolization.apply(this, [node, obj]);
  108. // add the two extra attributes
  109. obj.userSymbols.inlineFeature = parseInt(node.getAttribute("InlineFeature")) == 1;
  110. obj.userSymbols.remoteWCS = parseInt(node.getAttribute("RemoteWCS")) == 1;
  111. },
  112. "DescribeLayer": function(node, obj) {
  113. this.readers.wms.DescribeLayer.apply(this, [node, obj]);
  114. },
  115. "GetLegendGraphic": function(node, obj) {
  116. this.readers.wms.GetLegendGraphic.apply(this, [node, obj]);
  117. }
  118. }
  119. },
  120. CLASS_NAME: "OpenLayers.Format.WMSCapabilities.v1_3"
  121. });