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

René-Luc Dhont rldhont at gmail.com
Mon May 9 09:00:27 PDT 2016


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.

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


More information about the Qgis-developer mailing list