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

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


HI Tim,
the old plugin is crappy as it was made before the auxiliary data storage
and the geometry generator awesome features.
The expression used are exactly similar to Nyall's advice. The next plugin
will just be a helper to set all those expressions and geometry generator
style for users. I still miss a native implementation for callouts, but
that might become a reality in the next months. Finger crossed.
Régis

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

> Hi Alexis, Régis and Nyall
>
> I went with Nyall’s approach for now since I was 90% there and he gave me
> the last nudge I needed :-) I used data defined alignments:
>
>
>
> Here are the expressions I used for horizontal:
>
>
> if (
>   X(closest_point($geometry,
>   make_point( "auxiliary_storage_labeling_positionx" ,
> "auxiliary_storage_labeling_positiony" ))) >
>   X(make_point( "auxiliary_storage_labeling_positionx" ,
> "auxiliary_storage_labeling_positiony" )),
>   'Right', 'Left’)
>
> Which gives (animated gif, open in browser if needed):
>
>
>
> And Vertical
>
> if (
>   Y(closest_point($geometry,
>   make_point( "auxiliary_storage_labeling_positionx" ,
> "auxiliary_storage_labeling_positiony" ))) <
>   Y(make_point( "auxiliary_storage_labeling_positionx" ,
> "auxiliary_storage_labeling_positiony" )),
>   ’Top’, ‘Bottom’)
>
> Which gives (animated gif, open in browser if needed):
>
>
>
> @Régis I will give your plugin a try to see what it does too, thanks!
>
> QGIS Rocks!
>
> Regards
>
> Tim
>
> On 11 Apr 2019, at 07:19, Régis Haubourg <regis.haubourg at gmail.com> wrote:
>
> 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
>
> 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 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 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
> <KartozaNewLogoThumbnail.jpg>
>
>
>>
>
>
>
>
>
>
>
> *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.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20190411/d0297845/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: alignment.jpg
Type: image/jpeg
Size: 14512 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20190411/d0297845/attachment-0002.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: label.gif
Type: image/gif
Size: 6091 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20190411/d0297845/attachment-0002.gif>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: label2.gif
Type: image/gif
Size: 8916 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20190411/d0297845/attachment-0003.gif>
-------------- 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/d0297845/attachment-0003.jpg>


More information about the QGIS-Developer mailing list