Thank you Daniel, Nathan and Marco for all your hints. I am sure I will manage to do what I want with all of your suggestions!
Andreas Am 06.10.2013 02:00, schrieb Daniel: > Using map() is the pythonic way > > > Maybe ftools need an upgrade :) > > Thanks for the tip > > > On Sat, Oct 5, 2013 at 8:53 PM, Nathan Woodrow <[email protected]> wrote: > >> >> On Sun, Oct 6, 2013 at 9:45 AM, Daniel <[email protected]> wrote: >> >>> def createIndex( provider ): >>> feat = QgsFeature() >>> index = QgsSpatialIndex() >>> fit = provider.getFeatures() >>> while fit.nextFeature( feat ): >>> index.insertFeature( feat ) >>> return index >>> >> >> Try something like this for your createIndex which will work with any >> collection of features: >> >> def createIndex( features ): >> index = QgsSpatialIndex() >> map(index.insertFeature, features) >> return index >> >> index = createIndex(provider.getFeatures()) >> >> and also because I hate seeing while nextFeature() used :) >> >> - Nathan >> >> >> > > _______________________________________________ Qgis-developer mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/qgis-developer
