Merge pull request #7198 from bartvde/wfs-update-geom-name
Use geometry name in WFS updates
This commit is contained in:
@@ -461,6 +461,7 @@ ol.format.WFS.writeUpdate_ = function(node, feature, objectStack) {
|
||||
var featurePrefix = context['featurePrefix'];
|
||||
var featureNS = context['featureNS'];
|
||||
var typeName = ol.format.WFS.getTypeName_(featurePrefix, featureType);
|
||||
var geometryName = feature.getGeometryName();
|
||||
node.setAttribute('typeName', typeName);
|
||||
ol.xml.setAttributeNS(node, ol.format.WFS.XMLNS, 'xmlns:' + featurePrefix,
|
||||
featureNS);
|
||||
@@ -471,7 +472,11 @@ ol.format.WFS.writeUpdate_ = function(node, feature, objectStack) {
|
||||
for (var i = 0, ii = keys.length; i < ii; i++) {
|
||||
var value = feature.get(keys[i]);
|
||||
if (value !== undefined) {
|
||||
values.push({name: keys[i], value: value});
|
||||
var name = keys[i];
|
||||
if (value instanceof ol.geom.Geometry) {
|
||||
name = geometryName;
|
||||
}
|
||||
values.push({name: name, value: value});
|
||||
}
|
||||
}
|
||||
ol.xml.pushSerializeAndPop(/** @type {ol.XmlNodeStackItem} */ (
|
||||
|
||||
@@ -696,6 +696,27 @@ describe('ol.format.WFS', function() {
|
||||
});
|
||||
expect(serialized).to.xmleql(ol.xml.parse(text));
|
||||
});
|
||||
|
||||
it('creates the correct update if geometry name is alias', function() {
|
||||
var format = new ol.format.WFS();
|
||||
var updateFeature = new ol.Feature(new ol.geom.MultiLineString([[
|
||||
[-12279454, 6741885],
|
||||
[-12064207, 6732101],
|
||||
[-11941908, 6595126],
|
||||
[-12240318, 6507071],
|
||||
[-12416429, 6604910]
|
||||
]]));
|
||||
updateFeature.setGeometryName('the_geom');
|
||||
updateFeature.setId('FAULTS.4455');
|
||||
var serialized = format.writeTransaction(null, [updateFeature], null, {
|
||||
featureNS: 'http://foo',
|
||||
featureType: 'FAULTS',
|
||||
featurePrefix: 'foo',
|
||||
gmlOptions: {srsName: 'EPSG:900913'}
|
||||
});
|
||||
expect(serialized).to.xmleql(ol.xml.parse(text));
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('when writing out a Transaction request', function() {
|
||||
@@ -809,6 +830,7 @@ describe('ol.format.WFS', function() {
|
||||
unwritten: undefined
|
||||
});
|
||||
updateFeature.setId('fid.42');
|
||||
updateFeature.setGeometryName('the_geom');
|
||||
var updates = [updateFeature];
|
||||
|
||||
var deleteFeature = new ol.Feature();
|
||||
@@ -878,6 +900,7 @@ describe('ol.format.WFS', function() {
|
||||
unwritten: undefined
|
||||
});
|
||||
updateFeature.setId('fid.42');
|
||||
updateFeature.setGeometryName('the_geom');
|
||||
var updates = [updateFeature];
|
||||
|
||||
var deleteFeature = new ol.Feature();
|
||||
@@ -921,6 +944,7 @@ describe('ol.format.WFS', function() {
|
||||
unwritten: undefined
|
||||
});
|
||||
updateFeature.setId('fid.42');
|
||||
updateFeature.setGeometryName('the_geom');
|
||||
var updates = [updateFeature];
|
||||
|
||||
var deleteFeature = new ol.Feature();
|
||||
@@ -962,6 +986,7 @@ describe('ol.format.WFS', function() {
|
||||
// undefined value means don't create a Property element
|
||||
unwritten: undefined
|
||||
});
|
||||
updateFeature.setGeometryName('the_geom');
|
||||
updateFeature.setId('fid.42');
|
||||
var updates = [updateFeature];
|
||||
|
||||
@@ -1003,6 +1028,7 @@ describe('ol.format.WFS', function() {
|
||||
// undefined value means don't create a Property element
|
||||
unwritten: undefined
|
||||
});
|
||||
updateFeature.setGeometryName('the_geom');
|
||||
updateFeature.setId('fid.42');
|
||||
var updates = [updateFeature];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user