Add support for WFS 1.0.0 to ol.format.WFS#writeTransaction

- Add a version property to olx.format.WFSWriteTransactionOptions to set
the WFS protocol version to use
- Use the specified version to use the correct schema and version in the
GML request
- Use the version to select the proper GML serializer
This commit is contained in:
Julien Enselme
2017-02-17 15:07:56 +01:00
parent 1320168cca
commit ecafa44196
4 changed files with 135 additions and 14 deletions

View File

@@ -795,6 +795,50 @@ describe('ol.format.WFS', function() {
});
});
describe('when writing out a Transaction request', function() {
var text;
var filename = 'spec/ol/format/wfs/TransactionMultiVersion100.xml';
before(function(done) {
afterLoadText(filename, function(xml) {
text = xml;
done();
});
});
it('handles the WFS version', function() {
var format = new ol.format.WFS();
var insertFeature = new ol.Feature({
the_geom: new ol.geom.LineString([[1.1, 2], [3, 4.2]]),
foo: 'bar',
nul: null
});
insertFeature.setGeometryName('the_geom');
var inserts = [insertFeature];
var updateFeature = new ol.Feature({
the_geom: new ol.geom.LineString([[1.1, 2], [3, 4.2]]),
foo: 'bar',
// null value gets Property element with no Value
nul: null,
// undefined value means don't create a Property element
unwritten: undefined
});
updateFeature.setId('fid.42');
var updates = [updateFeature];
var deleteFeature = new ol.Feature();
deleteFeature.setId('fid.37');
var deletes = [deleteFeature];
var serialized = format.writeTransaction(inserts, updates, deletes, {
featureNS: 'http://www.openplans.org/topp',
featureType: 'states',
featurePrefix: 'topp',
version: '1.0.0'
});
expect(serialized).to.xmleql(ol.xml.parse(text));
});
});
describe('when writing out a GetFeature request', function() {
var text;

View File

@@ -0,0 +1,37 @@
<Transaction xmlns="http://www.opengis.net/wfs" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" service="WFS" version="1.0.0" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/wfs.xsd">
<Insert>
<states xmlns="http://www.openplans.org/topp">
<the_geom>
<LineString xmlns="http://www.opengis.net/gml">
<coordinates decimal="." cs="," ts=" ">1.1,2 3,4.2</coordinates>
</LineString>
</the_geom>
<foo>bar</foo>
</states>
</Insert>
<Update xmlns:wfs="http://www.opengis.net/wfs" typeName="topp:states" xmlns:topp="http://www.openplans.org/topp">
<Property>
<Name>the_geom</Name>
<Value>
<LineString xmlns="http://www.opengis.net/gml">
<coordinates decimal="." cs="," ts=" ">1.1,2 3,4.2</coordinates>
</LineString>
</Value>
</Property>
<Property>
<Name>foo</Name>
<Value>bar</Value>
</Property>
<Property>
<Name>nul</Name>
</Property>
<Filter xmlns="http://www.opengis.net/ogc">
<FeatureId fid="fid.42"/>
</Filter>
</Update>
<Delete xmlns:wfs="http://www.opengis.net/wfs" typeName="topp:states" xmlns:topp="http://www.openplans.org/topp">
<Filter xmlns="http://www.opengis.net/ogc">
<FeatureId fid="fid.37"/>
</Filter>
</Delete>
</Transaction>