[Qgis-developer] QgsFeatureRerquest filters are mutually exclusive? why?

Luigi Pirelli luipir at gmail.com
Sat Dec 20 03:38:01 PST 2014


remain the question... why filters are mutually exclusive.

regards, Luigi Pirelli

On 20 December 2014 at 12:34, Luigi Pirelli <luipir at gmail.com> wrote:
> filter combination works only if setting attribute filter with
>
> http://qgis.org/api/classQgsVectorLayer.html#a6ad141dfa9a0243c0c1c9fa422379e40
>
> a snippet that works is
>
> # iteration getting only selected features
> rect = QgsRectangle(  1223070.695,  2293653.357 , 9046974.211,  4184988.662)
>
> request =  QgsFeatureRequest()
> request.setSubsetOfAttributes([0, 2])
> myVector.setSubsetString('"AREA_MI" > 1000') <--------------------
> request.setFilterRect( rect )
>
> #request.setFlags(QgsFeatureRequest.ExactIntersect or
> QgsFeatureRequest.SubsetOfAttributes)
>
> for index, feature in enumerate( myVector.getFeatures( request ) ):
>     print "The record %d has ID %d" % ( index, feature.id() )
>
> regards Luigi Pirelli
>
>
> On 20 December 2014 at 11:57, Luigi Pirelli <luipir at gmail.com> wrote:
>> Hi,
>>
>> I realised that some filter in QgsFeatureRequest are mutually exclusive
>>
>> the following gist on alaska.shp (in alaska crs)
>> https://gist.github.com/luipir/fcbc318304944962dfec#file-gistfile1-py
>>
>> return 283 Elements
>>
>> but uncomment spatial filter request.setFilterRect( rect ) return only
>> 10 records
>>
>> seems that the mutual exclusivity is coded here
>> http://qgis.org/api/qgsvectorlayerfeatureiterator_8cpp_source.html#l00126
>>
>> and mFilter in QgsFeatureRequest is NOT managed in OR during setting
>> in http://qgis.org/api/qgsfeaturerequest_8cpp_source.html
>>
>> it's a bug or a feature or not implemented or my fault in using filtering?
>>
>> regards, Luigi Pirelli


More information about the Qgis-developer mailing list