<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /></head><body style='font-size: 10pt; font-family: Verdana,Geneva,sans-serif'>
<p>Hi Matthias,</p>
<p>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().</p>
<p>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?</p>
<p>Thanks for your replies,</p>
<p>Andreas</p>
<p>On 2016-09-26 19:12, Matthias Kuhn wrote:</p>
<blockquote type="cite" style="padding: 0 0.4em; border-left: #1010ff 2px solid; margin: 0"><!-- html ignored --><!-- head ignored --><!-- meta ignored -->
<div class="pre" style="margin: 0; padding: 0; font-family: monospace">Hi Andreas<br /><br /> On 26/09/16 16:01, Neumann, Andreas wrote:
<blockquote type="cite" style="padding: 0 0.4em; border-left: #1010ff 2px solid; margin: 0"><br /> Hi,<br /><br /> I recently had the need to filter a layer based on a selection, e.g.<br /> for QGIS atlas. The expressions plus plugin provides the<br /> "isselected(layername)" function which returns true|false for each<br /> feature - based on the selection state.<br /><br /> Could we make this a core expression in QGIS without the need to<br /> install a plugin? I guess this expression is of quite common use for many.<br /><br /></blockquote>
<br /> At the time I implemented this there were no expression variables<br /> available and an "expression context" barely existed and therefore a<br /> proper solution was out of scope, so it was more suitable to ship it<br /> with a plugin than in core.<br /><br /> With the current state of expressions it should not be hard to implement<br /> it in a clean way.<br /><br /> Proposal:<br /> isselected(feature, layer_id) <-- explicitly check for a certain feature<br /> on a certain layer<br /> isselected(feature_id, layer_id) <-- explicitly check for a certain<br /> feature on a certain layer<br /> isselected() <-- shorthand for the current feature / layer from the<br /> expression context.<br /><br /> Best regards<br /> Matthias<br /><br /> _______________________________________________<br /> Qgis-developer mailing list<br /><a href="mailto:Qgis-developer@lists.osgeo.org">Qgis-developer@lists.osgeo.org</a><br /> List info: <a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer">http://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br /> Unsubscribe: <a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer">http://lists.osgeo.org/mailman/listinfo/qgis-developer</a></div>
</blockquote>
<p> </p>
<div> </div>
</body></html>