implement versioned format base class, r=ahocevar (closes #2954)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@12155 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/Format/XML.js
|
||||
* @requires OpenLayers/Format/XML/VersionedOGC.js
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -12,9 +12,9 @@
|
||||
* Read SOS Capabilities.
|
||||
*
|
||||
* Inherits from:
|
||||
* - <OpenLayers.Format.XML>
|
||||
* - <OpenLayers.Format.XML.VersionedOGC>
|
||||
*/
|
||||
OpenLayers.Format.SOSCapabilities = OpenLayers.Class(OpenLayers.Format.XML, {
|
||||
OpenLayers.Format.SOSCapabilities = OpenLayers.Class(OpenLayers.Format.XML.VersionedOGC, {
|
||||
|
||||
/**
|
||||
* APIProperty: defaultVersion
|
||||
@@ -22,18 +22,6 @@ OpenLayers.Format.SOSCapabilities = OpenLayers.Class(OpenLayers.Format.XML, {
|
||||
*/
|
||||
defaultVersion: "1.0.0",
|
||||
|
||||
/**
|
||||
* APIProperty: version
|
||||
* {String} Specify a version string if one is known.
|
||||
*/
|
||||
version: null,
|
||||
|
||||
/**
|
||||
* Property: parser
|
||||
* {<OpenLayers.Format>} A cached versioned format used for reading.
|
||||
*/
|
||||
parser: null,
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Format.SOSCapabilities
|
||||
* Create a new parser for SOS Capabilities.
|
||||
@@ -54,25 +42,6 @@ OpenLayers.Format.SOSCapabilities = OpenLayers.Class(OpenLayers.Format.XML, {
|
||||
* Returns:
|
||||
* {Object} Info about the SOS
|
||||
*/
|
||||
read: function(data) {
|
||||
if(typeof data == "string") {
|
||||
data = OpenLayers.Format.XML.prototype.read.apply(this, [data]);
|
||||
}
|
||||
var root = data.documentElement;
|
||||
var version = this.version || root.getAttribute("version") || this.defaultVersion;
|
||||
if(!this.parser || this.parser.version !== version) {
|
||||
var constr = OpenLayers.Format.SOSCapabilities[
|
||||
"v" + version.replace(/\./g, "_")
|
||||
];
|
||||
if(!constr) {
|
||||
throw "Can't find a SOS capabilities parser for version " + version;
|
||||
}
|
||||
var parser = new constr(this.options);
|
||||
}
|
||||
var capabilities = parser.read(data);
|
||||
capabilities.version = version;
|
||||
return capabilities;
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Format.SOSCapabilities"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user