diff --git a/src/ol/format/gmlformat.js b/src/ol/format/gmlformat.js index dfe7385ace..61d008f387 100644 --- a/src/ol/format/gmlformat.js +++ b/src/ol/format/gmlformat.js @@ -119,10 +119,12 @@ ol.format.GML.readFeatures_ = function(node, objectStack) { if (localName == 'FeatureCollection') { features = ol.xml.pushParseAndPop(null, ol.format.GML.FEATURE_COLLECTION_PARSERS, node, objectStack); - } else if (localName == 'featureMembers') { + } else if (localName == 'featureMembers' || localName == 'featureMember') { var parsers = {}; var parsersNS = {}; - parsers[featureType] = ol.xml.makeArrayPusher(ol.format.GML.readFeature_); + parsers[featureType] = (localName == 'featureMembers') ? + ol.xml.makeArrayPusher(ol.format.GML.readFeature_) : + ol.xml.makeReplacer(ol.format.GML.readFeature_); parsersNS[goog.object.get(context, 'featureNS')] = parsers; features = ol.xml.pushParseAndPop([], parsersNS, node, objectStack); } @@ -138,6 +140,7 @@ ol.format.GML.readFeatures_ = function(node, objectStack) { */ ol.format.GML.FEATURE_COLLECTION_PARSERS = { 'http://www.opengis.net/gml': { + 'featureMember': ol.xml.makeArrayPusher(ol.format.GML.readFeatures_), 'featureMembers': ol.xml.makeReplacer(ol.format.GML.readFeatures_) } }; diff --git a/src/ol/format/wfsformat.js b/src/ol/format/wfsformat.js index 36413713cf..c6a8124bb9 100644 --- a/src/ol/format/wfsformat.js +++ b/src/ol/format/wfsformat.js @@ -80,7 +80,7 @@ ol.format.WFS.prototype.readFeaturesFromNode = function(node) { 'featureType': this.featureType_, 'featureNS': this.featureNS_ }]; - var features = ol.xml.pushParseAndPop(null, + var features = ol.xml.pushParseAndPop([], ol.format.GML.FEATURE_COLLECTION_PARSERS, node, objectStack); if (!goog.isDef(features)) { features = []; diff --git a/test/spec/ol/format/wfs/mapserver.xml b/test/spec/ol/format/wfs/mapserver.xml new file mode 100644 index 0000000000..c71781c17c --- /dev/null +++ b/test/spec/ol/format/wfs/mapserver.xml @@ -0,0 +1,197 @@ + + + + + 10.499999 50.599998 + 11.500001 51.000004 + + + + + + + 1205816.630831 6585772.755548 + 1224367.576331 6603402.922801 + + + + + + + 1205816.939380 6585772.755548 1205816.630831 6603402.592694 1224367.261890 6603402.922801 1224367.576331 6585773.084486 1205816.939380 6585772.755548 + + + + + 71055885 + 51_31 + 1936 + Arnstadt + http://digital.slub-dresden.de/id335959709 + http://fotothek.slub-dresden.de/fotos/df/dk/0010000/df_dk_0010001_5131.jpg + df_dk_0010001_5131 + + + + + + + 1224366.733352 6603402.922797 + 1242917.681900 6621070.996395 + + + + + + + 1224367.049596 6603402.922797 1224366.733352 6621070.658850 1242917.359733 6621070.996395 1242917.681900 6603403.259147 1224367.049596 6603402.922797 + + + + + 71055703 + 50_32 + 1878 + Erfurt + http://digital.slub-dresden.de/id335958907 + http://fotothek.slub-dresden.de/fotos/df/dk/0010000/df_dk_0010001_5032_1878.jpg + df_dk_0010001_5032_1878 + + + + + + + 1224366.733352 6603402.922797 + 1242917.681900 6621070.996395 + + + + + + + 1224367.049596 6603402.922797 1224366.733352 6621070.658850 1242917.359733 6621070.996395 1242917.681900 6603403.259147 1224367.049596 6603402.922797 + + + + + 71055704 + 50_32 + 1905 + Erfurt + http://digital.slub-dresden.de/id335958915 + http://fotothek.slub-dresden.de/fotos/df/dk/0010000/df_dk_0010001_5032_1905.jpg + df_dk_0010001_5032_1905 + + + + + + + 1168715.286189 6603401.951223 + 1187266.213287 6621070.002563 + + + + + + + 1168715.584649 6603401.951223 1168715.286189 6621069.683820 1187265.908897 6621070.002563 1187266.213287 6603402.268837 1168715.584649 6603401.951223 + + + + + 71055696 + 50_29 + 1918 + Fröttstädt + http://digital.slub-dresden.de/id335969488 + http://fotothek.slub-dresden.de/fotos/df/dk/0010000/df_dk_0010001_5029_1918.jpg + df_dk_0010001_5029_1918 + + + + + + + 1187265.802750 6603402.268835 + 1205816.736977 6621070.327575 + + + + + + + 1187266.107140 6603402.268835 1187265.802750 6621070.002561 1205816.426659 6621070.327575 1205816.736977 6603402.592696 1187266.107140 6603402.268835 + + + + + 71055699 + 50_30 + 1936 + Gotha + http://digital.slub-dresden.de/id335958877 + http://fotothek.slub-dresden.de/fotos/df/dk/0010000/df_dk_0010001_5030_1929.jpg + df_dk_0010001_5030_1929 + + + + + + + 1205817.246161 6550626.582163 + 1224368.199845 6568181.598557 + + + + + + + 1205817.551211 6550626.582163 1205817.246161 6568181.270783 1224367.888970 6568181.598557 1224368.199845 6550626.908779 1205817.551211 6550626.582163 + + + + + 71056242 + 53_31 + 1905 + Ilmenau + http://digital.slub-dresden.de/id335961355 + http://fotothek.slub-dresden.de/fotos/df/dk/0010000/df_dk_0010001_5331_1905.jpg + df_dk_0010001_5331_1905 + + + + + + + 1242917.575754 6585773.419639 + 1261468.535543 6603403.601734 + + + + + + + 1242917.896084 6585773.419639 1242917.575754 6603403.259145 1261468.209327 6603403.601734 1261468.535543 6585773.761014 1242917.896084 6585773.419639 + + + + + 71055889 + 51_33 + 1888 + Kranichfeld + http://digital.slub-dresden.de/id335959733 + http://fotothek.slub-dresden.de/fotos/df/dk/0010000/df_dk_0010001_5133_1873.jpg + df_dk_0010001_5133_1873 + + + diff --git a/test/spec/ol/format/wfsformat.test.js b/test/spec/ol/format/wfsformat.test.js index 760e3d8e6d..e4bf1c1d29 100644 --- a/test/spec/ol/format/wfsformat.test.js +++ b/test/spec/ol/format/wfsformat.test.js @@ -280,6 +280,38 @@ describe('ol.format.WFS', function() { }); }); + describe('when parsing GML from MapServer', function() { + + var features, feature; + before(function(done) { + afterLoadText('spec/ol/format/wfs/mapserver.xml', function(xml) { + try { + var config = { + 'featureNS': 'http://mapserver.gis.umn.edu/mapserver', + 'featureType': 'Historische_Messtischblaetter_WFS' + }; + features = new ol.format.WFS(config).readFeatures(xml); + } catch (e) { + done(e); + } + done(); + }); + }); + + it('creates 7 features', function() { + expect(features).to.have.length(7); + }); + + it('creates a polygon for Arnstadt', function() { + feature = features[0]; + var fid = 'Historische_Messtischblaetter_WFS.71055885'; + expect(feature.getId()).to.equal(fid); + expect(feature.get('titel')).to.equal('Arnstadt'); + expect(feature.getGeometry()).to.be.an(ol.geom.Polygon); + }); + + }); + }); @@ -287,4 +319,5 @@ goog.require('ol.xml'); goog.require('ol.Feature'); goog.require('ol.geom.MultiPoint'); goog.require('ol.geom.MultiPolygon'); +goog.require('ol.geom.Polygon'); goog.require('ol.format.WFS');