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:
bartvde
2011-07-05 09:42:34 +00:00
parent 3b70536695
commit c59e225d8f
17 changed files with 346 additions and 504 deletions
+3 -32
View File
@@ -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 WMTS Capabilities.
*
* Inherits from:
* - <OpenLayers.Format.XML>
* - <OpenLayers.Format.XML.VersionedOGC>
*/
OpenLayers.Format.WMTSCapabilities = OpenLayers.Class(OpenLayers.Format.XML, {
OpenLayers.Format.WMTSCapabilities = OpenLayers.Class(OpenLayers.Format.XML.VersionedOGC, {
/**
* APIProperty: defaultVersion
@@ -22,18 +22,6 @@ OpenLayers.Format.WMTSCapabilities = 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,
/**
* APIProperty: yx
* {Object} Members in the yx object are used to determine if a CRS URN
@@ -67,23 +55,6 @@ OpenLayers.Format.WMTSCapabilities = OpenLayers.Class(OpenLayers.Format.XML, {
* Returns:
* {Object} Info about the WMTS Capabilities
*/
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.WMTSCapabilities[
"v" + version.replace(/\./g, "_")
];
if (!constr) {
throw new Error("Can't find a WMTS capabilities parser for version " + version);
}
this.parser = new constr(this.options);
}
return this.parser.read(data);
},
/**
* APIMethod: createLayer