[Qgis-developer] delete selected features slow (because of featurecount/events)??

Matthias Kuhn matthias at opengis.ch
Wed Nov 16 01:46:20 PST 2016


Hi Richard,

What the trash button does is

vl.beginEditCommand( "Delete Selected Features" )
vl.deleteSelectedFeatures()
vl.endEditCommand()

This makes me think, that the "with edit" construct could actually wrap
things into a single edit command as well.

Matthias

On 11/14/2016 04:55 PM, Richard Duivenvoorde wrote:
> 
> Hi Dev's,
> 
> having a small dataset of 300 features (from an online service).
> 
> I want to quickly remove most/all of those features, request a new set
> an put them in the same vectorlayer (in a python plugin).
> 
> All ok, untill you activate the 'show feature count' in the legend.
> 
> If you show the featurecount, it looks like the features are deleted one
> by one: you can see the featurecount go down to zero... ( but I also
> have dataset with a lot more features :-( ) and it takes several (ten's)
> seconds.
> 
> Easy testable:
> 
> - load some data, tick the 'show feature count' tickbox in the legend.
> - make the layer editable and select all features
> - make sure the layer is current in the legend
> 
> do the following in the python console:
> 
> l=iface.mapCanvas().currentLayer()
> l.deleteSelectedFeatures()
> 
> you can see the 'feature count' go down one by one (slowly...)
> 
> while... if you do it outside of python, using the little red
> delete-basket in the edit-toolbar. All features are deleted in a blink!
> Also if you show the featurecount...
> 
> I tried some different ways, but could not find a quick way?
> 
> Do I miss something/a quicker way?
> 
> I thought that it maybe had something to do with filling up the
> 'editbuffer', so tried with and without the 'edit' construct [0]
> But in this case I just do not want an edit-buffer anyway..
> 
> Regards,
> 
> Richard Duivenvoorde
> 
> 
> [0]
> http://www.opengis.ch/2015/08/12/with-edit-layer/#avoid-using-dataprovider-methods
> 
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer


More information about the Qgis-developer mailing list