Make GetFeatureInfo format pass ol2 test suite
This commit is contained in:
committed by
Florent gravin
parent
d0d6215550
commit
c0f2187310
@@ -1,5 +1,6 @@
|
||||
goog.provide('ol.format.GetFeatureInfo');
|
||||
|
||||
goog.require('goog.array');
|
||||
goog.require('goog.asserts');
|
||||
goog.require('goog.dom');
|
||||
goog.require('goog.dom.NodeType');
|
||||
@@ -15,7 +16,7 @@ goog.require('ol.xml');
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
* Format for reading MapServer GetFeatureInfo format.It uses
|
||||
* Format for reading GetFeatureInfo format.It uses
|
||||
* ol.format.GML2 to read features.
|
||||
*
|
||||
* @constructor
|
||||
@@ -77,27 +78,43 @@ ol.format.GetFeatureInfo.prototype.readFeatures_ = function(node, objectStack) {
|
||||
node.namespaceURI = this.featureNS_;
|
||||
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
|
||||
var localName = ol.xml.getLocalName(node);
|
||||
var features;
|
||||
var features = [];
|
||||
if (node.childNodes.length === 0) {
|
||||
return features;
|
||||
}
|
||||
if (localName == 'msGMLOutput') {
|
||||
var context = objectStack[0];
|
||||
goog.asserts.assert(goog.isObject(context));
|
||||
goog.array.forEach(node.childNodes, function(layer) {
|
||||
if (layer.nodeType !== goog.dom.NodeType.ELEMENT) {
|
||||
return;
|
||||
}
|
||||
var context = objectStack[0];
|
||||
goog.asserts.assert(goog.isObject(context));
|
||||
|
||||
var layer = node.firstElementChild;
|
||||
goog.asserts.assert(layer.localName.indexOf(this.layerIdentifier_) >= 0);
|
||||
goog.asserts.assert(layer.localName.indexOf(this.layerIdentifier_) >= 0);
|
||||
|
||||
var featureType = goog.string.remove(layer.localName,
|
||||
this.layerIdentifier_) + this.featureIdentifier_;
|
||||
var featureType = goog.string.remove(layer.localName,
|
||||
this.layerIdentifier_) + this.featureIdentifier_;
|
||||
|
||||
goog.object.set(context, 'featureType', featureType);
|
||||
goog.object.set(context, 'featureNS', this.featureNS_);
|
||||
goog.object.set(context, 'featureType', featureType);
|
||||
goog.object.set(context, 'featureNS', this.featureNS_);
|
||||
|
||||
var parsers = {};
|
||||
var parsersNS = {};
|
||||
parsers[featureType] = ol.xml.makeArrayPusher(
|
||||
this.gmlFormat_.readFeatureElement, this.gmlFormat_);
|
||||
parsersNS[goog.object.get(context, 'featureNS')] = parsers;
|
||||
features = ol.xml.pushParseAndPop([], parsersNS, layer, objectStack,
|
||||
this.gmlFormat_);
|
||||
var parsers = {};
|
||||
parsers[featureType] = ol.xml.makeArrayPusher(
|
||||
this.gmlFormat_.readFeatureElement, this.gmlFormat_);
|
||||
var parsersNS = ol.xml.makeParsersNS(
|
||||
[goog.object.get(context, 'featureNS'), null], parsers);
|
||||
layer.namespaceURI = this.featureNS_;
|
||||
var layerFeatures = ol.xml.pushParseAndPop(
|
||||
[], parsersNS, layer, objectStack, this.gmlFormat_);
|
||||
if (goog.isDef(layerFeatures)) {
|
||||
goog.array.extend(/** @type {Array} */ (features), layerFeatures);
|
||||
}
|
||||
}, this);
|
||||
}
|
||||
if (localName == 'FeatureCollection') {
|
||||
features = ol.xml.pushParseAndPop([],
|
||||
this.gmlFormat_.FEATURE_COLLECTION_PARSERS, node,
|
||||
[{}], this.gmlFormat_);
|
||||
}
|
||||
if (!goog.isDef(features)) {
|
||||
features = [];
|
||||
|
||||
Reference in New Issue
Block a user