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

Nyall Dawson nyall.dawson at gmail.com
Tue Aug 30 16:09:23 PDT 2016


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


More information about the Qgis-developer mailing list