source:
trunk/workshop-routing-foss4g/web/OpenLayers/lib/OpenLayers/Format/WFSCapabilities.js
@
76
Revision 76, 2.3 KB checked in by djay, 12 years ago (diff) | |
---|---|
|
Line | |
---|---|
1 | /* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for |
2 | * full list of contributors). Published under the Clear BSD license. |
3 | * See http://svn.openlayers.org/trunk/openlayers/license.txt for the |
4 | * full text of the license. */ |
5 | |
6 | /** |
7 | * @requires OpenLayers/Format/XML.js |
8 | */ |
9 | |
10 | /** |
11 | * Class: OpenLayers.Format.WFSCapabilities |
12 | * Read WFS Capabilities. |
13 | * |
14 | * Inherits from: |
15 | * - <OpenLayers.Format.XML> |
16 | */ |
17 | OpenLayers.Format.WFSCapabilities = OpenLayers.Class(OpenLayers.Format.XML, { |
18 | |
19 | /** |
20 | * APIProperty: defaultVersion |
21 | * {String} Version number to assume if none found. Default is "1.1.0". |
22 | */ |
23 | defaultVersion: "1.1.0", |
24 | |
25 | /** |
26 | * APIProperty: version |
27 | * {String} Specify a version string if one is known. |
28 | */ |
29 | version: null, |
30 | |
31 | /** |
32 | * Constructor: OpenLayers.Format.WFSCapabilities |
33 | * Create a new parser for WFS capabilities. |
34 | * |
35 | * Parameters: |
36 | * options - {Object} An optional object whose properties will be set on |
37 | * this instance. |
38 | */ |
39 | initialize: function(options) { |
40 | OpenLayers.Format.XML.prototype.initialize.apply(this, [options]); |
41 | this.options = options; |
42 | }, |
43 | |
44 | /** |
45 | * APIMethod: read |
46 | * Read capabilities data from a string, and return a list of layers. |
47 | * |
48 | * Parameters: |
49 | * data - {String} or {DOMElement} data to read/parse. |
50 | * |
51 | * Returns: |
52 | * {Array} List of named layers. |
53 | */ |
54 | read: function(data) { |
55 | if(typeof data == "string") { |
56 | data = OpenLayers.Format.XML.prototype.read.apply(this, [data]); |
57 | } |
58 | var root = data.documentElement; |
59 | var version = this.version; |
60 | if(!version) { |
61 | version = root.getAttribute("version"); |
62 | if(!version) { |
63 | version = this.defaultVersion; |
64 | } |
65 | } |
66 | var constr = OpenLayers.Format.WFSCapabilities[ |
67 | "v" + version.replace(/\./g, "_") |
68 | ]; |
69 | if(!constr) { |
70 | throw "Can't find a WFS capabilities parser for version " + version; |
71 | } |
72 | var parser = new constr(this.options); |
73 | var capabilities = parser.read(data); |
74 | capabilities.version = version; |
75 | return capabilities; |
76 | }, |
77 | |
78 | CLASS_NAME: "OpenLayers.Format.WFSCapabilities" |
79 | |
80 | }); |
Note: See TracBrowser
for help on using the repository browser.