HI all,
I am trying to update features using WFS-T update. I am sending the request from my website (OpenLayers) by passing an array of features.
However, I have noticed that the attributes and geometry of last feature in the array is copied to all other features.
For example, if I pass 5 features to the writeTransaction method to update an attribute of all 5 features, it copies the attributes and geometry of the 5th feature to the other features.
var clones = []
selectedFeatures.forEach(function (feature) {
var featureProperties = feature.getProperties();
delete featureProperties.boundedBy;
var clone = feature.clone();
clone.setId(feature.getId());
clone.setGeometryName('the_geom');
clone.setProperties({'xyz':'xyz'})
clones.push(clone)
})
console.log(clones)
transactWFS('update_batch', clones);
int the transactWFS method,
transactWFS = function (mode, f) {
var node;
switch (mode) {
case 'insert':
node = formatWFS.writeTransaction([f], null, null, formatGML);
break;
case 'update':
node = formatWFS.writeTransaction(null, [f], null, formatGML);
break;
case 'update_batch':
node = formatWFS.writeTransaction(null, f, null, formatGML);
break;
case 'delete':
node = formatWFS.writeTransaction(null, null, [f], formatGML);
break;
}
var payload = xs.serializeToString(node);
$.ajax('[http://localhost:8080/geoserver/TEST/ows](http://localhost:8080/geoserver/TEST/ows)', {
service: 'WFS',
type: 'POST',
dataType: 'xml',
processData: false,
contentType: 'text/xml',
data: payload,
success: function(data) {
},
error: function(e) {
var errorMsg = e? (e.status + ' ' + e.statusText) : "";
alert('Error saving this feature to GeoServer.<br><br>'
+ errorMsg);
}
}).done(function() {
wfsSource.refresh()
});
};
Does anyone have a solution?
Regards,
Vikram
