Support multiple feature types in GML format

This commit is contained in:
Bart van den Eijnden
2014-12-19 13:07:40 +01:00
parent 7527eddbaf
commit 3a7905f2fd
4 changed files with 102 additions and 12 deletions

View File

@@ -45,13 +45,13 @@ ol.format.GMLBase = function(opt_options) {
/**
* @protected
* @type {string}
* @type {Array.<string>|string|undefined}
*/
this.featureType = options.featureType;
/**
* @protected
* @type {string}
* @type {string|undefined}
*/
this.featureNS = options.featureNS;
@@ -115,10 +115,13 @@ ol.format.GMLBase.prototype.readFeaturesInternal = function(node, objectStack) {
}
var parsers = {};
var parsersNS = {};
parsers[featureType] = (localName == 'featureMembers') ?
ol.xml.makeArrayPusher(this.readFeatureElement, this) :
ol.xml.makeReplacer(this.readFeatureElement, this);
parsersNS[context['featureNS']] = parsers;
var featureTypes = goog.isArray(featureType) ? featureType : [featureType];
for (var i = 0, ii = featureTypes.length; i < ii; ++i) {
parsers[featureTypes[i]] = (localName == 'featureMembers') ?
ol.xml.makeArrayPusher(this.readFeatureElement, this) :
ol.xml.makeReplacer(this.readFeatureElement, this);
}
parsersNS[goog.object.get(context, 'featureNS')] = parsers;
features = ol.xml.pushParseAndPop([], parsersNS, node, objectStack);
}
if (!goog.isDef(features)) {