Bug report #12629
Vector Layer TranslateFeatures performance (2.8.1 vs 1.8.0)
|Affected QGIS version:||2.8.1||Regression?:||No|
|Operating System:||Linux 3.2.0-27-generic #43-Ubuntu SMP x86_64||Easy fix?:||No|
|Pull Request or Patch supplied:||No||Resolution:||end of life|
|Crashes QGIS or corrupts data:||No||Copied to github as #:||20744|
I developed a plugin for Qgis version 1.8.0 that translates a vector layer with the simple following code:
delta_x = 0.1 delta_y = 0.3 vlayer = iface.activeLayer() for fid in range(vlayer.featureCount()): vlayer.translateFeature(fid, delta_x, delta_y)
then converted for 2.8.1 with the following code:
delta_x = 0.1 delta_y = 0.3 vlayer = iface.activeLayer() for f in vlayer.getFeatures(): fid = f.id() vlayer.translateFeature(fid, delta_x, delta_y)
I experience big performance issues in 2.8.1.
Qgis 1.8.0 performs the translation of the attached ShapeFile in about 4 seconds both for the first translation and the following ones.
Qgis 2.8.1 performs the same translation in about 4 minutes for the first translation and in 20 seconds for the following ones.
The layer loading time is the same for both versions (about 1 second).
I cannot understand the reason of this loss of performance.
I'm available to further test my installations or provide any other data.
The system on which I'm running both Qgis versions is:
Distributor ID: Ubuntu
Description: Ubuntu 12.04.3 LTS
Linux 3.2.0-27-generic #43-Ubuntu SMP Fri Jul 6 14:25:57 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
Thank you very much.
#2 Updated by Matthias Kuhn almost 5 years ago
Can you check if it helps to group it in a single undo command.
I.e. compare the result of the following two snippets
from timeit import * def funct(): vlayer = iface.activeLayer() u = QgsVectorLayerEditUtils( vlayer ) vlayer.beginEditCommand( 'Translate' ) for f in vlayer.getFeatures(): f.id() u.translateFeature(fid, delta_x, delta_y) vlayer.endEditCommand() t = Timer(stmt=funct) print t.timeit(number = 5 )
from timeit import * def funct(): vlayer = iface.activeLayer() u = QgsVectorLayerEditUtils( vlayer ) for f in vlayer.getFeatures(): f.id() u.translateFeature(fid, delta_x, delta_y) t = Timer(stmt=funct) print t.timeit(number = 5 )
#4 Updated by jopan - almost 5 years ago
Firstly I posted this question on the Qgis developers mailing list.
Secondly I tried to play with "grouped"/"ungrouped" and "QgsFeatureRequest().setSubsetOfAttributes()" but the situation didn't change. The first translation in version 2.8.1 still lasted 4 minutes.
#7 Updated by Giovanni Manghi about 1 year ago
- Resolution set to end of life
- Status changed from Open to Closed
End of life notice: QGIS 2.18 LTR