Add getFeatureType and setFeatureType functions to ol.format.WFS

This commit is contained in:
Frederic Junod
2017-11-01 14:07:54 +01:00
parent d33e41d322
commit daea26ec50
2 changed files with 30 additions and 2 deletions

View File

@@ -116,6 +116,22 @@ ol.format.WFS.SCHEMA_LOCATIONS = {
ol.format.WFS.DEFAULT_VERSION = '1.1.0';
/**
* @return {Array.<string>|string|undefined} featureType
*/
ol.format.WFS.prototype.getFeatureType = function() {
return this.featureType_;
};
/**
* @param {Array.<string>|string|undefined} featureType Feature type(s) to parse.
*/
ol.format.WFS.prototype.setFeatureType = function(featureType) {
this.featureType_ = featureType;
};
/**
* Read all features from a WFS FeatureCollection.
*

View File

@@ -1,5 +1,3 @@
goog.require('ol.Feature');
goog.require('ol.format.GML2');
goog.require('ol.format.WFS');
@@ -14,6 +12,20 @@ goog.require('ol.xml');
describe('ol.format.WFS', function() {
describe('featureType', function() {
it('#getFeatureType #setFeatureType', function() {
var format = new ol.format.WFS({
featureNS: 'http://www.openplans.org/topp',
featureType: ['foo', 'bar']
});
expect(format.getFeatureType()).to.eql(['foo', 'bar']);
format.setFeatureType('baz');
expect(format.getFeatureType()).to.eql('baz');
});
});
describe('when parsing TOPP states GML from WFS', function() {
var features, feature, xml;