As I replied to the same question on qgis-developers, you *have* to obtain
a new iterator, because when it finishes iterating it gets closed and you
cannot use it anymore (nor rewind it).

giovanni


2013/10/22 Nathan Woodrow <[email protected]>

> I would just grab a new one.  It's pretty cheap.
>
> - Nathan
>
>
> On Tue, Oct 22, 2013 at 12:01 AM, Stefano Masera <
> [email protected]> wrote:
>
>> The reason is to be more fast.
>> I think that restart an iterator is more fast than grab a new one from
>> the same layer.
>> But I don't know if it's true!
>> Thanks
>>
>>
>> ------------------------------
>> *Da: *"Nathan Woodrow" <[email protected]>
>> *A: *"Stefano Masera" <[email protected]>
>> *Cc: *"qgis-user" <[email protected]>
>> *Inviato: *Lunedì, 21 ottobre 2013 15:56:35
>> *Oggetto: *Re: [Qgis-user] How can I reset the starting point of a
>> QgsFeatureIterator?
>>
>>
>> Just grab a new iterator.  Any reason you want to reuse the same
>> iteratror.
>> On 21/10/2013 11:44 PM, "Stefano Masera" <[email protected]>
>> wrote:
>>
>>> Hi list,
>>> I use an iterator two times in a python code and I have to reset it to
>>> the starting point before to recall it.
>>>
>>> # 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-user mailing list
>>> [email protected]
>>> http://lists.osgeo.org/mailman/listinfo/qgis-user
>>>
>>
>>
>
> _______________________________________________
> Qgis-user mailing list
> [email protected]
> http://lists.osgeo.org/mailman/listinfo/qgis-user
>



-- 
Giovanni Allegri
http://about.me/giovanniallegri
blog: http://blog.spaziogis.it
GEO+ geomatica in Italia http://bit.ly/GEOplus
_______________________________________________
Qgis-user mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/qgis-user

Reply via email to