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

Tim Sutton tim at kartoza.com
Wed Apr 10 15:02:36 PDT 2019


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:



But doesn’t work when the label is e.g. south west of the polygon:



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



—









Tim Sutton

Co-founder: Kartoza
Ex Project chair: QGIS.org

Visit http://kartoza.com <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.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20190410/2644adc5/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screenshot 2019-04-10 at 22.54.29.jpg
Type: image/jpeg
Size: 25150 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20190410/2644adc5/attachment-0003.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screenshot 2019-04-10 at 22.54.54.jpg
Type: image/jpeg
Size: 21975 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20190410/2644adc5/attachment-0004.jpg>
-------------- 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/20190410/2644adc5/attachment-0005.jpg>


More information about the QGIS-Developer mailing list