WCS parsing working properly, but needs more tests; moved errorProperty down to parser, where it arguably belongs, and where it has to live to work with WCS. Also removed null error property on versionedOGC.

This commit is contained in:
Christopher Eykamp
2012-12-27 13:29:02 +01:00
parent 8ff05cdeac
commit b6c2c26580
7 changed files with 36 additions and 31 deletions

View File

@@ -22,14 +22,6 @@ OpenLayers.Format.WCSCapabilities = OpenLayers.Class(OpenLayers.Format.XML.Versi
*/
defaultVersion: "1.1.0",
/**
* 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.
*/
errorProperty: "service",
/**
* Constructor: OpenLayers.Format.WCSCapabilities

View File

@@ -38,6 +38,16 @@ OpenLayers.Format.WCSCapabilities.v1_0_0 = OpenLayers.Class(
ows: "http://www.opengis.net/ows"
},
/**
* 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.
*/
errorProperty: "service",
/**
* Property: readers
* Contains public functions, grouped by namespace prefix, that will

View File

@@ -30,6 +30,15 @@ OpenLayers.Format.WCSCapabilities.v1_1_0 = OpenLayers.Class(
ows: "http://www.opengis.net/ows/1.1"
},
/**
* 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.
*/
errorProperty: "operationsMetadata",
/**
* Constructor: OpenLayers.Format.WCSCapabilities.v1_1_0

View File

@@ -21,15 +21,6 @@ OpenLayers.Format.WFSCapabilities = OpenLayers.Class(OpenLayers.Format.XML.Versi
* {String} Version number to assume if none found. Default is "1.1.0".
*/
defaultVersion: "1.1.0",
/**
* 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.
*/
errorProperty: "featureTypeList",
/**
* Constructor: OpenLayers.Format.WFSCapabilities

View File

@@ -28,6 +28,16 @@ OpenLayers.Format.WFSCapabilities.v1 = OpenLayers.Class(
ows: "http://www.opengis.net/ows"
},
/**
* 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.
*/
errorProperty: "featureTypeList",
/**
* Property: defaultPrefix
*/

View File

@@ -45,14 +45,6 @@ OpenLayers.Format.XML.VersionedOGC = OpenLayers.Class(OpenLayers.Format.XML, {
*/
allowFallback: false,
/**
* 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.
*/
errorProperty: null,
/**
* Property: name
@@ -193,9 +185,13 @@ OpenLayers.Format.XML.VersionedOGC = OpenLayers.Class(OpenLayers.Format.XML, {
}
var root = data.documentElement;
var version = this.getVersion(root);
this.parser = this.getParser(version);
var obj = this.parser.read(data, options);
if (this.errorProperty !== null && obj[this.errorProperty] === undefined) {
this.parser = this.getParser(version); // Select the parser
var obj = this.parser.read(data, options); // Parse the data
var errorProperty = this.parser.errorProperty || null;
if (errorProperty !== null && obj[errorProperty] === undefined) {
// an error must have happened, so parse it and report back
var format = new OpenLayers.Format.OGCExceptionReport();
obj.error = format.read(data);

View File

@@ -30,7 +30,6 @@
var res = parser.read(text);
debugger;
t.ok(!res.error, "Parsing XML generated no errors");
t.eq(res.service.fees, "mucho dinero", "Service>Fees correctly parsed");
@@ -64,8 +63,6 @@
res = parser.read(text);
debugger;
t.ok(!res.error, "Parsing XML generated no errors");
// ft = res.featureTypeList.featureTypes;