Make sure ol.format.GML2 is usable for WFS 1.0 requests as well
This commit is contained in:
@@ -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
|
||||
*/
|
||||
|
||||
@@ -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');
|
||||
|
||||
74
test/spec/ol/format/gml/osm-wfs-10.xml
Normal file
74
test/spec/ol/format/gml/osm-wfs-10.xml
Normal file
@@ -0,0 +1,74 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<wfs:FeatureCollection xmlns="http://www.opengis.net/wfs" xmlns:wfs="http://www.opengis.net/wfs"
|
||||
xmlns:gml="http://www.opengis.net/gml" xmlns:osm="http://openstreemap.org"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://openstreemap.org http://demo.boundlessgeo.com:80/geoserver/wfs?service=WFS&version=1.0.0&request=DescribeFeatureType&typeName=osm%3Awater_areas http://www.opengis.net/wfs http://demo.boundlessgeo.com:80/geoserver/schemas/wfs/1.0.0/WFS-basic.xsd">
|
||||
<gml:boundedBy>
|
||||
<gml:Box srsName="http://www.opengis.net/gml/srs/epsg.xml#3857">
|
||||
<gml:coordinates xmlns:gml="http://www.opengis.net/gml" decimal="." cs="," ts=" ">-8968891.6,5359194.88 -8851849.35,5404697.62</gml:coordinates>
|
||||
</gml:Box>
|
||||
</gml:boundedBy>
|
||||
<gml:featureMember>
|
||||
<osm:water_areas fid="water_areas.1">
|
||||
<gml:boundedBy>
|
||||
<gml:Box srsName="http://www.opengis.net/gml/srs/epsg.xml#3857">
|
||||
<gml:coordinates xmlns:gml="http://www.opengis.net/gml" decimal="." cs="," ts=" ">-8861874.95,5404470.6 -8861656.64,5404697.62</gml:coordinates>
|
||||
</gml:Box>
|
||||
</gml:boundedBy>
|
||||
<osm:osm_id>43923968</osm:osm_id>
|
||||
<osm:way>
|
||||
<gml:Polygon srsName="http://www.opengis.net/gml/srs/epsg.xml#3857">
|
||||
<gml:outerBoundaryIs>
|
||||
<gml:LinearRing>
|
||||
<gml:coordinates xmlns:gml="http://www.opengis.net/gml" decimal="." cs="," ts=" ">-8861874.95,5404567.88 -8861764.02,5404697.62 -8861656.64,5404593.11 -8861763.02,5404470.6 -8861874.95,5404567.88</gml:coordinates>
|
||||
</gml:LinearRing>
|
||||
</gml:outerBoundaryIs>
|
||||
</gml:Polygon>
|
||||
</osm:way>
|
||||
<osm:natural>natural</osm:natural>
|
||||
<osm:landuse>reservoir</osm:landuse>
|
||||
</osm:water_areas>
|
||||
</gml:featureMember>
|
||||
<gml:featureMember>
|
||||
<osm:water_areas fid="water_areas.6">
|
||||
<gml:boundedBy>
|
||||
<gml:Box srsName="http://www.opengis.net/gml/srs/epsg.xml#3857">
|
||||
<gml:coordinates xmlns:gml="http://www.opengis.net/gml" decimal="." cs="," ts=" ">-8878000.03,5387681.65 -8877690.97,5388003.42</gml:coordinates>
|
||||
</gml:Box>
|
||||
</gml:boundedBy>
|
||||
<osm:osm_id>43936917</osm:osm_id>
|
||||
<osm:way>
|
||||
<gml:Polygon srsName="http://www.opengis.net/gml/srs/epsg.xml#3857">
|
||||
<gml:outerBoundaryIs>
|
||||
<gml:LinearRing>
|
||||
<gml:coordinates xmlns:gml="http://www.opengis.net/gml" decimal="." cs="," ts=" ">-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</gml:coordinates>
|
||||
</gml:LinearRing>
|
||||
</gml:outerBoundaryIs>
|
||||
</gml:Polygon>
|
||||
</osm:way>
|
||||
<osm:natural>natural</osm:natural>
|
||||
<osm:landuse>reservoir</osm:landuse>
|
||||
</osm:water_areas>
|
||||
</gml:featureMember>
|
||||
<gml:featureMember>
|
||||
<osm:water_areas fid="water_areas.8">
|
||||
<gml:boundedBy>
|
||||
<gml:Box srsName="http://www.opengis.net/gml/srs/epsg.xml#3857">
|
||||
<gml:coordinates xmlns:gml="http://www.opengis.net/gml" decimal="." cs="," ts=" ">-8867744.24,5392288.05 -8867560.83,5392575.38</gml:coordinates>
|
||||
</gml:Box>
|
||||
</gml:boundedBy>
|
||||
<osm:osm_id>43923958</osm:osm_id>
|
||||
<osm:way>
|
||||
<gml:Polygon srsName="http://www.opengis.net/gml/srs/epsg.xml#3857">
|
||||
<gml:outerBoundaryIs>
|
||||
<gml:LinearRing>
|
||||
<gml:coordinates xmlns:gml="http://www.opengis.net/gml" decimal="." cs="," ts=" ">-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</gml:coordinates>
|
||||
</gml:LinearRing>
|
||||
</gml:outerBoundaryIs>
|
||||
</gml:Polygon>
|
||||
</osm:way>
|
||||
<osm:natural>natural</osm:natural>
|
||||
<osm:landuse>reservoir</osm:landuse>
|
||||
</osm:water_areas>
|
||||
</gml:featureMember>
|
||||
</wfs:FeatureCollection>
|
||||
@@ -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() {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user