WCS 1.0.0 parsing now passing all tests
This commit is contained in:
@@ -28,6 +28,11 @@ OpenLayers.Format.WCSCapabilities.v1 = OpenLayers.Class(
|
|||||||
ows: "http://www.opengis.net/ows"
|
ows: "http://www.opengis.net/ows"
|
||||||
},
|
},
|
||||||
|
|
||||||
|
regExes: {
|
||||||
|
trimSpace: (/^\s*|\s*$/g),
|
||||||
|
splitSpace: (/\s+/)
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Property: defaultPrefix
|
* Property: defaultPrefix
|
||||||
*/
|
*/
|
||||||
@@ -78,16 +83,6 @@ OpenLayers.Format.WCSCapabilities.v1 = OpenLayers.Class(
|
|||||||
"WCS_Capabilities": function(node, obj) { // In 1.0.0, this was WCS_Capabilties, changed in 1.1.0
|
"WCS_Capabilities": function(node, obj) { // In 1.0.0, this was WCS_Capabilties, changed in 1.1.0
|
||||||
this.readChildNodes(node, obj);
|
this.readChildNodes(node, obj);
|
||||||
},
|
},
|
||||||
"Name": function(node, obj) { //????
|
|
||||||
var name = this.getChildValue(node);
|
|
||||||
if(name) {
|
|
||||||
var parts = name.split(":");
|
|
||||||
obj.name = parts.pop();
|
|
||||||
if(parts.length > 0) {
|
|
||||||
obj.featureNS = this.lookupNamespaceURI(node, parts[0]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Title": function(node, obj) {
|
"Title": function(node, obj) {
|
||||||
var title = this.getChildValue(node);
|
var title = this.getChildValue(node);
|
||||||
if(title) {
|
if(title) {
|
||||||
|
|||||||
@@ -36,59 +36,142 @@ OpenLayers.Format.WCSCapabilities.v1_0_0 = OpenLayers.Class(
|
|||||||
*/
|
*/
|
||||||
readers: {
|
readers: {
|
||||||
"wcs": OpenLayers.Util.applyDefaults({
|
"wcs": OpenLayers.Util.applyDefaults({
|
||||||
"Service": function(node, capabilities) {
|
"Service": function(node, obj) {
|
||||||
capabilities.service = {};
|
obj.service = {};
|
||||||
this.readChildNodes(node, capabilities.service);
|
this.readChildNodes(node, obj.service);
|
||||||
},
|
},
|
||||||
"Fees": function(node, service) {
|
"name": function(node, service) {
|
||||||
var fees = this.getChildValue(node);
|
service.name = this.getChildValue(node);
|
||||||
if (fees && fees.toLowerCase() != "none") {
|
|
||||||
service.fees = fees;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"AccessConstraints": function(node, service) {
|
"label": function(node, service) {
|
||||||
var constraints = this.getChildValue(node);
|
service.label = this.getChildValue(node);
|
||||||
if (constraints && constraints.toLowerCase() != "none") {
|
|
||||||
service.accessConstraints = constraints;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"OnlineResource": function(node, service) {
|
"keywords": function(node, service) {
|
||||||
var onlineResource = this.getChildValue(node);
|
service.keywords = [];
|
||||||
if (onlineResource && onlineResource.toLowerCase() != "none") {
|
this.readChildNodes(node, service.keywords);
|
||||||
service.onlineResource = onlineResource;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"Keywords": function(node, service) {
|
"keyword": function(node, keywords) {
|
||||||
var keywords = this.getChildValue(node);
|
keywords.push(this.getChildValue(node)); // Append the keyword to the keywords list
|
||||||
if (keywords && keywords.toLowerCase() != "none") {
|
|
||||||
service.keywords = keywords.split(', ');
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"Capability": function(node, capabilities) {
|
"responsibleParty": function(node, service) {
|
||||||
capabilities.capability = {};
|
service.responsibleParty = {};
|
||||||
this.readChildNodes(node, capabilities.capability);
|
this.readChildNodes(node, service.responsibleParty);
|
||||||
},
|
},
|
||||||
"Request": function(node, obj) {
|
"individualName": function(node, responsibleParty) {
|
||||||
obj.request = {};
|
responsibleParty.individualName = this.getChildValue(node);
|
||||||
this.readChildNodes(node, obj.request);
|
|
||||||
},
|
},
|
||||||
"GetFeature": function(node, request) {
|
"organisationName": function(node, responsibleParty) {
|
||||||
request.getfeature = {
|
responsibleParty.organisationName = this.getChildValue(node);
|
||||||
href: {}, // DCPType
|
|
||||||
formats: [] // ResultFormat
|
|
||||||
};
|
|
||||||
this.readChildNodes(node, request.getfeature);
|
|
||||||
},
|
},
|
||||||
"ResultFormat": function(node, obj) {
|
"positionName": function(node, responsibleParty) {
|
||||||
var children = node.childNodes;
|
responsibleParty.positionName = this.getChildValue(node);
|
||||||
var childNode;
|
},
|
||||||
for(var i=0; i<children.length; i++) {
|
"contactInfo": function(node, responsibleParty) {
|
||||||
childNode = children[i];
|
responsibleParty.contactInfo = {};
|
||||||
if(childNode.nodeType == 1) {
|
this.readChildNodes(node, responsibleParty.contactInfo);
|
||||||
obj.formats.push(childNode.nodeName);
|
},
|
||||||
|
"phone": function(node, contactInfo) {
|
||||||
|
contactInfo.phone = {};
|
||||||
|
this.readChildNodes(node, contactInfo.phone);
|
||||||
|
},
|
||||||
|
"voice": function(node, phone) {
|
||||||
|
phone.voice = this.getChildValue(node);
|
||||||
|
},
|
||||||
|
"facsimile": function(node, phone) {
|
||||||
|
phone.facsimile = this.getChildValue(node);
|
||||||
|
},
|
||||||
|
"address": function(node, contactInfo) {
|
||||||
|
contactInfo.address = {};
|
||||||
|
this.readChildNodes(node, contactInfo.address);
|
||||||
|
},
|
||||||
|
"deliveryPoint": function(node, address) {
|
||||||
|
address.deliveryPoint = this.getChildValue(node);
|
||||||
|
},
|
||||||
|
"city": function(node, address) {
|
||||||
|
address.city = this.getChildValue(node);
|
||||||
|
},
|
||||||
|
"postalCode": function(node, address) {
|
||||||
|
address.postalCode = this.getChildValue(node);
|
||||||
|
},
|
||||||
|
"country": function(node, address) {
|
||||||
|
address.country = this.getChildValue(node);
|
||||||
|
},
|
||||||
|
"electronicMailAddress": function(node, address) {
|
||||||
|
address.electronicMailAddress = this.getChildValue(node);
|
||||||
|
},
|
||||||
|
"fees": function(node, service) {
|
||||||
|
service.fees = this.getChildValue(node);
|
||||||
|
},
|
||||||
|
"accessConstraints": function(node, service) {
|
||||||
|
service.accessConstraints = this.getChildValue(node);
|
||||||
|
},
|
||||||
|
"ContentMetadata": function(node, obj) {
|
||||||
|
obj.contentMetadata = [];
|
||||||
|
this.readChildNodes(node, obj.contentMetadata);
|
||||||
|
},
|
||||||
|
"CoverageOfferingBrief": function(node, contentMetadata) {
|
||||||
|
var coverageOfferingBrief = {};
|
||||||
|
this.readChildNodes(node, coverageOfferingBrief);
|
||||||
|
contentMetadata.push(coverageOfferingBrief);
|
||||||
|
},
|
||||||
|
"name": function(node, coverageOfferingBrief) {
|
||||||
|
coverageOfferingBrief.name = this.getChildValue(node);
|
||||||
|
},
|
||||||
|
"label": function(node, coverageOfferingBrief) {
|
||||||
|
coverageOfferingBrief.label = this.getChildValue(node);
|
||||||
|
},
|
||||||
|
"lonLatEnvelope": function(node, coverageOfferingBrief) {
|
||||||
|
|
||||||
|
// Look for <gml:pos>. Only write the data if everything parsed neatly.
|
||||||
|
// This works well for the data samples I have access to, but may need to be generalized to cover other possible use cases.
|
||||||
|
var nodeList = this.getElementsByTagNameNS(node, "http://www.opengis.net/gml", "pos");
|
||||||
|
|
||||||
|
// We expect two nodes here, to create the corners of a bounding box
|
||||||
|
if(nodeList.length == 2) {
|
||||||
|
var min = {},
|
||||||
|
max = {};
|
||||||
|
|
||||||
|
var ok = true;
|
||||||
|
|
||||||
|
// min
|
||||||
|
var coordString = nodeList[0].firstChild.nodeValue;
|
||||||
|
|
||||||
|
coordString = coordString.replace(this.regExes.trimSpace, "");
|
||||||
|
var coords = coordString.split(this.regExes.splitSpace);
|
||||||
|
|
||||||
|
if(coords.length == 2) {
|
||||||
|
min.lon = coords[0];
|
||||||
|
min.lat = coords[1];
|
||||||
|
} else {
|
||||||
|
ok = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// max
|
||||||
|
var coordString = nodeList[1].firstChild.nodeValue;
|
||||||
|
|
||||||
|
coordString = coordString.replace(this.regExes.trimSpace, "");
|
||||||
|
var coords = coordString.split(this.regExes.splitSpace);
|
||||||
|
|
||||||
|
if(coords.length == 2) {
|
||||||
|
max.lon = coords[0];
|
||||||
|
max.lat = coords[1];
|
||||||
|
} else {
|
||||||
|
ok = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(ok) {
|
||||||
|
coverageOfferingBrief.lonLatEnvelope = {};
|
||||||
|
coverageOfferingBrief.lonLatEnvelope.srsName = node.getAttribute("srsName");
|
||||||
|
coverageOfferingBrief.lonLatEnvelope.min = min;
|
||||||
|
coverageOfferingBrief.lonLatEnvelope.max = max;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
"DCPType": function(node, obj) {
|
"DCPType": function(node, obj) {
|
||||||
this.readChildNodes(node, obj);
|
this.readChildNodes(node, obj);
|
||||||
},
|
},
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user