[Qgis-developer] QgsFeatureRequest::FilterFid and QgsFeatureRequest::FilterFids do not retrieve the same Feature

Nyall Dawson nyall.dawson at gmail.com
Tue May 10 00:06:48 PDT 2016


On 10 May 2016 at 02:00, René-Luc Dhont <rldhont at gmail.com> wrote:
> Hi devs,
>
> I have an issue in QGIS Server with features filtered by FeatureId. I can
> reproduce the issue in Python console.
>
> With a vector that has joined attributes and virtual attributes, the
> QgsFeatureRequest::FilterFid retrieves a feature with all the attributes
> values but just the layer fields.
> With the same layer, the QgsFeatureRequest::FilterFids with 1 featureId
> retrieves a feature with all the attributes values and fields.

Good catch - fixed in
https://github.com/qgis/QGIS/commit/3340d8ea70463385feaf72b1b4e4c6e7446b480e

Nyall


>
> You can test it in the Python console with that code wher `l` is the vector
> layer
> ```
> fr = QgsFeatureRequest().setFilterFid( 2
> ).setFlags(QgsFeatureRequest.NoFlags)
> fit = l.getFeatures( fr )
> for feat in fit:
>   len( feat.fields().toList() )
>   len( feat.attributes() )
>
> fr = QgsFeatureRequest().setFilterFids( [2]
> ).setFlags(QgsFeatureRequest.NoFlags)
> fit = l.getFeatures( fr )
> for feat in fit:
>   len( feat.fields().toList() )
>   len( feat.attributes() )
> ```
> In the first case, the len will be different, in the second case it is the
> same.
>
> Does some one know how to fix it ?
>
> Regards,
> René-Luc
> _______________________________________________
> 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