[Qgis-developer] Vector Layer Translate Feature

Pietro Panzeri pietro.panzeri at treuropa.com
Thu Apr 23 10:25:09 EDT 2009


Hi all,

I'm 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.


I already posted this question on the users mailing list and they pointed me 
to this one.

Can someone point me a way to act on the whole layer regardless of the current 
zoom?

Thank you very much.

Pietro


-- 
------------------------------------------------------------
Pietro Panzeri

Tele-Rilevamento Europa - T.R.E. s.r.l.
a POLIMI spin-off company
Via Vittoria Colonna, 7
20149 Milano - Italia
tel.: +39.02.4343.121
fax: +39.02.4343.1230
e-mail: pietro.panzeri at treuropa.com
web: www.treuropa.com
-------------------------------------------------------------



More information about the Qgis-developer mailing list