[Qgis-developer] Integrate isselected() expression in core?

Neumann, Andreas a.neumann at carto.net
Mon Sep 26 23:04:00 PDT 2016


Hi Matthias, 

Your proposal sounds good - but besides Nyall hints to name it
"is_selected()" I would also want to make sure that a layer can be
selected by layer name next to be able to select by layer id. The
layer_id is not so useful if I don't want to loop over all layers and
find out what id the layer with my envisaged name has. So it would make
my life much easier, if I could just specify my layer name. My projects
always have unique layer names. If not, it should just pick the first
hit. We already have the same mechanism in place for get_feature(). 

In addition, I would have an additional need to have an expression
function or or a variable that shows the total number of selected
features for a given layer. If we use it in layer scope, I think it
could be a variable, something like @num_selected - could something be a
variable and at the same time also be a function with the same name? So
we could have it as a variable name @num_selected in layer scope and
still provide a function to get the num_selected() features of another
layer? 

Thanks for your replies, 

Andreas 

On 2016-09-26 19:12, Matthias Kuhn wrote:

> Hi Andreas
> 
> On 26/09/16 16:01, Neumann, Andreas wrote: 
> 
>> Hi,
>> 
>> I recently had the need to filter a layer based on a selection, e.g.
>> for QGIS atlas. The expressions plus plugin provides the
>> "isselected(layername)" function which returns true|false for each
>> feature - based on the selection state.
>> 
>> Could we make this a core expression in QGIS without the need to
>> install a plugin? I guess this expression is of quite common use for many.
> 
> At the time I implemented this there were no expression variables
> available and an "expression context" barely existed and therefore a
> proper solution was out of scope, so it was more suitable to ship it
> with a plugin than in core.
> 
> With the current state of expressions it should not be hard to implement
> it in a clean way.
> 
> Proposal:
> isselected(feature, layer_id) <-- explicitly check for a certain feature
> on a certain layer
> isselected(feature_id, layer_id) <-- explicitly check for a certain
> feature on a certain layer
> isselected() <-- shorthand for the current feature / layer from the
> expression context.
> 
> Best regards
> 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

  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20160927/003408c0/attachment-0001.html>


More information about the Qgis-developer mailing list