[Qgis-developer] How can I reset the starting point of a QgsFeatureIterator?

G. Allegri giohappy at gmail.com
Wed Oct 23 08:18:49 PDT 2013


When the iterator has given back all the features it gets closed.
Rewind works only while the iterator si open, so it's supposed to work
while you're stepping through the iteration.
I fear you have to obtain a new iterator to repreat the iteration.

giovanni



2013/10/23 Stefano Masera <stefano.masera at arpa.piemonte.it>

> No, it does False!
>
> But if  I put
> iterator.rewind()
> before the first use of the iterator it does True.
>
>
>
> ------------------------------
> *Da: *"G. Allegri" <giohappy at gmail.com>
> *A: *"Stefano Masera" <stefano.masera at arpa.piemonte.it>
> *Cc: *"qgis-developer" <qgis-developer at lists.osgeo.org>
> *Inviato: *Mercoledì, 23 ottobre 2013 16:36:12
> *Oggetto: *Re: [Qgis-developer] How can I reset the starting point of a
> QgsFeatureIterator?
>
> Does iterator.rewind() return True?
>
>
> 2013/10/23 Stefano Masera <stefano.masera at arpa.piemonte.it>
>
>> Hi list,
>> I use an iterator two times in a python code and I wantto reset it to the
>> starting point before to reuse it.
>> In this way I hope to be more quick.
>>
>> # first use of the iterator
>> iterator = layer.dataProvider().getFeatures()
>> for feature in iterator:
>> #  operations
>> # than, a second time I have to use the operator, in a following part of
>> the code:
>> for feature in iterator:
>> #  other operations
>>
>> But it doesn't start from the first feature!
>>
>> I try with:
>> iterator.rewind()
>> between the two blocks, but it doesn't work.
>>
>> Thanks.
>>
>> Stefano Masera
>>
>>
>> _______________________________________________
>> Qgis-developer mailing list
>> Qgis-developer at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/qgis-developer
>>
>
>
>
> --
> Giovanni Allegri
> http://about.me/giovanniallegri
> blog: http://blog.spaziogis.it
> GEO+ geomatica in Italia http://bit.ly/GEOplus
>
>


-- 
Giovanni Allegri
http://about.me/giovanniallegri
blog: http://blog.spaziogis.it
GEO+ geomatica in Italia http://bit.ly/GEOplus
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20131023/56fcab3c/attachment-0001.html>


More information about the Qgis-developer mailing list