[Qgis-developer] Python and strange results using layer(.dataProvider()).getFeatures(...)

Casper Børgesen (CABO) CABO at NIRAS.DK
Wed Aug 31 00:17:14 PDT 2016


Hi Matthias and Nyall,

Thanks for your comments. 

I've created the issue: http://hub.qgis.org/issues/15505

Regards, Casper

-----Original Message-----
From: Qgis-developer [mailto:qgis-developer-bounces at lists.osgeo.org] On Behalf Of Nyall Dawson
Sent: 31. august 2016 01:09
To: Matthias Kuhn
Cc: qgis-developer
Subject: Re: [Qgis-developer] Python and strange results using layer(.dataProvider()).getFeatures(...)

On 30 August 2016 at 23:52, Matthias Kuhn <matthias at opengis.ch> wrote:
> Hi Casper
>
> On 08/30/2016 02:59 PM, Casper Børgesen (CABO) wrote:
>> Hi Nathan
>>
>>
>>
>> Thanks for clarifying that, I’ll try to put my faith in the layer. My 
>> question is then, why does the layer only respond with 2 features 
>> when I ask it for max 3 features, since 4 – 1 = 3?
>>
>
> I guess (no verification done) that in the background the limit is 
> forwarded to the dataprovider which returns 3 features from which 1 is 
> filtered out by the layer so only 2 remain.
>
> Please report this as a bug. I'm not sure if an action will be taken, 
> most of the "fixes" to this which I can think of defeat the purpose of 
> sending as few requests as possible to the database, but on the other 
> hand, this situation here can really lead to confusion.

I'd say something like this could work. In QgsVectorLayerFeatureIterator:
- take the feature request limit for mProviderRequest
- if deleted features are present in the edit buffer, add the number of deleted features to the limit in mProviderRequest
- if changed feature attributes are present, and the request is an expression based request, add the number of changed features to the limit (could be smarter here and check which attributes are required by the filter + which have changed)
- if geometry changes are present and a filter rect is in place then add the number of geometry changes to the limit

That would still gain us most of the benefits of feature limits + handle this case, and the only penalty is present when the bug would otherwise show itself.

Nyall



>
> Matthias
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer
_______________________________________________
Qgis-developer mailing list
Qgis-developer at lists.osgeo.org
List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer


More information about the Qgis-developer mailing list