Bug report #1657
Vector Layer Translate Feature
Status: | Closed | ||
---|---|---|---|
Priority: | Low | ||
Assignee: | Marco Hugentobler | ||
Category: | Python plugins | ||
Affected QGIS version: | Regression?: | No | |
Operating System: | Debian | Easy fix?: | No |
Pull Request or Patch supplied: | Resolution: | fixed | |
Crashes QGIS or corrupts data: | Copied to github as #: | 11717 |
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.
History
#1 Updated by Marco Hugentobler over 15 years ago
- Resolution set to fixed
- Status changed from Open to Closed
Fixed in trunk e137b095 (SVN r10668)