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 <madman...@gmail.com> wrote:

>
> On Sun, Oct 6, 2013 at 9:45 AM, Daniel <daniel...@gmail.com> 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
>
>
>


-- 
Daniel Vaz
_______________________________________________
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer

Reply via email to