Add an option to writeTransaction to support 3D geometries

Close #6630
This commit is contained in:
Julien Enselme
2017-04-06 18:10:34 +02:00
parent ea54543602
commit 870bc51ad9
7 changed files with 209 additions and 19 deletions

View File

@@ -880,6 +880,86 @@ describe('ol.format.WFS', function() {
});
});
describe('when writing out a transaction request', function() {
var text;
var filename = 'spec/ol/format/wfs/TransactionMultiVersion100_3D.xml';
before(function(done) {
afterLoadText(filename, function(xml) {
text = xml;
done();
});
});
it('handles 3D in WFS 1.0.0', function() {
var format = new ol.format.WFS();
var insertFeature = new ol.Feature({
the_geom: new ol.geom.LineString([[1.1, 2, 4], [3, 4.2, 5]]),
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, 6], [3, 4.2, 7]]),
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 serialized = format.writeTransaction(inserts, updates, null, {
featureNS: 'http://www.openplans.org/topp',
featureType: 'states',
featurePrefix: 'topp',
is3D: true,
version: '1.0.0'
});
expect(serialized).to.xmleql(ol.xml.parse(text));
});
});
describe('when writing out a Transaction request', function() {
var text;
before(function(done) {
afterLoadText('spec/ol/format/wfs/TransactionMulti_3D.xml', function(xml) {
text = xml;
done();
});
});
it('handles 3D in WFS 1.1.0', function() {
var format = new ol.format.WFS();
var insertFeature = new ol.Feature({
the_geom: new ol.geom.MultiPoint([[1, 2, 3]]),
foo: 'bar',
nul: null
});
insertFeature.setGeometryName('the_geom');
var inserts = [insertFeature];
var updateFeature = new ol.Feature({
the_geom: new ol.geom.MultiPoint([[1, 2, 3]]),
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 serialized = format.writeTransaction(inserts, updates, null, {
featureNS: 'http://www.openplans.org/topp',
featureType: 'states',
is3D: true,
featurePrefix: 'topp'
});
expect(serialized).to.xmleql(ol.xml.parse(text));
});
});
describe('when writing out a GetFeature request', function() {
var text;

View File

@@ -0,0 +1,32 @@
<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,4 3,4.2,5</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,6 3,4.2,7</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>
</Transaction>

View File

@@ -0,0 +1,40 @@
<wfs:Transaction xmlns:wfs="http://www.opengis.net/wfs" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" service="WFS" version="1.1.0" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd">
<wfs:Insert>
<feature:states xmlns:feature="http://www.openplans.org/topp">
<feature:the_geom>
<gml:MultiPoint xmlns:gml="http://www.opengis.net/gml">
<gml:pointMember>
<gml:Point>
<gml:pos>1 2 3</gml:pos>
</gml:Point>
</gml:pointMember>
</gml:MultiPoint>
</feature:the_geom>
<feature:foo>bar</feature:foo>
</feature:states>
</wfs:Insert>
<wfs:Update xmlns:wfs="http://www.opengis.net/wfs" typeName="topp:states" xmlns:topp="http://www.openplans.org/topp">
<wfs:Property>
<wfs:Name>the_geom</wfs:Name>
<wfs:Value>
<gml:MultiPoint xmlns:gml="http://www.opengis.net/gml">
<gml:pointMember>
<gml:Point>
<gml:pos>1 2 3</gml:pos>
</gml:Point>
</gml:pointMember>
</gml:MultiPoint>
</wfs:Value>
</wfs:Property>
<wfs:Property>
<wfs:Name>foo</wfs:Name>
<wfs:Value>bar</wfs:Value>
</wfs:Property>
<wfs:Property>
<wfs:Name>nul</wfs:Name>
</wfs:Property>
<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
<ogc:FeatureId fid="fid.42"/>
</ogc:Filter>
</wfs:Update>
</wfs:Transaction>