rewrite WFSCapabilities parser to the new readers structure, and use OWSCommon readers. This will mean that the return structure will differ for WFS 1.0 and WFS 1.1, but I think it's better to adhere to OWSCommon structures here since this will allow similar structures over different OGC Web Services
This commit is contained in:
@@ -25,136 +25,89 @@ OpenLayers.Format.WFSCapabilities.v1_0_0 = OpenLayers.Class(
|
||||
* options - {Object} An optional object whose properties will be set on
|
||||
* this instance.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Method: read_cap_Service
|
||||
*/
|
||||
read_cap_Service: function(capabilities, node) {
|
||||
var service = {};
|
||||
this.runChildNodes(service, node);
|
||||
capabilities.service = service;
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: read_cap_Fees
|
||||
* Property: readers
|
||||
* Contains public functions, grouped by namespace prefix, that will
|
||||
* be applied when a namespaced node is found matching the function
|
||||
* name. The function will be applied in the scope of this parser
|
||||
* with two arguments: the node being read and a context object passed
|
||||
* from the parent.
|
||||
*/
|
||||
read_cap_Fees: function(service, node) {
|
||||
var fees = this.getChildValue(node);
|
||||
if (fees && fees.toLowerCase() != "none") {
|
||||
service.fees = fees;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: read_cap_AccessConstraints
|
||||
*/
|
||||
read_cap_AccessConstraints: function(service, node) {
|
||||
var constraints = this.getChildValue(node);
|
||||
if (constraints && constraints.toLowerCase() != "none") {
|
||||
service.accessConstraints = constraints;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: read_cap_OnlineResource
|
||||
*/
|
||||
read_cap_OnlineResource: function(service, node) {
|
||||
var onlineResource = this.getChildValue(node);
|
||||
if (onlineResource && onlineResource.toLowerCase() != "none") {
|
||||
service.onlineResource = onlineResource;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: read_cap_Keywords
|
||||
*/
|
||||
read_cap_Keywords: function(service, node) {
|
||||
var keywords = this.getChildValue(node);
|
||||
if (keywords && keywords.toLowerCase() != "none") {
|
||||
service.keywords = keywords.split(', ');
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: read_cap_Capability
|
||||
*/
|
||||
read_cap_Capability: function(capabilities, node) {
|
||||
var capability = {};
|
||||
this.runChildNodes(capability, node);
|
||||
capabilities.capability = capability;
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: read_cap_Request
|
||||
*/
|
||||
read_cap_Request: function(obj, node) {
|
||||
var request = {};
|
||||
this.runChildNodes(request, node);
|
||||
obj.request = request;
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: read_cap_GetFeature
|
||||
*/
|
||||
read_cap_GetFeature: function(request, node) {
|
||||
var getfeature = {
|
||||
href: {}, // DCPType
|
||||
formats: [] // ResultFormat
|
||||
};
|
||||
this.runChildNodes(getfeature, node);
|
||||
request.getfeature = getfeature;
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: read_cap_ResultFormat
|
||||
*/
|
||||
read_cap_ResultFormat: function(obj, node) {
|
||||
var children = node.childNodes;
|
||||
var childNode;
|
||||
for(var i=0; i<children.length; i++) {
|
||||
childNode = children[i];
|
||||
if(childNode.nodeType == 1) {
|
||||
obj.formats.push(childNode.nodeName);
|
||||
readers: {
|
||||
"wfs": OpenLayers.Util.applyDefaults({
|
||||
"Service": function(node, capabilities) {
|
||||
capabilities.service = {};
|
||||
this.readChildNodes(node, capabilities.service);
|
||||
},
|
||||
"Fees": function(node, service) {
|
||||
var fees = this.getChildValue(node);
|
||||
if (fees && fees.toLowerCase() != "none") {
|
||||
service.fees = fees;
|
||||
}
|
||||
},
|
||||
"AccessConstraints": function(node, service) {
|
||||
var constraints = this.getChildValue(node);
|
||||
if (constraints && constraints.toLowerCase() != "none") {
|
||||
service.accessConstraints = constraints;
|
||||
}
|
||||
},
|
||||
"OnlineResource": function(node, service) {
|
||||
var onlineResource = this.getChildValue(node);
|
||||
if (onlineResource && onlineResource.toLowerCase() != "none") {
|
||||
service.onlineResource = onlineResource;
|
||||
}
|
||||
},
|
||||
"Keywords": function(node, service) {
|
||||
var keywords = this.getChildValue(node);
|
||||
if (keywords && keywords.toLowerCase() != "none") {
|
||||
service.keywords = keywords.split(', ');
|
||||
}
|
||||
},
|
||||
"Capability": function(node, capabilities) {
|
||||
capabilities.capability = {};
|
||||
this.readChildNodes(node, capabilities.capability);
|
||||
},
|
||||
"Request": function(node, obj) {
|
||||
obj.request = {};
|
||||
this.readChildNodes(node, obj.request);
|
||||
},
|
||||
"GetFeature": function(node, request) {
|
||||
request.getfeature = {
|
||||
href: {}, // DCPType
|
||||
formats: [] // ResultFormat
|
||||
};
|
||||
this.readChildNodes(node, request.getfeature);
|
||||
},
|
||||
"ResultFormat": function(node, obj) {
|
||||
var children = node.childNodes;
|
||||
var childNode;
|
||||
for(var i=0; i<children.length; i++) {
|
||||
childNode = children[i];
|
||||
if(childNode.nodeType == 1) {
|
||||
obj.formats.push(childNode.nodeName);
|
||||
}
|
||||
}
|
||||
},
|
||||
"DCPType": function(node, obj) {
|
||||
this.readChildNodes(node, obj);
|
||||
},
|
||||
"HTTP": function(node, obj) {
|
||||
this.readChildNodes(node, obj.href);
|
||||
},
|
||||
"Get": function(node, obj) {
|
||||
obj.get = node.getAttribute("onlineResource");
|
||||
},
|
||||
"Post": function(node, obj) {
|
||||
obj.post = node.getAttribute("onlineResource");
|
||||
},
|
||||
"SRS": function(node, obj) {
|
||||
var srs = this.getChildValue(node);
|
||||
if (srs) {
|
||||
obj.srs = srs;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: read_cap_DCPType
|
||||
*/
|
||||
read_cap_DCPType: function(obj, node) {
|
||||
this.runChildNodes(obj, node);
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: read_cap_HTTP
|
||||
*/
|
||||
read_cap_HTTP: function(obj, node) {
|
||||
this.runChildNodes(obj.href, node);
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: read_cap_Get
|
||||
*/
|
||||
read_cap_Get: function(obj, node) {
|
||||
obj.get = node.getAttribute("onlineResource");
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: read_cap_Post
|
||||
*/
|
||||
read_cap_Post: function(obj, node) {
|
||||
obj.post = node.getAttribute("onlineResource");
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: read_cap_SRS
|
||||
*/
|
||||
read_cap_SRS: function(obj, node) {
|
||||
var srs = this.getChildValue(node);
|
||||
if (srs) {
|
||||
obj.srs = srs;
|
||||
}
|
||||
}, OpenLayers.Format.WFSCapabilities.v1.prototype.readers["wfs"])
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Format.WFSCapabilities.v1_0_0"
|
||||
|
||||
Reference in New Issue
Block a user