Re: [QGIS-Developer] Concatenating QgsFeatureRequest

2017-12-20 Thread matteo
Hi Etienne,

yep Nyall's blog is really outstanding useful, thanks!

Cheers

Matteo
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [QGIS-Developer] Concatenating QgsFeatureRequest

2017-12-20 Thread matteo
Hi Matthias,

thanks for the help!

Matteo
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [QGIS-Developer] Concatenating QgsFeatureRequest

2017-12-19 Thread Etienne Trimaille
Hi,

You should have a look to the blog post from Nyall:
http://nyalldawson.net/2016/10/speeding-up-your-pyqgis-scripts/
So you can still use your `setFilterExpression`

1
2
3
request =
QgsFeatureRequest().setFilterFids(vector_layer.selectedFeaturesIds())
for feature in vector_layer.getFeatures(request):
# do something with the feature


2017-12-19 16:41 GMT+01:00 Matthias Kuhn :

> Hi Matteo,
>
> No, it's not possible to combine the two in the query itself.
>
> But sending the request with the filter expression and then checking if
> each feature's id is in selectedFeatureIds() should be straightforward.
>
> selcted_ids = layer.selectedFeatureIds()
> for feature in layer.getFeatures(request):
> if feature.id() in selected_ids:
> do_amazing_stuff_with(feature)
>
> Matthias
>
> On 12/19/2017 04:33 PM, matteo wrote:
> > Hi devs,
> >
> > maybe the question can sound trivial but I didn't find a solution.
> >
> > Simply I would like to iterate only on selected features of a vector
> > layer features with an expression.
> >
> > I know that the QgsFeatureRequest can be used with `setFilterExpression`
> > and `setFilterFids`.
> >
> > Is it possible to combine them, so merging the following example in an
> > unique request?
> >
> > exp = ''' "PH" > 7 '''
> > request = QgsFeatureRequest().setFilterExpression(exp)
> > l = [i.id() for i in vl.selectedFeatures()]
> > request = QgsFeatureRequest().setFilterFids(l)
> >
> > for i in vl.getFeatures(request):
> > ..
> >
> >
> > Thanks for all the suggestions!
> >
> > Cheers
> >
> > Matteo
> > ___
> > QGIS-Developer mailing list
> > QGIS-Developer@lists.osgeo.org
> > List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> > Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> >
> ___
> QGIS-Developer mailing list
> QGIS-Developer@lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [QGIS-Developer] Concatenating QgsFeatureRequest

2017-12-19 Thread Matthias Kuhn
Hi Matteo,

No, it's not possible to combine the two in the query itself.

But sending the request with the filter expression and then checking if
each feature's id is in selectedFeatureIds() should be straightforward.

selcted_ids = layer.selectedFeatureIds()
for feature in layer.getFeatures(request):
if feature.id() in selected_ids:
do_amazing_stuff_with(feature)

Matthias

On 12/19/2017 04:33 PM, matteo wrote:
> Hi devs,
> 
> maybe the question can sound trivial but I didn't find a solution.
> 
> Simply I would like to iterate only on selected features of a vector
> layer features with an expression.
> 
> I know that the QgsFeatureRequest can be used with `setFilterExpression`
> and `setFilterFids`.
> 
> Is it possible to combine them, so merging the following example in an
> unique request?
> 
> exp = ''' "PH" > 7 '''
> request = QgsFeatureRequest().setFilterExpression(exp)
> l = [i.id() for i in vl.selectedFeatures()]
> request = QgsFeatureRequest().setFilterFids(l)
> 
> for i in vl.getFeatures(request):
> ..
> 
> 
> Thanks for all the suggestions!
> 
> Cheers
> 
> Matteo
> ___
> QGIS-Developer mailing list
> QGIS-Developer@lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> 
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

[QGIS-Developer] Concatenating QgsFeatureRequest

2017-12-19 Thread matteo
Hi devs,

maybe the question can sound trivial but I didn't find a solution.

Simply I would like to iterate only on selected features of a vector
layer features with an expression.

I know that the QgsFeatureRequest can be used with `setFilterExpression`
and `setFilterFids`.

Is it possible to combine them, so merging the following example in an
unique request?

exp = ''' "PH" > 7 '''
request = QgsFeatureRequest().setFilterExpression(exp)
l = [i.id() for i in vl.selectedFeatures()]
request = QgsFeatureRequest().setFilterFids(l)

for i in vl.getFeatures(request):
..


Thanks for all the suggestions!

Cheers

Matteo
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer