[QGIS-Developer] Advice? Sneaky trick for call out labels

Régis Haubourg regis.haubourg at gmail.com
Wed Apr 10 23:19:14 PDT 2019


Hi Tim,
You can have a look at easycustomlabeling plugin code. It's sets those
expressions for label alignement.

FYI I should be working on a new version of it taking profit of the
geometry generators power soon , and we might be able to revive the QEP47
to revive the idea of porting this natively to core.
Best regards
Regis

Le jeu. 11 avr. 2019 à 00:54, Tim Sutton <tim at kartoza.com> a écrit :

> To clarify a little, I am trying to avoid the label text crossing the
> call-out line.
>
> Regards
>
> Tim
>
> On 10 Apr 2019, at 23:02, Tim Sutton <tim at kartoza.com> wrote:
>
> Hi Friends
>
> So I am using logic like this* to make call out labels using a geometry
> generator:
>
> make_line(
>   closest_point($geometry,
>   make_point( "auxiliary_storage_labeling_positionx" ,
> "auxiliary_storage_labeling_positiony" )),
>   make_point( "auxiliary_storage_labeling_positionx" ,
> "auxiliary_storage_labeling_positiony" )
> )
>
> The line runs from the closest point along the edge of the polygon to the
> bottom left corner of the label box. With this configuration it works well
> when my ‘lollipop’ callout label is north-east of the polygon being
> labelled:
>
> <Screenshot 2019-04-10 at 22.54.29.jpg>
>
> But doesn’t work when the label is e.g. south west of the polygon:
>
> <Screenshot 2019-04-10 at 22.54.54.jpg>
>
> Now I am wondering if we have any options for getting the geometry of the
> label box so I can do the reverse and get the closest point along the edge
> of the label box to the polygon being labelled. So my question:
>
> Is there any sneaky trick for getting the geometry of the label box for a
> feature in an expression? And no, using an opaque background for my label
> to mask away the call out line doesn’t really hack it. I know the label box
> isn’t being calculated at the time the polygon is being rendered so the
> answer is probably ’no’ but maybe someone else has a clever idea to make
> may lollipops work when labels are south (or east or west for that matter)
> of the feature being labelled?
>
> Thanks!
>
> Regards
>
> Tim
>
>
>
>>
>
> <KartozaNewLogoThumbnail.jpg>
>
>
>
>
>
>
> *Tim Sutton*
>
> *Co-founder:* Kartoza
> *Ex Project chair:* QGIS.org <http://qgis.org/>
>
> Visit http://kartoza.com to find out about open source:
>
> Desktop GIS programming services
> Geospatial web development
> GIS Training
> Consulting Services
>
> *Skype*: timlinux
> *IRC:* timlinux on #qgis at freenode.net
>
> I'd love to connect. Here's my calendar link
> <https://calendly.com/timlinux> to make finding time easy.
>
>
>>
>
>
>
>
>
>
>
> *Tim Sutton*
>
> *Co-founder:* Kartoza
> *Ex Project chair:* QGIS.org
>
> Visit http://kartoza.com to find out about open source:
>
> Desktop GIS programming services
> Geospatial web development
> GIS Training
> Consulting Services
>
> *Skype*: timlinux
> *IRC:* timlinux on #qgis at freenode.net
>
> I'd love to connect. Here's my calendar link
> <https://calendly.com/timlinux> to make finding time easy.
>
> _______________________________________________
> 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/20190411/73b2cb58/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: KartozaNewLogoThumbnail.jpg
Type: image/jpeg
Size: 6122 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20190411/73b2cb58/attachment-0001.jpg>


More information about the QGIS-Developer mailing list