fix distanceWithin for WFS2.0
This commit is contained in:
@@ -1087,7 +1087,11 @@ function writeDWithinFilter(node, filter, objectStack) {
|
|||||||
writeSpatialFilter(node, filter, objectStack);
|
writeSpatialFilter(node, filter, objectStack);
|
||||||
const distance = createElementNS(getFilterNS(version), 'Distance');
|
const distance = createElementNS(getFilterNS(version), 'Distance');
|
||||||
writeStringTextNode(distance, filter.distance.toString());
|
writeStringTextNode(distance, filter.distance.toString());
|
||||||
distance.setAttribute('uom', filter.unit);
|
if (version === '2.0.0') {
|
||||||
|
distance.setAttribute('uom', filter.unit);
|
||||||
|
} else {
|
||||||
|
distance.setAttribute('units', filter.unit);
|
||||||
|
}
|
||||||
node.appendChild(distance);
|
node.appendChild(distance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -687,7 +687,7 @@ describe('ol.format.WFS', function () {
|
|||||||
expect(serialized.firstElementChild).to.xmleql(parse(text));
|
expect(serialized.firstElementChild).to.xmleql(parse(text));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('creates a dwithin filter', function () {
|
it('creates a dwithin filter for WFS 1.x', function () {
|
||||||
const text =
|
const text =
|
||||||
'<wfs:Query xmlns:wfs="http://www.opengis.net/wfs" ' +
|
'<wfs:Query xmlns:wfs="http://www.opengis.net/wfs" ' +
|
||||||
' typeName="area" srsName="EPSG:4326" ' +
|
' typeName="area" srsName="EPSG:4326" ' +
|
||||||
@@ -704,7 +704,7 @@ describe('ol.format.WFS', function () {
|
|||||||
' </gml:LinearRing>' +
|
' </gml:LinearRing>' +
|
||||||
' </gml:exterior>' +
|
' </gml:exterior>' +
|
||||||
' </gml:Polygon>' +
|
' </gml:Polygon>' +
|
||||||
' <ogc:Distance uom="m">10</ogc:Distance>' +
|
' <ogc:Distance units="m">10</ogc:Distance>' +
|
||||||
' </ogc:DWithin>' +
|
' </ogc:DWithin>' +
|
||||||
' </ogc:Filter>' +
|
' </ogc:Filter>' +
|
||||||
'</wfs:Query>';
|
'</wfs:Query>';
|
||||||
@@ -729,6 +729,48 @@ describe('ol.format.WFS', function () {
|
|||||||
expect(serialized.firstElementChild).to.xmleql(parse(text));
|
expect(serialized.firstElementChild).to.xmleql(parse(text));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('creates a dwithin filter for WFS 2.0', function () {
|
||||||
|
const text =
|
||||||
|
'<wfs:Query xmlns:wfs="http://www.opengis.net/wfs/2.0" ' +
|
||||||
|
' typeNames="area" srsName="EPSG:4326" ' +
|
||||||
|
' xmlns:topp="http://www.openplans.org/topp">' +
|
||||||
|
' <fes:Filter xmlns:fes="http://www.opengis.net/fes/2.0">' +
|
||||||
|
' <fes:DWithin>' +
|
||||||
|
' <fes:ValueReference>the_geom</fes:ValueReference>' +
|
||||||
|
' <gml:Polygon xmlns:gml="http://www.opengis.net/gml/3.2">' +
|
||||||
|
' <gml:exterior>' +
|
||||||
|
' <gml:LinearRing>' +
|
||||||
|
' <gml:posList srsDimension="2">' +
|
||||||
|
' 10 20 10 25 15 25 15 20 10 20' +
|
||||||
|
' </gml:posList>' +
|
||||||
|
' </gml:LinearRing>' +
|
||||||
|
' </gml:exterior>' +
|
||||||
|
' </gml:Polygon>' +
|
||||||
|
' <fes:Distance uom="m">10</fes:Distance>' +
|
||||||
|
' </fes:DWithin>' +
|
||||||
|
' </fes:Filter>' +
|
||||||
|
'</wfs:Query>';
|
||||||
|
const serialized = new WFS({version: '2.0.0'}).writeGetFeature({
|
||||||
|
srsName: 'EPSG:4326',
|
||||||
|
featureTypes: ['area'],
|
||||||
|
filter: dwithinFilter(
|
||||||
|
'the_geom',
|
||||||
|
new Polygon([
|
||||||
|
[
|
||||||
|
[10, 20],
|
||||||
|
[10, 25],
|
||||||
|
[15, 25],
|
||||||
|
[15, 20],
|
||||||
|
[10, 20],
|
||||||
|
],
|
||||||
|
]),
|
||||||
|
10,
|
||||||
|
'm'
|
||||||
|
),
|
||||||
|
});
|
||||||
|
expect(serialized.firstElementChild).to.xmleql(parse(text));
|
||||||
|
});
|
||||||
|
|
||||||
it('creates During property filter', function () {
|
it('creates During property filter', function () {
|
||||||
const text =
|
const text =
|
||||||
'<wfs:Query xmlns:wfs="http://www.opengis.net/wfs" ' +
|
'<wfs:Query xmlns:wfs="http://www.opengis.net/wfs" ' +
|
||||||
|
|||||||
Reference in New Issue
Block a user