diff --git a/src/ol/format/gml/gml2format.js b/src/ol/format/gml/gml2format.js index ab2c281a2c..ff9f46238f 100644 --- a/src/ol/format/gml/gml2format.js +++ b/src/ol/format/gml/gml2format.js @@ -27,6 +27,10 @@ ol.format.GML2 = function(opt_options) { goog.base(this, options); + this.FEATURE_COLLECTION_PARSERS[ol.format.GMLBase.GMLNS][ + 'featureMember'] = + ol.xml.makeArrayPusher(ol.format.GMLBase.prototype.readFeaturesInternal); + /** * @inheritDoc */ diff --git a/src/ol/format/gml/gmlbaseformat.js b/src/ol/format/gml/gmlbaseformat.js index c6da053a46..1878296f8f 100644 --- a/src/ol/format/gml/gmlbaseformat.js +++ b/src/ol/format/gml/gmlbaseformat.js @@ -101,9 +101,15 @@ ol.format.GMLBase.prototype.readFeaturesInternal = function(node, objectStack) { var localName = ol.xml.getLocalName(node); var features; if (localName == 'FeatureCollection') { - features = ol.xml.pushParseAndPop(null, - this.FEATURE_COLLECTION_PARSERS, node, - objectStack, this); + if (node.namespaceURI === 'http://www.opengis.net/wfs') { + features = ol.xml.pushParseAndPop([], + this.FEATURE_COLLECTION_PARSERS, node, + objectStack, this); + } else { + features = ol.xml.pushParseAndPop(null, + this.FEATURE_COLLECTION_PARSERS, node, + objectStack, this); + } } else if (localName == 'featureMembers' || localName == 'featureMember') { var context = objectStack[0]; goog.asserts.assert(goog.isObject(context), 'context should be an Object'); diff --git a/test/spec/ol/format/gml/osm-wfs-10.xml b/test/spec/ol/format/gml/osm-wfs-10.xml new file mode 100644 index 0000000000..aceeb3f7fe --- /dev/null +++ b/test/spec/ol/format/gml/osm-wfs-10.xml @@ -0,0 +1,74 @@ + + + + + -8968891.6,5359194.88 -8851849.35,5404697.62 + + + + + + + -8861874.95,5404470.6 -8861656.64,5404697.62 + + + 43923968 + + + + + -8861874.95,5404567.88 -8861764.02,5404697.62 -8861656.64,5404593.11 -8861763.02,5404470.6 -8861874.95,5404567.88 + + + + + natural + reservoir + + + + + + + -8878000.03,5387681.65 -8877690.97,5388003.42 + + + 43936917 + + + + + -8878000.03,5387863.07 -8877848.36,5388003.42 -8877729.84,5387882.79 -8877690.97,5387798.34 -8877820.3,5387681.65 -8877881.51,5387742.44 -8878000.03,5387863.07 + + + + + natural + reservoir + + + + + + + -8867744.24,5392288.05 -8867560.83,5392575.38 + + + 43923958 + + + + + -8867744.24,5392373.3 -8867676.8,5392462.18 -8867721.93,5392503.87 -8867662.89,5392575.38 -8867588.37,5392518.12 -8867634.04,5392444.68 -8867560.83,5392387.74 -8867629.53,5392288.05 -8867744.24,5392373.3 + + + + + natural + reservoir + + + diff --git a/test/spec/ol/format/gmlformat.test.js b/test/spec/ol/format/gmlformat.test.js index 09aa00cb01..8597ad26ce 100644 --- a/test/spec/ol/format/gmlformat.test.js +++ b/test/spec/ol/format/gmlformat.test.js @@ -19,6 +19,25 @@ describe('ol.format.GML2', function() { formatNoSrs = new ol.format.GML2(); }); + describe('#readFeatures', function() { + var features; + before(function(done) { + var url = 'spec/ol/format/gml/osm-wfs-10.xml'; + afterLoadText(url, function(xml) { + try { + features = new ol.format.GML2().readFeatures(xml); + } catch (e) { + done(e); + } + done(); + }); + }); + + it('reads all features', function() { + expect(features.length).to.be(3); + }); + + }); describe('#readGeometry', function() {