Opened 15 years ago
Closed 15 years ago
#1657 closed bug (fixed)
Vector Layer Translate Feature
Reported by: | jopan | Owned by: | mhugent |
---|---|---|---|
Priority: | major: does not work as expected | Milestone: | |
Component: | Python plugins and bindings | Version: | 1.0.0 |
Keywords: | Cc: | ||
Must Fix for Release: | No | Platform: | Debian |
Platform Version: | Awaiting user input: | no |
Description
Writing a Python plugin to allow the user to translate a whole vector layer by a given shift I use the translateFeature() of the QgsVectorLayer class but if the layer is zoomed the function translates only the visualized features.
I use the following code:
vlayer = iface.activeLayer()
provider = vlayer.dataProvider() attrs = provider.attributeIndexes() provider.select(attrs)
f = QgsFeature()
while provider.nextFeature(f):
error_code = vlayer.translateFeature(f.id(), delta_x, delta_y)
If the feature to translate is not one of the visualized features, the error_code is 1 and the feature is not translated.
Fixed in trunk r10667