Merge pull request #6614 from adube/filter-write-util-method
Filter write util method
This commit is contained in:
@@ -782,6 +782,20 @@ ol.format.WFS.GETFEATURE_SERIALIZERS_ = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encode filter as WFS `Filter` and return the Node.
|
||||||
|
*
|
||||||
|
* @param {ol.format.filter.Filter} filter Filter.
|
||||||
|
* @return {Node} Result.
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
ol.format.WFS.writeFilter = function(filter) {
|
||||||
|
var child = ol.xml.createElementNS(ol.format.WFS.OGCNS, 'Filter');
|
||||||
|
ol.format.WFS.writeFilterCondition_(child, filter, []);
|
||||||
|
return child;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Node} node Node.
|
* @param {Node} node Node.
|
||||||
* @param {Array.<string>} featureTypes Feature types.
|
* @param {Array.<string>} featureTypes Feature types.
|
||||||
|
|||||||
@@ -1014,4 +1014,29 @@ describe('ol.format.WFS', function() {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('when writing out a WFS Filter', function() {
|
||||||
|
it('creates a filter', function() {
|
||||||
|
var text =
|
||||||
|
'<Filter xmlns="http://www.opengis.net/ogc">' +
|
||||||
|
' <And>' +
|
||||||
|
' <PropertyIsLike wildCard="*" singleChar="." escapeChar="!">' +
|
||||||
|
' <PropertyName>name</PropertyName>' +
|
||||||
|
' <Literal>Mississippi*</Literal>' +
|
||||||
|
' </PropertyIsLike>' +
|
||||||
|
' <PropertyIsEqualTo>' +
|
||||||
|
' <PropertyName>waterway</PropertyName>' +
|
||||||
|
' <Literal>riverbank</Literal>' +
|
||||||
|
' </PropertyIsEqualTo>' +
|
||||||
|
' </And>' +
|
||||||
|
'</Filter>';
|
||||||
|
var serialized = ol.format.WFS.writeFilter(
|
||||||
|
ol.format.filter.and(
|
||||||
|
ol.format.filter.like('name', 'Mississippi*'),
|
||||||
|
ol.format.filter.equalTo('waterway', 'riverbank')
|
||||||
|
)
|
||||||
|
);
|
||||||
|
expect(serialized).to.xmleql(ol.xml.parse(text));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user