v1_1.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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_1
  10. * Abstract class not to be instantiated directly.
  11. *
  12. * Inherits from:
  13. * - <OpenLayers.Format.WMSCapabilities.v1>
  14. */
  15. OpenLayers.Format.WMSCapabilities.v1_1 = OpenLayers.Class(
  16. OpenLayers.Format.WMSCapabilities.v1, {
  17. /**
  18. * Property: readers
  19. * Contains public functions, grouped by namespace prefix, that will
  20. * be applied when a namespaced node is found matching the function
  21. * name. The function will be applied in the scope of this parser
  22. * with two arguments: the node being read and a context object passed
  23. * from the parent.
  24. */
  25. readers: {
  26. "wms": OpenLayers.Util.applyDefaults({
  27. "WMT_MS_Capabilities": function(node, obj) {
  28. this.readChildNodes(node, obj);
  29. },
  30. "Keyword": function(node, obj) {
  31. if (obj.keywords) {
  32. obj.keywords.push(this.getChildValue(node));
  33. }
  34. },
  35. "DescribeLayer": function(node, obj) {
  36. obj.describelayer = {formats: []};
  37. this.readChildNodes(node, obj.describelayer);
  38. },
  39. "GetLegendGraphic": function(node, obj) {
  40. obj.getlegendgraphic = {formats: []};
  41. this.readChildNodes(node, obj.getlegendgraphic);
  42. },
  43. "GetStyles": function(node, obj) {
  44. obj.getstyles = {formats: []};
  45. this.readChildNodes(node, obj.getstyles);
  46. },
  47. "PutStyles": function(node, obj) {
  48. obj.putstyles = {formats: []};
  49. this.readChildNodes(node, obj.putstyles);
  50. },
  51. "UserDefinedSymbolization": function(node, obj) {
  52. var userSymbols = {
  53. supportSLD: parseInt(node.getAttribute("SupportSLD")) == 1,
  54. userLayer: parseInt(node.getAttribute("UserLayer")) == 1,
  55. userStyle: parseInt(node.getAttribute("UserStyle")) == 1,
  56. remoteWFS: parseInt(node.getAttribute("RemoteWFS")) == 1
  57. };
  58. obj.userSymbols = userSymbols;
  59. },
  60. "LatLonBoundingBox": function(node, obj) {
  61. obj.llbbox = [
  62. parseFloat(node.getAttribute("minx")),
  63. parseFloat(node.getAttribute("miny")),
  64. parseFloat(node.getAttribute("maxx")),
  65. parseFloat(node.getAttribute("maxy"))
  66. ];
  67. },
  68. "BoundingBox": function(node, obj) {
  69. var bbox = OpenLayers.Format.WMSCapabilities.v1.prototype.readers["wms"].BoundingBox.apply(this, [node, obj]);
  70. bbox.srs = node.getAttribute("SRS");
  71. obj.bbox[bbox.srs] = bbox;
  72. },
  73. "ScaleHint": function(node, obj) {
  74. var min = node.getAttribute("min");
  75. var max = node.getAttribute("max");
  76. var rad2 = Math.pow(2, 0.5);
  77. var ipm = OpenLayers.INCHES_PER_UNIT["m"];
  78. if (min != 0) {
  79. obj.maxScale = parseFloat(
  80. ((min / rad2) * ipm *
  81. OpenLayers.DOTS_PER_INCH).toPrecision(13)
  82. );
  83. }
  84. if (max != Number.POSITIVE_INFINITY) {
  85. obj.minScale = parseFloat(
  86. ((max / rad2) * ipm *
  87. OpenLayers.DOTS_PER_INCH).toPrecision(13)
  88. );
  89. }
  90. },
  91. "Dimension": function(node, obj) {
  92. var name = node.getAttribute("name").toLowerCase();
  93. var dim = {
  94. name: name,
  95. units: node.getAttribute("units"),
  96. unitsymbol: node.getAttribute("unitSymbol")
  97. };
  98. obj.dimensions[dim.name] = dim;
  99. },
  100. "Extent": function(node, obj) {
  101. var name = node.getAttribute("name").toLowerCase();
  102. if (name in obj["dimensions"]) {
  103. var extent = obj.dimensions[name];
  104. extent.nearestVal =
  105. node.getAttribute("nearestValue") === "1";
  106. extent.multipleVal =
  107. node.getAttribute("multipleValues") === "1";
  108. extent.current = node.getAttribute("current") === "1";
  109. extent["default"] = node.getAttribute("default") || "";
  110. var values = this.getChildValue(node);
  111. extent.values = values.split(",");
  112. }
  113. }
  114. }, OpenLayers.Format.WMSCapabilities.v1.prototype.readers["wms"])
  115. },
  116. CLASS_NAME: "OpenLayers.Format.WMSCapabilities.v1_1"
  117. });