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

Nyall Dawson nyall.dawson at gmail.com
Mon Sep 26 15:58:17 PDT 2016


On 27 September 2016 at 03:12, Matthias Kuhn <matthias at opengis.ch> 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.

Sounds good to me. As much as I hate the idea of styling based on
something as transient as a selection there's obviously demand for
this, so as long as it's done in the right way (using contexts) I'm
not against it. The is_selected() method could even use a scoped
expression function provided by the layer scope to avoid the need to
retrieve layers by id.

Just a note that it would need to be "is_selected(...)" to keep the
standard naming of other expression functions.

Maybe this could even be integrated with Nathan's experiments with
selection presets...

Nyall





>
> 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


More information about the Qgis-developer mailing list