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,8 +4,7 @@
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/Format/XML.js
|
||||
* @requires OpenLayers/Format/OGCExceptionReport.js
|
||||
* @requires OpenLayers/Format/XML/VersionedOGC.js
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -13,21 +12,24 @@
|
||||
* Read WFS Capabilities.
|
||||
*
|
||||
* Inherits from:
|
||||
* - <OpenLayers.Format.XML>
|
||||
* - <OpenLayers.Format.XML.VersionedOGC>
|
||||
*/
|
||||
OpenLayers.Format.WFSCapabilities = OpenLayers.Class(OpenLayers.Format.XML, {
|
||||
OpenLayers.Format.WFSCapabilities = OpenLayers.Class(OpenLayers.Format.XML.VersionedOGC, {
|
||||
|
||||
/**
|
||||
* APIProperty: defaultVersion
|
||||
* {String} Version number to assume if none found. Default is "1.1.0".
|
||||
*/
|
||||
defaultVersion: "1.1.0",
|
||||
|
||||
|
||||
/**
|
||||
* APIProperty: version
|
||||
* {String} Specify a version string if one is known.
|
||||
* APIProperty: errorProperty
|
||||
* {String} Which property of the returned object to check for in order to
|
||||
* determine whether or not parsing has failed. In the case that the
|
||||
* errorProperty is undefined on the returned object, the document will be
|
||||
* run through an OGCExceptionReport parser.
|
||||
*/
|
||||
version: null,
|
||||
errorProperty: "service",
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Format.WFSCapabilities
|
||||
@@ -48,34 +50,6 @@ OpenLayers.Format.WFSCapabilities = OpenLayers.Class(OpenLayers.Format.XML, {
|
||||
* Returns:
|
||||
* {Array} List of named layers.
|
||||
*/
|
||||
read: function(data) {
|
||||
if(typeof data == "string") {
|
||||
data = OpenLayers.Format.XML.prototype.read.apply(this, [data]);
|
||||
}
|
||||
var root = data.documentElement;
|
||||
var version = this.version;
|
||||
if(!version) {
|
||||
version = root.getAttribute("version");
|
||||
if(!version) {
|
||||
version = this.defaultVersion;
|
||||
}
|
||||
}
|
||||
var constr = OpenLayers.Format.WFSCapabilities[
|
||||
"v" + version.replace(/\./g, "_")
|
||||
];
|
||||
if(!constr) {
|
||||
throw "Can't find a WFS capabilities parser for version " + version;
|
||||
}
|
||||
var parser = new constr(this.options);
|
||||
var capabilities = parser.read(data);
|
||||
if (capabilities.service === undefined) {
|
||||
// an error must have happened, so parse it and report back
|
||||
var format = new OpenLayers.Format.OGCExceptionReport();
|
||||
capabilities.error = format.read(data);
|
||||
}
|
||||
capabilities.version = version;
|
||||
return capabilities;
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Format.WFSCapabilities"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user