Hi Graham,

I have already tried that. I have two different cases 'update' and 'update_batch'.

Regards,

Vikram

On 22/01/2020 22:57, Humphries, Graham wrote:

I just looking at your code I think the problem may be with the call to transactWFS.

The update function called is written like this: formatWFS.writeTransaction(null,[f],null,formatGML);

Your clones object is already an array, so you are than wrapping that in an array with only one element. Try modifying the writeTransaction call to this:

:formatWFS.writeTransaction(null,f,null,formatGML);

Cheers,

Graham

*From:*Vikram [mailto:[email protected]]
*Sent:* Wednesday, 22 January 2020 9:10 PM
*To:* [email protected]
*Subject:* [Geoserver-users] OpenLayers GeoServer update an array of features using WFS-T

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.

varclones =[]
selectedFeatures.forEach(function(feature){
varfeatureProperties =feature.getProperties();
deletefeatureProperties.boundedBy;
varclone =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){
varnode;
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;
}
varpayload =xs.serializeToString(node);
    $.ajax('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){
varerrorMsg =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


------------------------------------------------------------------------

CONFIDENTIALITY NOTICE AND DISCLAIMER
The information in this transmission may be confidential and/or protected by legal professional privilege, and is intended only for the person or persons to whom it is addressed. If you are not such a person, you are warned that any disclosure, copying or dissemination of the information is unauthorised. If you have received the transmission in error, please immediately contact this office by telephone, fax or email, to inform us of the error and to enable arrangements to be made for the destruction of the transmission, or its return at our cost. No liability is accepted for any unauthorised use of the information contained in this transmission.
_______________________________________________
Geoserver-users mailing list

Please make sure you read the following two resources before posting to this 
list:
- Earning your support instead of buying it, but Ian Turton: 
http://www.ianturton.com/talks/foss4g.html#/
- The GeoServer user list posting guidelines: 
http://geoserver.org/comm/userlist-guidelines.html

If you want to request a feature or an improvement, also see this: 
https://github.com/geoserver/geoserver/wiki/Successfully-requesting-and-integrating-new-features-and-improvements-in-GeoServer


[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Reply via email to