v1.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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/WFSCapabilities.js
  7. */
  8. /**
  9. * Class: OpenLayers.Format.WFSCapabilities.v1
  10. * Abstract class not to be instantiated directly.
  11. *
  12. * Inherits from:
  13. * - <OpenLayers.Format.XML>
  14. */
  15. OpenLayers.Format.WFSCapabilities.v1 = OpenLayers.Class(
  16. OpenLayers.Format.XML, {
  17. /**
  18. * Property: namespaces
  19. * {Object} Mapping of namespace aliases to namespace URIs.
  20. */
  21. namespaces: {
  22. wfs: "http://www.opengis.net/wfs",
  23. xlink: "http://www.w3.org/1999/xlink",
  24. xsi: "http://www.w3.org/2001/XMLSchema-instance",
  25. ows: "http://www.opengis.net/ows"
  26. },
  27. /**
  28. * APIProperty: errorProperty
  29. * {String} Which property of the returned object to check for in order to
  30. * determine whether or not parsing has failed. In the case that the
  31. * errorProperty is undefined on the returned object, the document will be
  32. * run through an OGCExceptionReport parser.
  33. */
  34. errorProperty: "featureTypeList",
  35. /**
  36. * Property: defaultPrefix
  37. */
  38. defaultPrefix: "wfs",
  39. /**
  40. * Constructor: OpenLayers.Format.WFSCapabilities.v1_1
  41. * Create an instance of one of the subclasses.
  42. *
  43. * Parameters:
  44. * options - {Object} An optional object whose properties will be set on
  45. * this instance.
  46. */
  47. /**
  48. * APIMethod: read
  49. * Read capabilities data from a string, and return a list of layers.
  50. *
  51. * Parameters:
  52. * data - {String} or {DOMElement} data to read/parse.
  53. *
  54. * Returns:
  55. * {Array} List of named layers.
  56. */
  57. read: function(data) {
  58. if(typeof data == "string") {
  59. data = OpenLayers.Format.XML.prototype.read.apply(this, [data]);
  60. }
  61. var raw = data;
  62. if(data && data.nodeType == 9) {
  63. data = data.documentElement;
  64. }
  65. var capabilities = {};
  66. this.readNode(data, capabilities);
  67. return capabilities;
  68. },
  69. /**
  70. * Property: readers
  71. * Contains public functions, grouped by namespace prefix, that will
  72. * be applied when a namespaced node is found matching the function
  73. * name. The function will be applied in the scope of this parser
  74. * with two arguments: the node being read and a context object passed
  75. * from the parent.
  76. */
  77. readers: {
  78. "wfs": {
  79. "WFS_Capabilities": function(node, obj) {
  80. this.readChildNodes(node, obj);
  81. },
  82. "FeatureTypeList": function(node, request) {
  83. request.featureTypeList = {
  84. featureTypes: []
  85. };
  86. this.readChildNodes(node, request.featureTypeList);
  87. },
  88. "FeatureType": function(node, featureTypeList) {
  89. var featureType = {};
  90. this.readChildNodes(node, featureType);
  91. featureTypeList.featureTypes.push(featureType);
  92. },
  93. "Name": function(node, obj) {
  94. var name = this.getChildValue(node);
  95. if(name) {
  96. var parts = name.split(":");
  97. obj.name = parts.pop();
  98. if(parts.length > 0) {
  99. obj.featureNS = this.lookupNamespaceURI(node, parts[0]);
  100. }
  101. }
  102. },
  103. "Title": function(node, obj) {
  104. var title = this.getChildValue(node);
  105. if(title) {
  106. obj.title = title;
  107. }
  108. },
  109. "Abstract": function(node, obj) {
  110. var abst = this.getChildValue(node);
  111. if(abst) {
  112. obj["abstract"] = abst;
  113. }
  114. }
  115. }
  116. },
  117. CLASS_NAME: "OpenLayers.Format.WFSCapabilities.v1"
  118. });