I would like to know what is the way to delete hundreds of polygons by attribute, using OpenLayers6 ? The layer is a polygon WFS layer stored in PostGis, published by GeoServer. For example, in a layer there are lots of polygons that have attribute 'projectid'=1, which I want to delete. OpenLayers version I am using is ol 6.15.1.
I initially tried to find a way that has the fastest processing time, unfortunately all approaches I found still have problems.
I noticed few ways from the internet that I already tried, but each have their own problems.
What I have tried:
Using writeTransaction(null,null,features, formatGML).
This way, the time was spent in both looping/checking/populating the features that have 'projectid'=1 and waiting for the POST request process of the "writeTransaction". I managed to delete 1 feature with this method, but when I tried hundreds, it began to not responding. Deletion did not happen, and the response of the POST request was not sent back. I began to think this method was not suitable for large number of feature deletion.
Using vectorSource.removeFeature(feature).
I thought this way was faster since I just needed to loop/check all features that have 'projectid'=1, and the removal happened inside the same loop. However, the reality was that the function did not delete the features. The features still exist in the layer even though the loop and "removeFeature" function ran without any error. Does anyone knows why? Or maybe I need to run additional codes after this?
I would like to know is there any other removal / delete approach I can use to delete by attribute with OpenLayer 6?
I want to begin my question from the big image first: what method, without my scripts. But definitely I can show you my sample codes if needed. I might need to ask for the sample script too in the end.
Looking forward to your advise.