allow versioned profiled parsers to fallback to the non-profiled parser, this will help deal with situations in which a WMSC parser is created, the server is requested for WMS 1.1.1, but returns 1.1.0

This commit is contained in:
Bart van den Eijnden
2012-10-08 16:28:19 +02:00
parent e3a5091ebd
commit fd6e7ebe03
2 changed files with 158 additions and 2 deletions

View File

@@ -36,6 +36,17 @@ OpenLayers.Format.XML.VersionedOGC = OpenLayers.Class(OpenLayers.Format.XML, {
*/
profile: null,
/**
* APIProperty: allowFallback
* {Boolean} If a profiled parser cannot be found for the returned version,
* use a non-profiled parser as the fallback. Application code using this
* should take into account that the return object structure might be
* missing the specifics of the profile. Defaults to false Application code using this
* should take into account that the return object structure might be
* missing the specifics of the profile. Defaults to false.
*/
allowFallback: false,
/**
* APIProperty: errorProperty
* {String} Which property of the returned object to check for in order to
@@ -128,8 +139,17 @@ OpenLayers.Format.XML.VersionedOGC = OpenLayers.Class(OpenLayers.Format.XML, {
"v" + version.replace(/\./g, "_") + profile
];
if(!format) {
throw "Can't find a " + this.name + " parser for version " +
version + profile;
if (profile !== "" && this.allowFallback) {
// fallback to the non-profiled version of the parser
profile = "";
format = OpenLayers.Format[this.name][
"v" + version.replace(/\./g, "_")
];
}
if (!format) {
throw "Can't find a " + this.name + " parser for version " +
version + profile;
}
}
this.parser = new format(this.options);
}