Fix WFS 2.0.0 writeFilter
* Add a test for WFS 2.0.0 filter encoding * Use getFilterNS to ensure correct NS for filter child node
This commit is contained in:
@@ -1328,7 +1328,7 @@ function writeTimeInstant(node, time) {
|
|||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
export function writeFilter(filter, version) {
|
export function writeFilter(filter, version) {
|
||||||
const child = createElementNS(OGCNS[version], 'Filter');
|
const child = createElementNS(getFilterNS(version), 'Filter');
|
||||||
const context = {
|
const context = {
|
||||||
node: child,
|
node: child,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1457,20 +1457,33 @@ describe('ol.format.WFS', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('when writing out a WFS Filter', function () {
|
describe('when writing out a WFS Filter', function () {
|
||||||
it('creates a filter', function () {
|
const wfs1Filter =
|
||||||
const text =
|
'<Filter xmlns="http://www.opengis.net/ogc">' +
|
||||||
'<Filter xmlns="http://www.opengis.net/ogc">' +
|
' <And>' +
|
||||||
' <And>' +
|
' <PropertyIsLike wildCard="*" singleChar="." escapeChar="!">' +
|
||||||
' <PropertyIsLike wildCard="*" singleChar="." escapeChar="!">' +
|
' <PropertyName>name</PropertyName>' +
|
||||||
' <PropertyName>name</PropertyName>' +
|
' <Literal>Mississippi*</Literal>' +
|
||||||
' <Literal>Mississippi*</Literal>' +
|
' </PropertyIsLike>' +
|
||||||
' </PropertyIsLike>' +
|
' <PropertyIsEqualTo>' +
|
||||||
' <PropertyIsEqualTo>' +
|
' <PropertyName>waterway</PropertyName>' +
|
||||||
' <PropertyName>waterway</PropertyName>' +
|
' <Literal>riverbank</Literal>' +
|
||||||
' <Literal>riverbank</Literal>' +
|
' </PropertyIsEqualTo>' +
|
||||||
' </PropertyIsEqualTo>' +
|
' </And>' +
|
||||||
' </And>' +
|
'</Filter>';
|
||||||
'</Filter>';
|
const wfs2Filter =
|
||||||
|
'<Filter xmlns="http://www.opengis.net/fes/2.0">' +
|
||||||
|
' <And>' +
|
||||||
|
' <PropertyIsLike wildCard="*" singleChar="." escapeChar="!">' +
|
||||||
|
' <ValueReference>name</ValueReference>' +
|
||||||
|
' <Literal>Mississippi*</Literal>' +
|
||||||
|
' </PropertyIsLike>' +
|
||||||
|
' <PropertyIsEqualTo>' +
|
||||||
|
' <ValueReference>waterway</ValueReference>' +
|
||||||
|
' <Literal>riverbank</Literal>' +
|
||||||
|
' </PropertyIsEqualTo>' +
|
||||||
|
' </And>' +
|
||||||
|
'</Filter>';
|
||||||
|
it('creates a WFS 1.x.x filter', function () {
|
||||||
const serialized = writeFilter(
|
const serialized = writeFilter(
|
||||||
andFilter(
|
andFilter(
|
||||||
likeFilter('name', 'Mississippi*'),
|
likeFilter('name', 'Mississippi*'),
|
||||||
@@ -1478,7 +1491,17 @@ describe('ol.format.WFS', function () {
|
|||||||
),
|
),
|
||||||
'1.1.0'
|
'1.1.0'
|
||||||
);
|
);
|
||||||
expect(serialized).to.xmleql(parse(text));
|
expect(serialized).to.xmleql(parse(wfs1Filter));
|
||||||
|
});
|
||||||
|
it('creates a WFS 2.x.x filter', function () {
|
||||||
|
const serialized = writeFilter(
|
||||||
|
andFilter(
|
||||||
|
likeFilter('name', 'Mississippi*'),
|
||||||
|
equalToFilter('waterway', 'riverbank')
|
||||||
|
),
|
||||||
|
'2.0.0'
|
||||||
|
);
|
||||||
|
expect(serialized).to.xmleql(parse(wfs2Filter));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user