source:
trunk/workshop-routing-foss4g/web/OpenLayers/lib/OpenLayers/Format/SOSCapabilities.js
@
76
Revision 76, 2.4 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.SOSCapabilities |
12 | * Read SOS Capabilities. |
13 | * |
14 | * Inherits from: |
15 | * - <OpenLayers.Format.XML> |
16 | */ |
17 | OpenLayers.Format.SOSCapabilities = OpenLayers.Class(OpenLayers.Format.XML, { |
18 | |
19 | /** |
20 | * APIProperty: defaultVersion |
21 | * {String} Version number to assume if none found. Default is "1.0.0". |
22 | */ |
23 | defaultVersion: "1.0.0", |
24 | |
25 | /** |
26 | * APIProperty: version |
27 | * {String} Specify a version string if one is known. |
28 | */ |
29 | version: null, |
30 | |
31 | /** |
32 | * Property: parser |
33 | * {<OpenLayers.Format>} A cached versioned format used for reading. |
34 | */ |
35 | parser: null, |
36 | |
37 | /** |
38 | * Constructor: OpenLayers.Format.SOSCapabilities |
39 | * Create a new parser for SOS capabilities. |
40 | * |
41 | * Parameters: |
42 | * options - {Object} An optional object whose properties will be set on |
43 | * this instance. |
44 | */ |
45 | initialize: function(options) { |
46 | OpenLayers.Format.XML.prototype.initialize.apply(this, [options]); |
47 | this.options = options; |
48 | }, |
49 | |
50 | /** |
51 | * APIMethod: read |
52 | * Read capabilities data from a string, and return information about |
53 | * the service (offering and observedProperty mostly). |
54 | * |
55 | * Parameters: |
56 | * data - {String} or {DOMElement} data to read/parse. |
57 | * |
58 | * Returns: |
59 | * {Object} Info about the SOS |
60 | */ |
61 | read: function(data) { |
62 | if(typeof data == "string") { |
63 | data = OpenLayers.Format.XML.prototype.read.apply(this, [data]); |
64 | } |
65 | var root = data.documentElement; |
66 | var version = this.version || root.getAttribute("version") || this.defaultVersion; |
67 | if(!this.parser || this.parser.version !== version) { |
68 | var constr = OpenLayers.Format.SOSCapabilities[ |
69 | "v" + version.replace(/\./g, "_") |
70 | ]; |
71 | if(!constr) { |
72 | throw "Can't find a SOS capabilities parser for version " + version; |
73 | } |
74 | var parser = new constr(this.options); |
75 | } |
76 | var capabilities = parser.read(data); |
77 | capabilities.version = version; |
78 | return capabilities; |
79 | }, |
80 | |
81 | CLASS_NAME: "OpenLayers.Format.SOSCapabilities" |
82 | |
83 | }); |
Note: See TracBrowser
for help on using the repository browser.