[Qgis-developer] vectordataprovider.rewind() problem?
Carson Farmer
carson.farmer at gmail.com
Tue Nov 25 18:48:06 EST 2008
Martin Dobias wrote:
> On Tue, Nov 25, 2008 at 9:14 PM, Carson Farmer <carson.farmer at gmail.com> wrote:
>
>> [...]
>> vproviderB.rewind()
>> while vproviderB.nextFeature( inFeatA ):
>> geom = QgsGeometry( inFeatA.geometry() )
>> [...]
>>
>> Essentially what all this does, is loop through layerA, and calculates
>> differences and intersections with layerB, then loops through layerB, and
>> calculates difference with layerA. Technically, I don't even think rewind()
>> needs to be called here at all, but then again... it's not working that way
>> either?
>>
>
> But actually have you called vproviderB.select() before calling
> vproviderB.nextFeautre()? I don't see it in the code (neither for
> vproviderA).
>
Hi Martin,
Sorry I didn't include that in my last email:
vproviderA = vlayerA.dataProvider()
allAttrsA = vproviderA.attributeIndexes()
vproviderA.select( allAttrsA )
and the same goes for vproviderB as well...
> rewind() itself only resets internal counter for iterations with
> nextFeature() and without a preceding select() it has no use. In
> select() you define what stuff do you want to get from the provider,
> by calling rewind() in fact you say you want the same stuff again.
>
>
>> But what I'm no longer getting, is the interaction through layerB... the
>> first bit runs fine, but the second bit won't run... it used too? I'm not
>> entirely sure what's going on (abviously) so I'm going to continue to look
>> into this using smaller examples to pint point the problem... I was really
>> just interested in hearing if others were getting similar problems...
>>
>
> In first bit you use featureAtId() which is independent from the
> select/nextFeature/(rewind) combination.
>
Right, so I shouldn't really have to call rewind() in the first place
should I?
Carson
More information about the Qgis-developer
mailing list