Vector Layer Translate Feature

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Vector Layer Translate Feature

Pietro Panzeri
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: [hidden email]
web: www.treuropa.com
-------------------------------------------------------------

_______________________________________________
Qgis-developer mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/qgis-developer
Reply | Threaded
Open this post in threaded view
|

AW: Vector Layer Translate Feature

Hugentobler  Marco
Hi Pietro

This is probably a bug in the editing code of vector layer. I think it only checks the cached geometries (in view) and not the other ones. Please fill a bug into the tracker and assign it to me.

Regards,
Marco


-----Urspr√ľngliche Nachricht-----
Von: [hidden email] im Auftrag von Pietro Panzeri
Gesendet: Do 23.04.2009 16:25
An: [hidden email]
Betreff: [Qgis-developer] Vector Layer Translate Feature
 
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: [hidden email]
web: www.treuropa.com
-------------------------------------------------------------

_______________________________________________
Qgis-developer mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/qgis-developer

_______________________________________________
Qgis-developer mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/qgis-developer