Il Monday 30 March 2009 14:43:49 Carson Farmer ha scritto: > Pietro, > > > 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. > > > > Can someone point me a way to act on the whole layer regardless of the > > current zoom? > > In your provider.select() call, what do you use for the spatial filter? > If you want to run through all features in the layer, make sure you > don't specify any bounds in the rect variable: > > attrs = provider.attributeIndexes() > provider.select(attrs) > > or if that doesn't work, specify the extent of the layer as the rect > using layer.extent(), which is inherited from QgsMapLayer... > > Cheers, > > Carson
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 don't know if this is the correct approach. Please tell me where I'm doing wrong. Thank you. 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.panz...@treuropa.com web: www.treuropa.com ------------------------------------------------------------- _______________________________________________ Qgis-user mailing list Qgis-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/qgis-user