WMSGetFeatureInfo class with tests. Should have gone in with my previous
commit, but forgot to svn a. (see #1812) git-svn-id: http://svn.openlayers.org/trunk/openlayers@8920 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
686
lib/OpenLayers/Format/WMSGetFeatureInfo.js
Normal file
686
lib/OpenLayers/Format/WMSGetFeatureInfo.js
Normal file
@@ -0,0 +1,686 @@
|
||||
/* Copyright (c) 2006-2008 MetaCarta, Inc., published under the Clear BSD
|
||||
* license. See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/Format/XML.js
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class: OpenLayers.Format.WMSGetFeatureInfo
|
||||
* Class to read GetFeatureInfo responses from Web Mapping Services
|
||||
*
|
||||
* Inherits from:
|
||||
* - <OpenLayers.Format.XML>
|
||||
*/
|
||||
OpenLayers.Format.WMSGetFeatureInfo = OpenLayers.Class(OpenLayers.Format.XML, {
|
||||
|
||||
/**
|
||||
* APIProperty: layerIdentifier
|
||||
* {String} All xml nodes containing this search criteria will populate an
|
||||
* internal array of layer nodes.
|
||||
*/
|
||||
layerIdentifier: '_layer',
|
||||
|
||||
/**
|
||||
* APIProperty: featureIdentifier
|
||||
* {String} All xml nodes containing this search criteria will populate an
|
||||
* internal array of feature nodes for each layer node found.
|
||||
*/
|
||||
featureIdentifier: '_feature',
|
||||
|
||||
/**
|
||||
* Property: regExes
|
||||
* Compiled regular expressions for manipulating strings.
|
||||
*/
|
||||
regExes: {
|
||||
trimSpace: (/^\s*|\s*$/g),
|
||||
removeSpace: (/\s*/g),
|
||||
splitSpace: (/\s+/),
|
||||
trimComma: (/\s*,\s*/g)
|
||||
},
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Format.WMSGetFeatureInfo
|
||||
* Create a new parser for WMS GetFeatureInfo responses
|
||||
*
|
||||
* Parameters:
|
||||
* options - {Object} An optional object whose properties will be set on
|
||||
* this instance.
|
||||
*/
|
||||
initialize: function(options) {
|
||||
OpenLayers.Format.XML.prototype.initialize.apply(this, arguments);
|
||||
OpenLayers.Util.extend(this, options);
|
||||
this.options = options;
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: read
|
||||
* Read WMS GetFeatureInfo data from a string, and return an array of features
|
||||
*
|
||||
* Parameters:
|
||||
* data - {String} or {DOMElement} data to read/parse.
|
||||
*
|
||||
* Returns:
|
||||
* {Array(<OpenLayers.Feature.Vector>)} An array of features.
|
||||
*/
|
||||
read: function(data) {
|
||||
var result;
|
||||
if(typeof data == "string") {
|
||||
data = OpenLayers.Format.XML.prototype.read.apply(this, [data]);
|
||||
}
|
||||
var root = data.documentElement;
|
||||
var scope = this;
|
||||
var read = this["read_" + root.nodeName];
|
||||
if(read) {
|
||||
result = read.call(this, root);
|
||||
} else {
|
||||
// fall-back to GML since this is a common output format for WMS
|
||||
// GetFeatureInfo responses
|
||||
result = new OpenLayers.Format.GML((this.options ? this.options : {})).read(data);
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Method: read_msGMLOutput
|
||||
* Parse msGMLOutput nodes.
|
||||
*
|
||||
* Parameters:
|
||||
* data - {DOMElement}
|
||||
*
|
||||
* Returns:
|
||||
* {Array}
|
||||
*/
|
||||
read_msGMLOutput: function(data) {
|
||||
var response = [];
|
||||
var layerNodes, n;
|
||||
layerNodes = this.getSiblingNodesByTagCriteria(data,
|
||||
this.layerIdentifier);
|
||||
if (layerNodes) {
|
||||
n = layerNodes.length;
|
||||
for (var i = 0; i < n; i++) {
|
||||
var node = layerNodes[i];
|
||||
var layerName = node.nodeName;
|
||||
if (node.prefix) {
|
||||
layerName = layerName.split(':')[1];
|
||||
}
|
||||
var layerName = layerName.replace(this.layerIdentifier, '');
|
||||
var featureNodes = this.getSiblingNodesByTagCriteria(node,
|
||||
this.featureIdentifier);
|
||||
if (featureNodes) {
|
||||
for (var j = 0; j < featureNodes.length; j++) {
|
||||
var featureNode = featureNodes[j];
|
||||
var geom = null;
|
||||
var attributes = this.parseAttributes(featureNode);
|
||||
var feature = new OpenLayers.Feature.Vector(geom,
|
||||
attributes, null);
|
||||
feature.type = layerName;
|
||||
response.push(feature);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return response;
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: read_FeatureInfoResponse
|
||||
* Parse FeatureInfoResponse nodes.
|
||||
*
|
||||
* Parameters:
|
||||
* data - {DOMElement}
|
||||
*
|
||||
* Returns:
|
||||
* {Array}
|
||||
*/
|
||||
read_FeatureInfoResponse: function(data) {
|
||||
var response = [];
|
||||
var featureNodes = this.getElementsByTagNameNS(data, '*',
|
||||
'FIELDS');
|
||||
|
||||
for(var i=0, len=featureNodes.length;i<len;i++) {
|
||||
var featureNode = featureNodes[i];
|
||||
var geom = null;
|
||||
|
||||
var attributes = {};
|
||||
for(var j=0, jlen=featureNode.attributes.length; j<jlen; j++) {
|
||||
var attribute = featureNode.attributes[j];
|
||||
attributes[attribute.nodeName] = attribute.nodeValue;
|
||||
}
|
||||
|
||||
response.push(
|
||||
new OpenLayers.Feature.Vector(geom, attributes, null)
|
||||
);
|
||||
}
|
||||
return response;
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: getSiblingNodesByTagCriteria
|
||||
* Recursively searches passed xml node and all it's descendant levels for
|
||||
* nodes whose tagName contains the passed search string. This returns an
|
||||
* array of all sibling nodes which match the criteria from the highest
|
||||
* hierarchial level from which a match is found.
|
||||
*
|
||||
* Parameters:
|
||||
* node - {DOMElement} An xml node
|
||||
* criteria - {String} Search string which will match some part of a tagName
|
||||
*
|
||||
* Returns:
|
||||
* Array({DOMElement)) An array of sibling xml nodes
|
||||
*/
|
||||
getSiblingNodesByTagCriteria: function(node, criteria){
|
||||
var nodes = [];
|
||||
var children, tagName, n, matchNodes, child;
|
||||
if (node && node.hasChildNodes()) {
|
||||
children = node.childNodes;
|
||||
n = children.length;
|
||||
child = children[0];
|
||||
while (child && child.nodeType != 1) {
|
||||
child = child.nextSibling;
|
||||
}
|
||||
tagName = (child ? child.nodeName : '');
|
||||
if (tagName.length > 0 && tagName.indexOf(criteria) > -1) {
|
||||
for (var i = 0; i < n; i++) {
|
||||
child = children[i];
|
||||
if (child.nodeType == 1) {
|
||||
nodes.push(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (var i = 0; i < n; i++) {
|
||||
matchNodes = this.getSiblingNodesByTagCriteria(
|
||||
children[i], criteria);
|
||||
(nodes.length == 0) ?
|
||||
nodes = matchNodes : nodes.push(matchNodes);
|
||||
}
|
||||
}
|
||||
}
|
||||
return nodes;
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: parseAttributes
|
||||
*
|
||||
* Parameters:
|
||||
* node - {<DOMElement>}
|
||||
*
|
||||
* Returns:
|
||||
* {Object} An attributes object.
|
||||
*
|
||||
* Notes:
|
||||
* Assumes that attributes are direct child xml nodes of the passed node
|
||||
* and contain only a single text node.
|
||||
*/
|
||||
parseAttributes: function(node){
|
||||
var attributes = {};
|
||||
if (node.nodeType == 1) {
|
||||
var children = node.childNodes;
|
||||
n = children.length
|
||||
for (var i = 0; i < n; ++i) {
|
||||
var child = children[i];
|
||||
if (child.nodeType == 1) {
|
||||
var grandchildren = child.childNodes;
|
||||
if (grandchildren.length == 1) {
|
||||
var grandchild = grandchildren[0];
|
||||
if (grandchild.nodeType == 3 ||
|
||||
grandchild.nodeType == 4) {
|
||||
var name = (child.prefix) ?
|
||||
child.nodeName.split(":")[1] : child.nodeName;
|
||||
var value = grandchild.nodeValue.replace(
|
||||
this.regExes.trimSpace, "");
|
||||
attributes[name] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return attributes;
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Format.WMSGetFeatureInfo"
|
||||
|
||||
});
|
||||
/**
|
||||
* @requires OpenLayers/Format/XML.js
|
||||
**/
|
||||
|
||||
/**
|
||||
* Class: OpenLayers.Format.WMSGetFeatureInfo
|
||||
* Class to read GetFeatureInfo responses from Web Mapping Services
|
||||
*
|
||||
* Inherits from:
|
||||
* - <OpenLayers.Format.XML>
|
||||
*/
|
||||
OpenLayers.Format.WMSGetFeatureInfo = OpenLayers.Class(OpenLayers.Format.XML, {
|
||||
|
||||
/**
|
||||
* APIProperty: layerIdentifier
|
||||
* {String} All xml nodes containing this search criteria will populate an
|
||||
* internal array of layer nodes.
|
||||
*/
|
||||
layerIdentifier: '_layer',
|
||||
|
||||
/**
|
||||
* APIProperty: featureIdentifier
|
||||
* {String} All xml nodes containing this search criteria will populate an
|
||||
* internal array of feature nodes for each layer node found.
|
||||
*/
|
||||
featureIdentifier: '_feature',
|
||||
|
||||
/**
|
||||
* Property: regExes
|
||||
* Compiled regular expressions for manipulating strings.
|
||||
*/
|
||||
regExes: {
|
||||
trimSpace: (/^\s*|\s*$/g),
|
||||
removeSpace: (/\s*/g),
|
||||
splitSpace: (/\s+/),
|
||||
trimComma: (/\s*,\s*/g)
|
||||
},
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Format.WMSGetFeatureInfo
|
||||
* Create a new parser for WMS GetFeatureInfo responses
|
||||
*
|
||||
* Parameters:
|
||||
* options - {Object} An optional object whose properties will be set on
|
||||
* this instance.
|
||||
*/
|
||||
initialize: function(options) {
|
||||
OpenLayers.Format.XML.prototype.initialize.apply(this, arguments);
|
||||
OpenLayers.Util.extend(this, options);
|
||||
this.options = options;
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: read
|
||||
* Read WMS GetFeatureInfo data from a string, and return an array of features
|
||||
*
|
||||
* Parameters:
|
||||
* data - {String} or {DOMElement} data to read/parse.
|
||||
*
|
||||
* Returns:
|
||||
* {Array(<OpenLayers.Feature.Vector>)} An array of features.
|
||||
*/
|
||||
read: function(data) {
|
||||
var result;
|
||||
if(typeof data == "string") {
|
||||
data = OpenLayers.Format.XML.prototype.read.apply(this, [data]);
|
||||
}
|
||||
var root = data.documentElement;
|
||||
var scope = this;
|
||||
var read = this["read_" + root.nodeName];
|
||||
if(read) {
|
||||
result = read.call(this, root);
|
||||
} else {
|
||||
// fall-back to GML since this is a common output format for WMS
|
||||
// GetFeatureInfo responses
|
||||
result = new OpenLayers.Format.GML((this.options ? this.options : {})).read(data);
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
read_msGMLOutput: function(data) {
|
||||
var response = [];
|
||||
var layerNodes, n;
|
||||
layerNodes = this.getSiblingNodesByTagCriteria(data,
|
||||
this.layerIdentifier);
|
||||
if (layerNodes) {
|
||||
n = layerNodes.length;
|
||||
for (var i = 0; i < n; i++) {
|
||||
var node = layerNodes[i];
|
||||
var layerName = node.nodeName;
|
||||
if (node.prefix) {
|
||||
layerName = layerName.split(':')[1];
|
||||
}
|
||||
var layerName = layerName.replace(this.layerIdentifier, '');
|
||||
var featureNodes = this.getSiblingNodesByTagCriteria(node,
|
||||
this.featureIdentifier);
|
||||
if (featureNodes) {
|
||||
for (var j = 0; j < featureNodes.length; j++) {
|
||||
var featureNode = featureNodes[j];
|
||||
var geom = null;
|
||||
var attributes = this.parseAttributes(featureNode);
|
||||
var feature = new OpenLayers.Feature.Vector(geom,
|
||||
attributes, null);
|
||||
feature.type = layerName;
|
||||
response.push(feature);
|
||||
}
|
||||
}
|
||||
}
|
||||
return response;
|
||||
}
|
||||
},
|
||||
|
||||
read_FeatureInfoResponse: function(data) {
|
||||
var response = [];
|
||||
var featureNodes = this.getElementsByTagNameNS(data, '*',
|
||||
'FIELDS');
|
||||
|
||||
for(var i=0;i<featureNodes.length;i++) {
|
||||
var featureNode = featureNodes[i];
|
||||
var geom = null;
|
||||
|
||||
var attributes = {};
|
||||
for(var j=0; j<featureNode.attributes.length; j++) {
|
||||
var attribute = featureNode.attributes[j];
|
||||
attributes[attribute.nodeName] = attribute.nodeValue;
|
||||
}
|
||||
|
||||
response.push(new OpenLayers.Feature.Vector(
|
||||
geom, attributes, null));
|
||||
}
|
||||
return response;
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: getSiblingNodesByTagCriteria
|
||||
* Recursively searches passed xml node and all it's descendant levels for
|
||||
* nodes whose tagName contains the passed search string. This returns an
|
||||
* array of all sibling nodes which match the criteria from the highest
|
||||
* hierarchial level from which a match is found.
|
||||
*
|
||||
* Parameters:
|
||||
* node - {DOMElement} An xml node
|
||||
* criteria - {String} Search string which will match some part of a tagName
|
||||
*
|
||||
* Returns:
|
||||
* Array({DOMElement)) An array of sibling xml nodes
|
||||
*/
|
||||
getSiblingNodesByTagCriteria: function(node, criteria){
|
||||
var nodes = [];
|
||||
var children, tagName, n, matchNodes, child;
|
||||
if (node && node.hasChildNodes()) {
|
||||
children = node.childNodes;
|
||||
n = children.length;
|
||||
child = children[0];
|
||||
while (child && child.nodeType != 1) {
|
||||
child = child.nextSibling;
|
||||
}
|
||||
tagName = (child ? child.nodeName : '');
|
||||
if (tagName.length > 0 && tagName.indexOf(criteria) > -1) {
|
||||
for (var i = 0; i < n; i++) {
|
||||
child = children[i];
|
||||
if (child.nodeType == 1) {
|
||||
nodes.push(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (var i = 0; i < n; i++) {
|
||||
matchNodes = this.getSiblingNodesByTagCriteria(
|
||||
children[i], criteria);
|
||||
(nodes.length == 0) ?
|
||||
nodes = matchNodes : nodes.push(matchNodes);
|
||||
}
|
||||
}
|
||||
}
|
||||
return nodes;
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: parseAttributes
|
||||
*
|
||||
* Parameters:
|
||||
* node - {<DOMElement>}
|
||||
*
|
||||
* Returns:
|
||||
* {Object} An attributes object.
|
||||
*
|
||||
* Notes:
|
||||
* Assumes that attributes are direct child xml nodes of the passed node
|
||||
* and contain only a single text node.
|
||||
*/
|
||||
parseAttributes: function(node){
|
||||
var attributes = {};
|
||||
if (node.nodeType == 1) {
|
||||
var children = node.childNodes;
|
||||
n = children.length
|
||||
for (var i = 0; i < n; ++i) {
|
||||
var child = children[i];
|
||||
if (child.nodeType == 1) {
|
||||
var grandchildren = child.childNodes;
|
||||
if (grandchildren.length == 1) {
|
||||
var grandchild = grandchildren[0];
|
||||
if (grandchild.nodeType == 3 ||
|
||||
grandchild.nodeType == 4) {
|
||||
var name = (child.prefix) ?
|
||||
child.nodeName.split(":")[1] : child.nodeName;
|
||||
var value = grandchild.nodeValue.replace(
|
||||
this.regExes.trimSpace, "");
|
||||
attributes[name] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return attributes;
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Format.WMSGetFeatureInfo"
|
||||
|
||||
});
|
||||
/**
|
||||
* @requires OpenLayers/Format/XML.js
|
||||
**/
|
||||
|
||||
/**
|
||||
* Class: OpenLayers.Format.WMSGetFeatureInfo
|
||||
* Class to read GetFeatureInfo responses from Web Mapping Services
|
||||
*
|
||||
* Inherits from:
|
||||
* - <OpenLayers.Format.XML>
|
||||
*/
|
||||
OpenLayers.Format.WMSGetFeatureInfo = OpenLayers.Class(OpenLayers.Format.XML, {
|
||||
|
||||
/**
|
||||
* APIProperty: layerIdentifier
|
||||
* {String} All xml nodes containing this search criteria will populate an
|
||||
* internal array of layer nodes.
|
||||
*/
|
||||
layerIdentifier: '_layer',
|
||||
|
||||
/**
|
||||
* APIProperty: featureIdentifier
|
||||
* {String} All xml nodes containing this search criteria will populate an
|
||||
* internal array of feature nodes for each layer node found.
|
||||
*/
|
||||
featureIdentifier: '_feature',
|
||||
|
||||
/**
|
||||
* Property: regExes
|
||||
* Compiled regular expressions for manipulating strings.
|
||||
*/
|
||||
regExes: {
|
||||
trimSpace: (/^\s*|\s*$/g),
|
||||
removeSpace: (/\s*/g),
|
||||
splitSpace: (/\s+/),
|
||||
trimComma: (/\s*,\s*/g)
|
||||
},
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Format.WMSGetFeatureInfo
|
||||
* Create a new parser for WMS GetFeatureInfo responses
|
||||
*
|
||||
* Parameters:
|
||||
* options - {Object} An optional object whose properties will be set on
|
||||
* this instance.
|
||||
*/
|
||||
initialize: function(options) {
|
||||
OpenLayers.Format.XML.prototype.initialize.apply(this, arguments);
|
||||
OpenLayers.Util.extend(this, options);
|
||||
this.options = options;
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: read
|
||||
* Read WMS GetFeatureInfo data from a string, and return an array of features
|
||||
*
|
||||
* Parameters:
|
||||
* data - {String} or {DOMElement} data to read/parse.
|
||||
*
|
||||
* Returns:
|
||||
* {Array(<OpenLayers.Feature.Vector>)} An array of features.
|
||||
*/
|
||||
read: function(data) {
|
||||
var result;
|
||||
if(typeof data == "string") {
|
||||
data = OpenLayers.Format.XML.prototype.read.apply(this, [data]);
|
||||
}
|
||||
var root = data.documentElement;
|
||||
var scope = this;
|
||||
var read = this["read_" + root.nodeName];
|
||||
if(read) {
|
||||
result = read.call(this, root);
|
||||
} else {
|
||||
// fall-back to GML since this is a common output format for WMS
|
||||
// GetFeatureInfo responses
|
||||
result = new OpenLayers.Format.GML((this.options ? this.options : {})).read(data);
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
read_msGMLOutput: function(data) {
|
||||
var response = [];
|
||||
var layerNodes, n;
|
||||
layerNodes = this.getSiblingNodesByTagCriteria(data,
|
||||
this.layerIdentifier);
|
||||
if (layerNodes) {
|
||||
n = layerNodes.length;
|
||||
for (var i = 0; i < n; i++) {
|
||||
var node = layerNodes[i];
|
||||
var layerName = node.nodeName;
|
||||
if (node.prefix) {
|
||||
layerName = layerName.split(':')[1];
|
||||
}
|
||||
var layerName = layerName.replace(this.layerIdentifier, '');
|
||||
var featureNodes = this.getSiblingNodesByTagCriteria(node,
|
||||
this.featureIdentifier);
|
||||
if (featureNodes) {
|
||||
for (var j = 0; j < featureNodes.length; j++) {
|
||||
var featureNode = featureNodes[j];
|
||||
var geom = null;
|
||||
var attributes = this.parseAttributes(featureNode);
|
||||
var feature = new OpenLayers.Feature.Vector(geom,
|
||||
attributes, null);
|
||||
feature.type = layerName;
|
||||
response.push(feature);
|
||||
}
|
||||
}
|
||||
}
|
||||
return response;
|
||||
}
|
||||
},
|
||||
|
||||
read_FeatureInfoResponse: function(data) {
|
||||
var response = [];
|
||||
var featureNodes = this.getElementsByTagNameNS(data, '*',
|
||||
'FIELDS');
|
||||
|
||||
for(var i=0;i<featureNodes.length;i++) {
|
||||
var featureNode = featureNodes[i];
|
||||
var geom = null;
|
||||
|
||||
var attributes = {};
|
||||
for(var j=0; j<featureNode.attributes.length; j++) {
|
||||
var attribute = featureNode.attributes[j];
|
||||
attributes[attribute.nodeName] = attribute.nodeValue;
|
||||
}
|
||||
|
||||
response.push(new OpenLayers.Feature.Vector(
|
||||
geom, attributes, null));
|
||||
}
|
||||
return response;
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: getSiblingNodesByTagCriteria
|
||||
* Recursively searches passed xml node and all it's descendant levels for
|
||||
* nodes whose tagName contains the passed search string. This returns an
|
||||
* array of all sibling nodes which match the criteria from the highest
|
||||
* hierarchial level from which a match is found.
|
||||
*
|
||||
* Parameters:
|
||||
* node - {DOMElement} An xml node
|
||||
* criteria - {String} Search string which will match some part of a tagName
|
||||
*
|
||||
* Returns:
|
||||
* Array({DOMElement)) An array of sibling xml nodes
|
||||
*/
|
||||
getSiblingNodesByTagCriteria: function(node, criteria){
|
||||
var nodes = [];
|
||||
var children, tagName, n, matchNodes, child;
|
||||
if (node && node.hasChildNodes()) {
|
||||
children = node.childNodes;
|
||||
n = children.length;
|
||||
child = children[0];
|
||||
while (child && child.nodeType != 1) {
|
||||
child = child.nextSibling;
|
||||
}
|
||||
tagName = (child ? child.nodeName : '');
|
||||
if (tagName.length > 0 && tagName.indexOf(criteria) > -1) {
|
||||
for (var i = 0; i < n; i++) {
|
||||
child = children[i];
|
||||
if (child.nodeType == 1) {
|
||||
nodes.push(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (var i = 0; i < n; i++) {
|
||||
matchNodes = this.getSiblingNodesByTagCriteria(
|
||||
children[i], criteria);
|
||||
(nodes.length == 0) ?
|
||||
nodes = matchNodes : nodes.push(matchNodes);
|
||||
}
|
||||
}
|
||||
}
|
||||
return nodes;
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: parseAttributes
|
||||
*
|
||||
* Parameters:
|
||||
* node - {<DOMElement>}
|
||||
*
|
||||
* Returns:
|
||||
* {Object} An attributes object.
|
||||
*
|
||||
* Notes:
|
||||
* Assumes that attributes are direct child xml nodes of the passed node
|
||||
* and contain only a single text node.
|
||||
*/
|
||||
parseAttributes: function(node){
|
||||
var attributes = {};
|
||||
if (node.nodeType == 1) {
|
||||
var children = node.childNodes;
|
||||
n = children.length
|
||||
for (var i = 0; i < n; ++i) {
|
||||
var child = children[i];
|
||||
if (child.nodeType == 1) {
|
||||
var grandchildren = child.childNodes;
|
||||
if (grandchildren.length == 1) {
|
||||
var grandchild = grandchildren[0];
|
||||
if (grandchild.nodeType == 3 ||
|
||||
grandchild.nodeType == 4) {
|
||||
var name = (child.prefix) ?
|
||||
child.nodeName.split(":")[1] : child.nodeName;
|
||||
var value = grandchild.nodeValue.replace(
|
||||
this.regExes.trimSpace, "");
|
||||
attributes[name] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return attributes;
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Format.WMSGetFeatureInfo"
|
||||
|
||||
});
|
||||
717
tests/Format/WMSGetFeatureInfo.html
Normal file
717
tests/Format/WMSGetFeatureInfo.html
Normal file
@@ -0,0 +1,717 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
function test_read_FeatureInfoResponse(t) {
|
||||
t.plan(5);
|
||||
|
||||
var parser = new OpenLayers.Format.WMSGetFeatureInfo();
|
||||
|
||||
// read empty response
|
||||
var text =
|
||||
'<?xml version="1.0" encoding="UTF-8" ?>' +
|
||||
'<FeatureInfoResponse>' +
|
||||
'</FeatureInfoResponse>';
|
||||
|
||||
var features = parser.read(text);
|
||||
t.eq(features.length, 0,
|
||||
"Parsing empty FeatureInfoResponse response succesfull");
|
||||
|
||||
// read 1 feature
|
||||
text =
|
||||
'<?xml version="1.0" encoding="UTF-8" ?>' +
|
||||
'<FeatureInfoResponse>' +
|
||||
' <FIELDS OBJECTID="1188" HECTARES="1819.734" ZONENR="5854" NULZONES=" " AREA="18197340.1426" PERIMETER="19177.4073627" SHAPE="NULL" SE_ANNO_CAD_DATA="NULL" SHAPE.AREA="0" SHAPE.LEN="0"/>' +
|
||||
'</FeatureInfoResponse>';
|
||||
|
||||
features = parser.read(text);
|
||||
t.eq(features.length, 1,
|
||||
"Parsed 1 feature in total");
|
||||
|
||||
t.eq(features[0].attributes.OBJECTID, '1188',
|
||||
"Attribute OBJECTID contains the right value");
|
||||
|
||||
// read multiple features
|
||||
text =
|
||||
'<?xml version="1.0" encoding="UTF-8" ?>' +
|
||||
'<FeatureInfoResponse>' +
|
||||
' <FIELDS OBJECTID="551" Shape="NULL" NAME="Carbon" STATE_NAME="Wyoming" AREA="7999.91062" POP2000="15639" POP00_SQMI="2" Shape_Length="6.61737274334215" Shape_Area="2.23938983524154"/>' +
|
||||
' <FIELDS OBJECTID="7" Shape="NULL" AREA="97803.199" STATE_NAME="Wyoming" SUB_REGION="Mtn" STATE_ABBR="WY" POP2000="493782" POP00_SQMI="5" Shape_Length="21.9870297323522" Shape_Area="27.9666881382635"/>' +
|
||||
' <FIELDS OBJECTID="99" Shape="NULL" LENGTH="378.836" TYPE="Multi-Lane Divided" ADMN_CLASS="Interstate" TOLL_RD="N" RTE_NUM1=" 80" RTE_NUM2=" " ROUTE="Interstate 80" Shape_Length="7.04294883879398"/>' +
|
||||
'</FeatureInfoResponse>';
|
||||
|
||||
features = parser.read(text);
|
||||
|
||||
t.eq(features.length, 3,
|
||||
"Parsed 3 features in total");
|
||||
|
||||
t.eq(features[1].attributes.STATE_NAME, 'Wyoming',
|
||||
"Attribute STATE_NAME contains the right value");
|
||||
|
||||
}
|
||||
|
||||
function test_read_msGMLOutput(t) {
|
||||
t.plan(6);
|
||||
|
||||
var parser = new OpenLayers.Format.WMSGetFeatureInfo();
|
||||
|
||||
// read empty response
|
||||
var text =
|
||||
'<?xml version="1.0" encoding="ISO-8859-1"?>' +
|
||||
'<msGMLOutput ' +
|
||||
' xmlns:gml="http://www.opengis.net/gml"' +
|
||||
' xmlns:xlink="http://www.w3.org/1999/xlink"' +
|
||||
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">' +
|
||||
'</msGMLOutput>';
|
||||
|
||||
var features = parser.read(text);
|
||||
t.eq(features.length, 0,
|
||||
"Parsing empty msGMLOutput response succesfull");
|
||||
|
||||
// read 1 feature from 1 layer
|
||||
text =
|
||||
'<?xml version="1.0" encoding="ISO-8859-1"?>' +
|
||||
'<msGMLOutput ' +
|
||||
' xmlns:gml="http://www.opengis.net/gml"' +
|
||||
' xmlns:xlink="http://www.w3.org/1999/xlink"' +
|
||||
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">' +
|
||||
' <AAA64_layer>' +
|
||||
' <AAA64_feature>' +
|
||||
' <gml:boundedBy>' +
|
||||
' <gml:Box srsName="EPSG:28992">' +
|
||||
' <gml:coordinates>107397.266000,460681.063000 116568.188000,480609.250000</gml:coordinates>' +
|
||||
' </gml:Box>' +
|
||||
' </gml:boundedBy>' +
|
||||
' <OBJECTID>109</OBJECTID>' +
|
||||
' <ROUTE>N231</ROUTE>' +
|
||||
' <ROUTE_CH>#N231</ROUTE_CH>' +
|
||||
' <COUNT>2</COUNT>' +
|
||||
' <BEHEERDER>P</BEHEERDER>' +
|
||||
' <LENGTH>28641.7</LENGTH>' +
|
||||
' <SHAPE><shape></SHAPE>' +
|
||||
' <SE_ANNO_CAD_DATA><null></SE_ANNO_CAD_DATA>' +
|
||||
' </AAA64_feature>' +
|
||||
' </AAA64_layer>' +
|
||||
'</msGMLOutput>';
|
||||
|
||||
features = parser.read(text);
|
||||
t.eq(features.length, 1,
|
||||
"Parsed 1 feature in total");
|
||||
|
||||
t.eq(features[0].attributes.OBJECTID, '109',
|
||||
"Attribute OBJECTID contains the right value");
|
||||
|
||||
t.eq(features[0].type, 'AAA64',
|
||||
"Parsed the layer name correctly");
|
||||
|
||||
// read 2 features from 2 layers
|
||||
text =
|
||||
'<?xml version="1.0" encoding="ISO-8859-1"?>' +
|
||||
'<msGMLOutput ' +
|
||||
' xmlns:gml="http://www.opengis.net/gml"' +
|
||||
' xmlns:xlink="http://www.w3.org/1999/xlink"' +
|
||||
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">'+
|
||||
' <AAA64_layer>' +
|
||||
' <AAA64_feature>' +
|
||||
' <gml:boundedBy>' +
|
||||
' <gml:Box srsName="EPSG:28992">' +
|
||||
' <gml:coordinates>129799.109000,467950.250000 133199.906000,468904.063000</gml:coordinates>' +
|
||||
' </gml:Box>' +
|
||||
' </gml:boundedBy>' +
|
||||
' <OBJECTID>287</OBJECTID>' +
|
||||
' <ROUTE>N403</ROUTE>' +
|
||||
' <ROUTE_CH>#N403</ROUTE_CH>' +
|
||||
' <COUNT>1</COUNT>' +
|
||||
' <BEHEERDER>P</BEHEERDER>' +
|
||||
' <LENGTH>4091.25</LENGTH>' +
|
||||
' <SHAPE><shape></SHAPE>' +
|
||||
' <SE_ANNO_CAD_DATA><null></SE_ANNO_CAD_DATA>' +
|
||||
' </AAA64_feature>' +
|
||||
' </AAA64_layer>' +
|
||||
' <AAA62_layer>' +
|
||||
' <AAA62_feature>' +
|
||||
' <gml:boundedBy>' +
|
||||
' <gml:Box srsName="EPSG:28992">' +
|
||||
' <gml:coordinates>129936.000000,468362.000000 131686.000000,473119.000000</gml:coordinates>' +
|
||||
' </gml:Box>' +
|
||||
' </gml:boundedBy>' +
|
||||
' <OBJECTID>1251</OBJECTID>' +
|
||||
' <VWK_ID>1515</VWK_ID>' +
|
||||
' <VWK_BEGDTM>00:00:00 01/01/1998</VWK_BEGDTM>' +
|
||||
' <VWJ_ID_BEG>1472</VWJ_ID_BEG>' +
|
||||
' <VWJ_ID_END>1309</VWJ_ID_END>' +
|
||||
' <VAKTYPE>D</VAKTYPE>' +
|
||||
' <VRT_CODE>227</VRT_CODE>' +
|
||||
' <VRT_NAAM>Vecht</VRT_NAAM>' +
|
||||
' <VWG_NR>2</VWG_NR>' +
|
||||
' <VWG_NAAM>Vecht</VWG_NAAM>' +
|
||||
' <BEGKM>18.25</BEGKM>' +
|
||||
' <ENDKM>23.995</ENDKM>' +
|
||||
' <LENGTH>5745.09</LENGTH>' +
|
||||
' <SHAPE><shape></SHAPE>' +
|
||||
' <SE_ANNO_CAD_DATA><null></SE_ANNO_CAD_DATA>' +
|
||||
' </AAA62_feature>' +
|
||||
' </AAA62_layer>' +
|
||||
'</msGMLOutput>';
|
||||
|
||||
features = parser.read(text);
|
||||
|
||||
t.eq(features.length, 2,
|
||||
"Parsed 2 features in total");
|
||||
|
||||
t.eq((features[0].type == features[1].type), false,
|
||||
"The layer name differs for the two features");
|
||||
|
||||
}
|
||||
|
||||
function test_read_GMLFeatureInfoResponse(t) {
|
||||
t.plan(4);
|
||||
|
||||
var parser = new OpenLayers.Format.WMSGetFeatureInfo();
|
||||
|
||||
// read Ionic response, see if parser falls back to GML format
|
||||
// url used:
|
||||
/* http://webservices.ionicsoft.com/ionicweb/wfs/BOSTON_ORA?service=WMS&request=GetFeatureInfo&layers=roads&version=1.1.1&bbox=-71.1,42.25,-71.05,42.3&width=500&height=500&format=image/png&SRS=EPSG:4326&styles=&x=174&y=252&query_layers=roads&info_format=application/vnd.ogc.gml */
|
||||
var text =
|
||||
"<?xml version='1.0' encoding='utf-8' ?>" +
|
||||
' <ogcwfs:FeatureCollection xsi:schemaLocation="http://www.ionicsoft.com/wfs http://webservices.ionicsoft.com/ionicweb/wfs/BOSTON_ORA?REQUEST=DescribeAllFeatureType&SERVICE=WFS http://www.opengis.net/wfs http://webservices.ionicsoft.com/ionicweb/wfs/BOSTON_ORA/REQUEST/get/DATA/LPR/wfs/1.0.0/WFS-basic.xsd" xmlns:wfs="http://www.ionicsoft.com/wfs" xmlns:gml="http://www.opengis.net/gml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ogcwfs="http://www.opengis.net/wfs">' +
|
||||
' <gml:boundedBy>' +
|
||||
' <gml:Box srsName="EPSG:4326">' +
|
||||
' <gml:coordinates>-71.08301710045646,42.27320863544783 -71.08020014900377,42.27480054530114</gml:coordinates>' +
|
||||
' </gml:Box>' +
|
||||
' </gml:boundedBy>' +
|
||||
' <gml:featureMember>' +
|
||||
' <wfs:roads fid="roads.9453.0">' +
|
||||
' <wfs:FNODE_>8943.0</wfs:FNODE_>' +
|
||||
' <wfs:TNODE_>9070.0</wfs:TNODE_>' +
|
||||
' <wfs:LPOLY_>0.0</wfs:LPOLY_>' +
|
||||
' <wfs:RPOLY_>0.0</wfs:RPOLY_>' +
|
||||
' <wfs:LENGTH>306.875</wfs:LENGTH>' +
|
||||
' <wfs:MRD_>13109.0</wfs:MRD_>' +
|
||||
' <wfs:MRD_ID>9453.0</wfs:MRD_ID>' +
|
||||
' <wfs:TILE_NAME>126</wfs:TILE_NAME>' +
|
||||
' <wfs:COUNTYCODE>M</wfs:COUNTYCODE>' +
|
||||
' <wfs:SERIAL_NUM>26000.0</wfs:SERIAL_NUM>' +
|
||||
' <wfs:CLASS>5.0</wfs:CLASS>' +
|
||||
' <wfs:ADMIN_TYPE>0.0</wfs:ADMIN_TYPE>' +
|
||||
' <wfs:ALTRT1TYPE>0.0</wfs:ALTRT1TYPE>' +
|
||||
' <wfs:STREETNAME>DOCTOR MARY MOORE BEATTY CIRCLE</wfs:STREETNAME>' +
|
||||
' <wfs:CSN>M 26000</wfs:CSN>' +
|
||||
' <wfs:GEOMETRY>' +
|
||||
' <gml:LineString srsName="EPSG:4326">' +
|
||||
' <gml:coordinates>-71.08300668868151,42.27480054530114 -71.08155305289881,42.27452010256956 -71.08021063085208,42.27320863544783</gml:coordinates>' +
|
||||
' </gml:LineString>' +
|
||||
' </wfs:GEOMETRY>' +
|
||||
' </wfs:roads>' +
|
||||
' </gml:featureMember>' +
|
||||
' </ogcwfs:FeatureCollection>';
|
||||
|
||||
var features = parser.read(text);
|
||||
|
||||
t.eq(features.length, 1,
|
||||
"Parsing GML GetFeatureInfo response from Ionic succesfull");
|
||||
|
||||
t.eq(features[0].attributes.TILE_NAME, '126',
|
||||
"Attribute TILE_NAME contains the right value");
|
||||
|
||||
// read Geoserver response
|
||||
// taken from:
|
||||
/* http://demo.opengeo.org/geoserver/wms?service=WMS&request=GetFeatureInfo&layers=opengeo:roads&query_layers=opengeo:roads&format=image/png&version=1.1.1&styles=&bbox=-103.9,44.4,-103.7,44.5&srs=EPSG:4326&width=500&height=500&x=158&y=98&info_format=application/vnd.ogc.gml*/
|
||||
|
||||
text = '<?xml version="1.0" encoding="UTF-8"?><wfs:FeatureCollection xmlns="http://www.opengis.net/wfs" xmlns:wfs="http://www.opengis.net/wfs" xmlns:opengeo="http://opengeo.org" xmlns:gml="http://www.opengis.net/gml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://opengeo.org http://demo.opengeo.org:80/geoserver/wfs?service=WFS&version=1.0.0&request=DescribeFeatureType&typeName=opengeo:roads http://www.opengis.net/wfs http://demo.opengeo.org:80/geoserver/schemas/wfs/1.0.0/WFS-basic.xsd"><gml:boundedBy><gml:Box srsName="http://www.opengis.net/gml/srs/epsg.xml#26713"><gml:coordinates xmlns:gml="http://www.opengis.net/gml" decimal="." cs="," ts=" ">591943.9375,4925605 593045.625,4925845</gml:coordinates></gml:Box></gml:boundedBy><gml:featureMember><opengeo:roads fid="roads.90"><opengeo:cat>3</opengeo:cat><opengeo:label>secondary highway, hard surface</opengeo:label><opengeo:the_geom><gml:MultiLineString srsName="http://www.opengis.net/gml/srs/epsg.xml#26713"><gml:lineStringMember><gml:LineString><gml:coordinates xmlns:gml="http://www.opengis.net/gml" decimal="." cs="," ts=" ">593045.60746465,4925605.0059156 593024.32382915,4925606.79305411 592907.54863574,4925624.85647524 592687.35111096,4925670.76834012 592430.76279218,4925678.79393165 592285.97636109,4925715.70811767 592173.39165655,4925761.83511156 592071.1753393,4925793.95523514 591985.96972625,4925831.59842486 591943.98769455,4925844.93220071</gml:coordinates></gml:LineString></gml:lineStringMember></gml:MultiLineString></opengeo:the_geom></opengeo:roads></gml:featureMember></wfs:FeatureCollection>';
|
||||
|
||||
features = parser.read(text);
|
||||
|
||||
t.eq(features.length, 1,
|
||||
"Parsing GML GetFeatureInfo response from Geoserver succesfull");
|
||||
|
||||
t.eq(features[0].attributes.cat, '3',
|
||||
"Attribute cat contains the right value");
|
||||
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
<html>
|
||||
<head>
|
||||
<script src="../../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
function test_read_FeatureInfoResponse(t) {
|
||||
t.plan(5);
|
||||
|
||||
var parser = new OpenLayers.Format.WMSGetFeatureInfo();
|
||||
|
||||
// read empty response
|
||||
var text =
|
||||
'<?xml version="1.0" encoding="UTF-8" ?>' +
|
||||
'<FeatureInfoResponse>' +
|
||||
'</FeatureInfoResponse>';
|
||||
|
||||
var features = parser.read(text);
|
||||
t.eq(features.length, 0,
|
||||
"Parsing empty FeatureInfoResponse response succesfull");
|
||||
|
||||
// read 1 feature
|
||||
text =
|
||||
'<?xml version="1.0" encoding="UTF-8" ?>' +
|
||||
'<FeatureInfoResponse>' +
|
||||
' <FIELDS OBJECTID="1188" HECTARES="1819.734" ZONENR="5854" NULZONES=" " AREA="18197340.1426" PERIMETER="19177.4073627" SHAPE="NULL" SE_ANNO_CAD_DATA="NULL" SHAPE.AREA="0" SHAPE.LEN="0"/>' +
|
||||
'</FeatureInfoResponse>';
|
||||
|
||||
features = parser.read(text);
|
||||
t.eq(features.length, 1,
|
||||
"Parsed 1 feature in total");
|
||||
|
||||
t.eq(features[0].attributes.OBJECTID, '1188',
|
||||
"Attribute OBJECTID contains the right value");
|
||||
|
||||
// read multiple features
|
||||
text =
|
||||
'<?xml version="1.0" encoding="UTF-8" ?>' +
|
||||
'<FeatureInfoResponse>' +
|
||||
' <FIELDS OBJECTID="551" Shape="NULL" NAME="Carbon" STATE_NAME="Wyoming" AREA="7999.91062" POP2000="15639" POP00_SQMI="2" Shape_Length="6.61737274334215" Shape_Area="2.23938983524154"/>' +
|
||||
' <FIELDS OBJECTID="7" Shape="NULL" AREA="97803.199" STATE_NAME="Wyoming" SUB_REGION="Mtn" STATE_ABBR="WY" POP2000="493782" POP00_SQMI="5" Shape_Length="21.9870297323522" Shape_Area="27.9666881382635"/>' +
|
||||
' <FIELDS OBJECTID="99" Shape="NULL" LENGTH="378.836" TYPE="Multi-Lane Divided" ADMN_CLASS="Interstate" TOLL_RD="N" RTE_NUM1=" 80" RTE_NUM2=" " ROUTE="Interstate 80" Shape_Length="7.04294883879398"/>' +
|
||||
'</FeatureInfoResponse>';
|
||||
|
||||
features = parser.read(text);
|
||||
|
||||
t.eq(features.length, 3,
|
||||
"Parsed 3 features in total");
|
||||
|
||||
t.eq(features[1].attributes.STATE_NAME, 'Wyoming',
|
||||
"Attribute STATE_NAME contains the right value");
|
||||
|
||||
}
|
||||
|
||||
function test_read_msGMLOutput(t) {
|
||||
t.plan(6);
|
||||
|
||||
var parser = new OpenLayers.Format.WMSGetFeatureInfo();
|
||||
|
||||
// read empty response
|
||||
var text =
|
||||
'<?xml version="1.0" encoding="ISO-8859-1"?>' +
|
||||
'<msGMLOutput ' +
|
||||
' xmlns:gml="http://www.opengis.net/gml"' +
|
||||
' xmlns:xlink="http://www.w3.org/1999/xlink"' +
|
||||
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">' +
|
||||
'</msGMLOutput>';
|
||||
|
||||
var features = parser.read(text);
|
||||
t.eq(features.length, 0,
|
||||
"Parsing empty msGMLOutput response succesfull");
|
||||
|
||||
// read 1 feature from 1 layer
|
||||
text =
|
||||
'<?xml version="1.0" encoding="ISO-8859-1"?>' +
|
||||
'<msGMLOutput ' +
|
||||
' xmlns:gml="http://www.opengis.net/gml"' +
|
||||
' xmlns:xlink="http://www.w3.org/1999/xlink"' +
|
||||
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">' +
|
||||
' <AAA64_layer>' +
|
||||
' <AAA64_feature>' +
|
||||
' <gml:boundedBy>' +
|
||||
' <gml:Box srsName="EPSG:28992">' +
|
||||
' <gml:coordinates>107397.266000,460681.063000 116568.188000,480609.250000</gml:coordinates>' +
|
||||
' </gml:Box>' +
|
||||
' </gml:boundedBy>' +
|
||||
' <OBJECTID>109</OBJECTID>' +
|
||||
' <ROUTE>N231</ROUTE>' +
|
||||
' <ROUTE_CH>#N231</ROUTE_CH>' +
|
||||
' <COUNT>2</COUNT>' +
|
||||
' <BEHEERDER>P</BEHEERDER>' +
|
||||
' <LENGTH>28641.7</LENGTH>' +
|
||||
' <SHAPE><shape></SHAPE>' +
|
||||
' <SE_ANNO_CAD_DATA><null></SE_ANNO_CAD_DATA>' +
|
||||
' </AAA64_feature>' +
|
||||
' </AAA64_layer>' +
|
||||
'</msGMLOutput>';
|
||||
|
||||
features = parser.read(text);
|
||||
t.eq(features.length, 1,
|
||||
"Parsed 1 feature in total");
|
||||
|
||||
t.eq(features[0].attributes.OBJECTID, '109',
|
||||
"Attribute OBJECTID contains the right value");
|
||||
|
||||
t.eq(features[0].type, 'AAA64',
|
||||
"Parsed the layer name correctly");
|
||||
|
||||
// read 2 features from 2 layers
|
||||
text =
|
||||
'<?xml version="1.0" encoding="ISO-8859-1"?>' +
|
||||
'<msGMLOutput ' +
|
||||
' xmlns:gml="http://www.opengis.net/gml"' +
|
||||
' xmlns:xlink="http://www.w3.org/1999/xlink"' +
|
||||
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">'+
|
||||
' <AAA64_layer>' +
|
||||
' <AAA64_feature>' +
|
||||
' <gml:boundedBy>' +
|
||||
' <gml:Box srsName="EPSG:28992">' +
|
||||
' <gml:coordinates>129799.109000,467950.250000 133199.906000,468904.063000</gml:coordinates>' +
|
||||
' </gml:Box>' +
|
||||
' </gml:boundedBy>' +
|
||||
' <OBJECTID>287</OBJECTID>' +
|
||||
' <ROUTE>N403</ROUTE>' +
|
||||
' <ROUTE_CH>#N403</ROUTE_CH>' +
|
||||
' <COUNT>1</COUNT>' +
|
||||
' <BEHEERDER>P</BEHEERDER>' +
|
||||
' <LENGTH>4091.25</LENGTH>' +
|
||||
' <SHAPE><shape></SHAPE>' +
|
||||
' <SE_ANNO_CAD_DATA><null></SE_ANNO_CAD_DATA>' +
|
||||
' </AAA64_feature>' +
|
||||
' </AAA64_layer>' +
|
||||
' <AAA62_layer>' +
|
||||
' <AAA62_feature>' +
|
||||
' <gml:boundedBy>' +
|
||||
' <gml:Box srsName="EPSG:28992">' +
|
||||
' <gml:coordinates>129936.000000,468362.000000 131686.000000,473119.000000</gml:coordinates>' +
|
||||
' </gml:Box>' +
|
||||
' </gml:boundedBy>' +
|
||||
' <OBJECTID>1251</OBJECTID>' +
|
||||
' <VWK_ID>1515</VWK_ID>' +
|
||||
' <VWK_BEGDTM>00:00:00 01/01/1998</VWK_BEGDTM>' +
|
||||
' <VWJ_ID_BEG>1472</VWJ_ID_BEG>' +
|
||||
' <VWJ_ID_END>1309</VWJ_ID_END>' +
|
||||
' <VAKTYPE>D</VAKTYPE>' +
|
||||
' <VRT_CODE>227</VRT_CODE>' +
|
||||
' <VRT_NAAM>Vecht</VRT_NAAM>' +
|
||||
' <VWG_NR>2</VWG_NR>' +
|
||||
' <VWG_NAAM>Vecht</VWG_NAAM>' +
|
||||
' <BEGKM>18.25</BEGKM>' +
|
||||
' <ENDKM>23.995</ENDKM>' +
|
||||
' <LENGTH>5745.09</LENGTH>' +
|
||||
' <SHAPE><shape></SHAPE>' +
|
||||
' <SE_ANNO_CAD_DATA><null></SE_ANNO_CAD_DATA>' +
|
||||
' </AAA62_feature>' +
|
||||
' </AAA62_layer>' +
|
||||
'</msGMLOutput>';
|
||||
|
||||
features = parser.read(text);
|
||||
|
||||
t.eq(features.length, 2,
|
||||
"Parsed 2 features in total");
|
||||
|
||||
t.eq((features[0].type == features[1].type), false,
|
||||
"The layer name differs for the two features");
|
||||
|
||||
}
|
||||
|
||||
function test_read_GMLFeatureInfoResponse(t) {
|
||||
t.plan(4);
|
||||
|
||||
var parser = new OpenLayers.Format.WMSGetFeatureInfo();
|
||||
|
||||
// read Ionic response, see if parser falls back to GML format
|
||||
// url used:
|
||||
/* http://webservices.ionicsoft.com/ionicweb/wfs/BOSTON_ORA?service=WMS&request=GetFeatureInfo&layers=roads&version=1.1.1&bbox=-71.1,42.25,-71.05,42.3&width=500&height=500&format=image/png&SRS=EPSG:4326&styles=&x=174&y=252&query_layers=roads&info_format=application/vnd.ogc.gml */
|
||||
var text =
|
||||
"<?xml version='1.0' encoding='utf-8' ?>" +
|
||||
' <ogcwfs:FeatureCollection xsi:schemaLocation="http://www.ionicsoft.com/wfs http://webservices.ionicsoft.com/ionicweb/wfs/BOSTON_ORA?REQUEST=DescribeAllFeatureType&SERVICE=WFS http://www.opengis.net/wfs http://webservices.ionicsoft.com/ionicweb/wfs/BOSTON_ORA/REQUEST/get/DATA/LPR/wfs/1.0.0/WFS-basic.xsd" xmlns:wfs="http://www.ionicsoft.com/wfs" xmlns:gml="http://www.opengis.net/gml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ogcwfs="http://www.opengis.net/wfs">' +
|
||||
' <gml:boundedBy>' +
|
||||
' <gml:Box srsName="EPSG:4326">' +
|
||||
' <gml:coordinates>-71.08301710045646,42.27320863544783 -71.08020014900377,42.27480054530114</gml:coordinates>' +
|
||||
' </gml:Box>' +
|
||||
' </gml:boundedBy>' +
|
||||
' <gml:featureMember>' +
|
||||
' <wfs:roads fid="roads.9453.0">' +
|
||||
' <wfs:FNODE_>8943.0</wfs:FNODE_>' +
|
||||
' <wfs:TNODE_>9070.0</wfs:TNODE_>' +
|
||||
' <wfs:LPOLY_>0.0</wfs:LPOLY_>' +
|
||||
' <wfs:RPOLY_>0.0</wfs:RPOLY_>' +
|
||||
' <wfs:LENGTH>306.875</wfs:LENGTH>' +
|
||||
' <wfs:MRD_>13109.0</wfs:MRD_>' +
|
||||
' <wfs:MRD_ID>9453.0</wfs:MRD_ID>' +
|
||||
' <wfs:TILE_NAME>126</wfs:TILE_NAME>' +
|
||||
' <wfs:COUNTYCODE>M</wfs:COUNTYCODE>' +
|
||||
' <wfs:SERIAL_NUM>26000.0</wfs:SERIAL_NUM>' +
|
||||
' <wfs:CLASS>5.0</wfs:CLASS>' +
|
||||
' <wfs:ADMIN_TYPE>0.0</wfs:ADMIN_TYPE>' +
|
||||
' <wfs:ALTRT1TYPE>0.0</wfs:ALTRT1TYPE>' +
|
||||
' <wfs:STREETNAME>DOCTOR MARY MOORE BEATTY CIRCLE</wfs:STREETNAME>' +
|
||||
' <wfs:CSN>M 26000</wfs:CSN>' +
|
||||
' <wfs:GEOMETRY>' +
|
||||
' <gml:LineString srsName="EPSG:4326">' +
|
||||
' <gml:coordinates>-71.08300668868151,42.27480054530114 -71.08155305289881,42.27452010256956 -71.08021063085208,42.27320863544783</gml:coordinates>' +
|
||||
' </gml:LineString>' +
|
||||
' </wfs:GEOMETRY>' +
|
||||
' </wfs:roads>' +
|
||||
' </gml:featureMember>' +
|
||||
' </ogcwfs:FeatureCollection>';
|
||||
|
||||
var features = parser.read(text);
|
||||
|
||||
t.eq(features.length, 1,
|
||||
"Parsing GML GetFeatureInfo response from Ionic succesfull");
|
||||
|
||||
t.eq(features[0].attributes.TILE_NAME, '126',
|
||||
"Attribute TILE_NAME contains the right value");
|
||||
|
||||
// read Geoserver response
|
||||
// taken from:
|
||||
/* http://demo.opengeo.org/geoserver/wms?service=WMS&request=GetFeatureInfo&layers=opengeo:roads&query_layers=opengeo:roads&format=image/png&version=1.1.1&styles=&bbox=-103.9,44.4,-103.7,44.5&srs=EPSG:4326&width=500&height=500&x=158&y=98&info_format=application/vnd.ogc.gml*/
|
||||
|
||||
text = '<?xml version="1.0" encoding="UTF-8"?><wfs:FeatureCollection xmlns="http://www.opengis.net/wfs" xmlns:wfs="http://www.opengis.net/wfs" xmlns:opengeo="http://opengeo.org" xmlns:gml="http://www.opengis.net/gml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://opengeo.org http://demo.opengeo.org:80/geoserver/wfs?service=WFS&version=1.0.0&request=DescribeFeatureType&typeName=opengeo:roads http://www.opengis.net/wfs http://demo.opengeo.org:80/geoserver/schemas/wfs/1.0.0/WFS-basic.xsd"><gml:boundedBy><gml:Box srsName="http://www.opengis.net/gml/srs/epsg.xml#26713"><gml:coordinates xmlns:gml="http://www.opengis.net/gml" decimal="." cs="," ts=" ">591943.9375,4925605 593045.625,4925845</gml:coordinates></gml:Box></gml:boundedBy><gml:featureMember><opengeo:roads fid="roads.90"><opengeo:cat>3</opengeo:cat><opengeo:label>secondary highway, hard surface</opengeo:label><opengeo:the_geom><gml:MultiLineString srsName="http://www.opengis.net/gml/srs/epsg.xml#26713"><gml:lineStringMember><gml:LineString><gml:coordinates xmlns:gml="http://www.opengis.net/gml" decimal="." cs="," ts=" ">593045.60746465,4925605.0059156 593024.32382915,4925606.79305411 592907.54863574,4925624.85647524 592687.35111096,4925670.76834012 592430.76279218,4925678.79393165 592285.97636109,4925715.70811767 592173.39165655,4925761.83511156 592071.1753393,4925793.95523514 591985.96972625,4925831.59842486 591943.98769455,4925844.93220071</gml:coordinates></gml:LineString></gml:lineStringMember></gml:MultiLineString></opengeo:the_geom></opengeo:roads></gml:featureMember></wfs:FeatureCollection>';
|
||||
|
||||
features = parser.read(text);
|
||||
|
||||
t.eq(features.length, 1,
|
||||
"Parsing GML GetFeatureInfo response from Geoserver succesfull");
|
||||
|
||||
t.eq(features[0].attributes.cat, '3',
|
||||
"Attribute cat contains the right value");
|
||||
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
<html>
|
||||
<head>
|
||||
<script src="../../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
function test_read_FeatureInfoResponse(t) {
|
||||
t.plan(5);
|
||||
|
||||
var parser = new OpenLayers.Format.WMSGetFeatureInfo();
|
||||
|
||||
// read empty response
|
||||
var text =
|
||||
'<?xml version="1.0" encoding="UTF-8" ?>' +
|
||||
'<FeatureInfoResponse>' +
|
||||
'</FeatureInfoResponse>';
|
||||
|
||||
var features = parser.read(text);
|
||||
t.eq(features.length, 0,
|
||||
"Parsing empty FeatureInfoResponse response succesfull");
|
||||
|
||||
// read 1 feature
|
||||
text =
|
||||
'<?xml version="1.0" encoding="UTF-8" ?>' +
|
||||
'<FeatureInfoResponse>' +
|
||||
' <FIELDS OBJECTID="1188" HECTARES="1819.734" ZONENR="5854" NULZONES=" " AREA="18197340.1426" PERIMETER="19177.4073627" SHAPE="NULL" SE_ANNO_CAD_DATA="NULL" SHAPE.AREA="0" SHAPE.LEN="0"/>' +
|
||||
'</FeatureInfoResponse>';
|
||||
|
||||
features = parser.read(text);
|
||||
t.eq(features.length, 1,
|
||||
"Parsed 1 feature in total");
|
||||
|
||||
t.eq(features[0].attributes.OBJECTID, '1188',
|
||||
"Attribute OBJECTID contains the right value");
|
||||
|
||||
// read multiple features
|
||||
text =
|
||||
'<?xml version="1.0" encoding="UTF-8" ?>' +
|
||||
'<FeatureInfoResponse>' +
|
||||
' <FIELDS OBJECTID="551" Shape="NULL" NAME="Carbon" STATE_NAME="Wyoming" AREA="7999.91062" POP2000="15639" POP00_SQMI="2" Shape_Length="6.61737274334215" Shape_Area="2.23938983524154"/>' +
|
||||
' <FIELDS OBJECTID="7" Shape="NULL" AREA="97803.199" STATE_NAME="Wyoming" SUB_REGION="Mtn" STATE_ABBR="WY" POP2000="493782" POP00_SQMI="5" Shape_Length="21.9870297323522" Shape_Area="27.9666881382635"/>' +
|
||||
' <FIELDS OBJECTID="99" Shape="NULL" LENGTH="378.836" TYPE="Multi-Lane Divided" ADMN_CLASS="Interstate" TOLL_RD="N" RTE_NUM1=" 80" RTE_NUM2=" " ROUTE="Interstate 80" Shape_Length="7.04294883879398"/>' +
|
||||
'</FeatureInfoResponse>';
|
||||
|
||||
features = parser.read(text);
|
||||
|
||||
t.eq(features.length, 3,
|
||||
"Parsed 3 features in total");
|
||||
|
||||
t.eq(features[1].attributes.STATE_NAME, 'Wyoming',
|
||||
"Attribute STATE_NAME contains the right value");
|
||||
|
||||
}
|
||||
|
||||
function test_read_msGMLOutput(t) {
|
||||
t.plan(6);
|
||||
|
||||
var parser = new OpenLayers.Format.WMSGetFeatureInfo();
|
||||
|
||||
// read empty response
|
||||
var text =
|
||||
'<?xml version="1.0" encoding="ISO-8859-1"?>' +
|
||||
'<msGMLOutput ' +
|
||||
' xmlns:gml="http://www.opengis.net/gml"' +
|
||||
' xmlns:xlink="http://www.w3.org/1999/xlink"' +
|
||||
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">' +
|
||||
'</msGMLOutput>';
|
||||
|
||||
var features = parser.read(text);
|
||||
t.eq(features.length, 0,
|
||||
"Parsing empty msGMLOutput response succesfull");
|
||||
|
||||
// read 1 feature from 1 layer
|
||||
text =
|
||||
'<?xml version="1.0" encoding="ISO-8859-1"?>' +
|
||||
'<msGMLOutput ' +
|
||||
' xmlns:gml="http://www.opengis.net/gml"' +
|
||||
' xmlns:xlink="http://www.w3.org/1999/xlink"' +
|
||||
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">' +
|
||||
' <AAA64_layer>' +
|
||||
' <AAA64_feature>' +
|
||||
' <gml:boundedBy>' +
|
||||
' <gml:Box srsName="EPSG:28992">' +
|
||||
' <gml:coordinates>107397.266000,460681.063000 116568.188000,480609.250000</gml:coordinates>' +
|
||||
' </gml:Box>' +
|
||||
' </gml:boundedBy>' +
|
||||
' <OBJECTID>109</OBJECTID>' +
|
||||
' <ROUTE>N231</ROUTE>' +
|
||||
' <ROUTE_CH>#N231</ROUTE_CH>' +
|
||||
' <COUNT>2</COUNT>' +
|
||||
' <BEHEERDER>P</BEHEERDER>' +
|
||||
' <LENGTH>28641.7</LENGTH>' +
|
||||
' <SHAPE><shape></SHAPE>' +
|
||||
' <SE_ANNO_CAD_DATA><null></SE_ANNO_CAD_DATA>' +
|
||||
' </AAA64_feature>' +
|
||||
' </AAA64_layer>' +
|
||||
'</msGMLOutput>';
|
||||
|
||||
features = parser.read(text);
|
||||
t.eq(features.length, 1,
|
||||
"Parsed 1 feature in total");
|
||||
|
||||
t.eq(features[0].attributes.OBJECTID, '109',
|
||||
"Attribute OBJECTID contains the right value");
|
||||
|
||||
t.eq(features[0].type, 'AAA64',
|
||||
"Parsed the layer name correctly");
|
||||
|
||||
// read 2 features from 2 layers
|
||||
text =
|
||||
'<?xml version="1.0" encoding="ISO-8859-1"?>' +
|
||||
'<msGMLOutput ' +
|
||||
' xmlns:gml="http://www.opengis.net/gml"' +
|
||||
' xmlns:xlink="http://www.w3.org/1999/xlink"' +
|
||||
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">'+
|
||||
' <AAA64_layer>' +
|
||||
' <AAA64_feature>' +
|
||||
' <gml:boundedBy>' +
|
||||
' <gml:Box srsName="EPSG:28992">' +
|
||||
' <gml:coordinates>129799.109000,467950.250000 133199.906000,468904.063000</gml:coordinates>' +
|
||||
' </gml:Box>' +
|
||||
' </gml:boundedBy>' +
|
||||
' <OBJECTID>287</OBJECTID>' +
|
||||
' <ROUTE>N403</ROUTE>' +
|
||||
' <ROUTE_CH>#N403</ROUTE_CH>' +
|
||||
' <COUNT>1</COUNT>' +
|
||||
' <BEHEERDER>P</BEHEERDER>' +
|
||||
' <LENGTH>4091.25</LENGTH>' +
|
||||
' <SHAPE><shape></SHAPE>' +
|
||||
' <SE_ANNO_CAD_DATA><null></SE_ANNO_CAD_DATA>' +
|
||||
' </AAA64_feature>' +
|
||||
' </AAA64_layer>' +
|
||||
' <AAA62_layer>' +
|
||||
' <AAA62_feature>' +
|
||||
' <gml:boundedBy>' +
|
||||
' <gml:Box srsName="EPSG:28992">' +
|
||||
' <gml:coordinates>129936.000000,468362.000000 131686.000000,473119.000000</gml:coordinates>' +
|
||||
' </gml:Box>' +
|
||||
' </gml:boundedBy>' +
|
||||
' <OBJECTID>1251</OBJECTID>' +
|
||||
' <VWK_ID>1515</VWK_ID>' +
|
||||
' <VWK_BEGDTM>00:00:00 01/01/1998</VWK_BEGDTM>' +
|
||||
' <VWJ_ID_BEG>1472</VWJ_ID_BEG>' +
|
||||
' <VWJ_ID_END>1309</VWJ_ID_END>' +
|
||||
' <VAKTYPE>D</VAKTYPE>' +
|
||||
' <VRT_CODE>227</VRT_CODE>' +
|
||||
' <VRT_NAAM>Vecht</VRT_NAAM>' +
|
||||
' <VWG_NR>2</VWG_NR>' +
|
||||
' <VWG_NAAM>Vecht</VWG_NAAM>' +
|
||||
' <BEGKM>18.25</BEGKM>' +
|
||||
' <ENDKM>23.995</ENDKM>' +
|
||||
' <LENGTH>5745.09</LENGTH>' +
|
||||
' <SHAPE><shape></SHAPE>' +
|
||||
' <SE_ANNO_CAD_DATA><null></SE_ANNO_CAD_DATA>' +
|
||||
' </AAA62_feature>' +
|
||||
' </AAA62_layer>' +
|
||||
'</msGMLOutput>';
|
||||
|
||||
features = parser.read(text);
|
||||
|
||||
t.eq(features.length, 2,
|
||||
"Parsed 2 features in total");
|
||||
|
||||
t.eq((features[0].type == features[1].type), false,
|
||||
"The layer name differs for the two features");
|
||||
|
||||
}
|
||||
|
||||
function test_read_GMLFeatureInfoResponse(t) {
|
||||
t.plan(4);
|
||||
|
||||
var parser = new OpenLayers.Format.WMSGetFeatureInfo();
|
||||
|
||||
// read Ionic response, see if parser falls back to GML format
|
||||
// url used:
|
||||
/* http://webservices.ionicsoft.com/ionicweb/wfs/BOSTON_ORA?service=WMS&request=GetFeatureInfo&layers=roads&version=1.1.1&bbox=-71.1,42.25,-71.05,42.3&width=500&height=500&format=image/png&SRS=EPSG:4326&styles=&x=174&y=252&query_layers=roads&info_format=application/vnd.ogc.gml */
|
||||
var text =
|
||||
"<?xml version='1.0' encoding='utf-8' ?>" +
|
||||
' <ogcwfs:FeatureCollection xsi:schemaLocation="http://www.ionicsoft.com/wfs http://webservices.ionicsoft.com/ionicweb/wfs/BOSTON_ORA?REQUEST=DescribeAllFeatureType&SERVICE=WFS http://www.opengis.net/wfs http://webservices.ionicsoft.com/ionicweb/wfs/BOSTON_ORA/REQUEST/get/DATA/LPR/wfs/1.0.0/WFS-basic.xsd" xmlns:wfs="http://www.ionicsoft.com/wfs" xmlns:gml="http://www.opengis.net/gml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ogcwfs="http://www.opengis.net/wfs">' +
|
||||
' <gml:boundedBy>' +
|
||||
' <gml:Box srsName="EPSG:4326">' +
|
||||
' <gml:coordinates>-71.08301710045646,42.27320863544783 -71.08020014900377,42.27480054530114</gml:coordinates>' +
|
||||
' </gml:Box>' +
|
||||
' </gml:boundedBy>' +
|
||||
' <gml:featureMember>' +
|
||||
' <wfs:roads fid="roads.9453.0">' +
|
||||
' <wfs:FNODE_>8943.0</wfs:FNODE_>' +
|
||||
' <wfs:TNODE_>9070.0</wfs:TNODE_>' +
|
||||
' <wfs:LPOLY_>0.0</wfs:LPOLY_>' +
|
||||
' <wfs:RPOLY_>0.0</wfs:RPOLY_>' +
|
||||
' <wfs:LENGTH>306.875</wfs:LENGTH>' +
|
||||
' <wfs:MRD_>13109.0</wfs:MRD_>' +
|
||||
' <wfs:MRD_ID>9453.0</wfs:MRD_ID>' +
|
||||
' <wfs:TILE_NAME>126</wfs:TILE_NAME>' +
|
||||
' <wfs:COUNTYCODE>M</wfs:COUNTYCODE>' +
|
||||
' <wfs:SERIAL_NUM>26000.0</wfs:SERIAL_NUM>' +
|
||||
' <wfs:CLASS>5.0</wfs:CLASS>' +
|
||||
' <wfs:ADMIN_TYPE>0.0</wfs:ADMIN_TYPE>' +
|
||||
' <wfs:ALTRT1TYPE>0.0</wfs:ALTRT1TYPE>' +
|
||||
' <wfs:STREETNAME>DOCTOR MARY MOORE BEATTY CIRCLE</wfs:STREETNAME>' +
|
||||
' <wfs:CSN>M 26000</wfs:CSN>' +
|
||||
' <wfs:GEOMETRY>' +
|
||||
' <gml:LineString srsName="EPSG:4326">' +
|
||||
' <gml:coordinates>-71.08300668868151,42.27480054530114 -71.08155305289881,42.27452010256956 -71.08021063085208,42.27320863544783</gml:coordinates>' +
|
||||
' </gml:LineString>' +
|
||||
' </wfs:GEOMETRY>' +
|
||||
' </wfs:roads>' +
|
||||
' </gml:featureMember>' +
|
||||
' </ogcwfs:FeatureCollection>';
|
||||
|
||||
var features = parser.read(text);
|
||||
|
||||
t.eq(features.length, 1,
|
||||
"Parsing GML GetFeatureInfo response from Ionic succesfull");
|
||||
|
||||
t.eq(features[0].attributes.TILE_NAME, '126',
|
||||
"Attribute TILE_NAME contains the right value");
|
||||
|
||||
// read Geoserver response
|
||||
// taken from:
|
||||
/* http://demo.opengeo.org/geoserver/wms?service=WMS&request=GetFeatureInfo&layers=opengeo:roads&query_layers=opengeo:roads&format=image/png&version=1.1.1&styles=&bbox=-103.9,44.4,-103.7,44.5&srs=EPSG:4326&width=500&height=500&x=158&y=98&info_format=application/vnd.ogc.gml*/
|
||||
|
||||
text = '<?xml version="1.0" encoding="UTF-8"?><wfs:FeatureCollection xmlns="http://www.opengis.net/wfs" xmlns:wfs="http://www.opengis.net/wfs" xmlns:opengeo="http://opengeo.org" xmlns:gml="http://www.opengis.net/gml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://opengeo.org http://demo.opengeo.org:80/geoserver/wfs?service=WFS&version=1.0.0&request=DescribeFeatureType&typeName=opengeo:roads http://www.opengis.net/wfs http://demo.opengeo.org:80/geoserver/schemas/wfs/1.0.0/WFS-basic.xsd"><gml:boundedBy><gml:Box srsName="http://www.opengis.net/gml/srs/epsg.xml#26713"><gml:coordinates xmlns:gml="http://www.opengis.net/gml" decimal="." cs="," ts=" ">591943.9375,4925605 593045.625,4925845</gml:coordinates></gml:Box></gml:boundedBy><gml:featureMember><opengeo:roads fid="roads.90"><opengeo:cat>3</opengeo:cat><opengeo:label>secondary highway, hard surface</opengeo:label><opengeo:the_geom><gml:MultiLineString srsName="http://www.opengis.net/gml/srs/epsg.xml#26713"><gml:lineStringMember><gml:LineString><gml:coordinates xmlns:gml="http://www.opengis.net/gml" decimal="." cs="," ts=" ">593045.60746465,4925605.0059156 593024.32382915,4925606.79305411 592907.54863574,4925624.85647524 592687.35111096,4925670.76834012 592430.76279218,4925678.79393165 592285.97636109,4925715.70811767 592173.39165655,4925761.83511156 592071.1753393,4925793.95523514 591985.96972625,4925831.59842486 591943.98769455,4925844.93220071</gml:coordinates></gml:LineString></gml:lineStringMember></gml:MultiLineString></opengeo:the_geom></opengeo:roads></gml:featureMember></wfs:FeatureCollection>';
|
||||
|
||||
features = parser.read(text);
|
||||
|
||||
t.eq(features.length, 1,
|
||||
"Parsing GML GetFeatureInfo response from Geoserver succesfull");
|
||||
|
||||
t.eq(features[0].attributes.cat, '3',
|
||||
"Attribute cat contains the right value");
|
||||
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user