[Qgis-developer] Expression to get label reference point X and Y for use with geometry generator (make_line) ?

Régis Haubourg regis.haubourg at gmail.com
Thu May 4 06:47:31 PDT 2017


Hi!

I submitted a bunch of QEP on that topic, if you have customers interested
to go ahead, we probably should mutualize things there and seek for common
budgets too.
What makes sense to me is that Callouts connectors make sense when labels
have been manually moved, not much for automated placement. If you let PAL
use "around point", then you will draw random lines in all directions,
which is not nice on screen.
If you align all labels using a corner placement option, then I think you
can compute easily the offset XY from centroid also.

What my plugin does for custom labeling is that it takes profit of the
pin/unpin buttons which writes the PAL computed to the XY columns.

Good news, I ported the plugin to QGIS3 at the hackfest, it's now in the
repo and here:

https://github.com/haubourg/EasyCustomLabeling/blob/qgis3_port/EasyCustomLabeling/EasyCustomLabeling.py

Feel free to submit a PR to replace the Line Label layer by a pure copy of
the source layer, and replace lines by a geometry generator (I wish I had
time for it)

Régis

2017-05-04 14:39 GMT+02:00 kimaidou <kimaidou at gmail.com>:

> Hi QGIS !
>
> I am playing with data-defined label position, with 2 column label_x and
> label_y.
> I use a geometry generator to draw the line between the label and the
> feature centroid, like
>
> make_line(
>   centroid( $geometry ),
>   make_point( "label_x", "label_y" )
> )
>
> It work pretty well (with some rectangle background under the label text),
> but it is obviously only active when the label_x and label_y fields are not
> NULL ( when the label is pinned )
>
> I would like to draw this line for any features (perhaps depending on this
> line length). So basically, I would need 2 new functions $x_label and
> $y_label.
>
> Anyone has tried to achieve this ?
>
> Cheers,
> Michaël
>
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20170504/dd350992/attachment.html>


More information about the QGIS-Developer mailing list