Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QEP 62: Curved labels improvements #62

Open
mhugo opened this issue Jun 2, 2016 · 10 comments
Open

QEP 62: Curved labels improvements #62

mhugo opened this issue Jun 2, 2016 · 10 comments

Comments

@mhugo
Copy link

mhugo commented Jun 2, 2016

QGIS Enhancement 62 (was 41): Curved labels improvements

Date 2016/06/01

Author Hugo Mercier (@mhugo)

Contact hugo dot mercier at oslandia dot com

maintainer @mhugo

Version QGIS 3.0

Summary

This QEP describes some improvements to the labeling engine for a better handling of curved labels.
A new option allowing to manually place these curved labels is proposed as well as a support for multiline curved labels.

Label anchor point

The labeling engine of QGIS allows to ask for labels to be placed along a line, either parallel or curved.
When the manual placement is enabled, an absolute X/Y coordinate is given by the user.

We propose to add an option so that the user can "orient" the placement of such curved or parallel labels.
The idea is to allow the user to set an "anchor point" that will be used by the labeling engine as a starting point of the label along the line.

The two fields used for the data-defined X/Y position will have a special meaning for curved / parallel labels. This coordinate will be projected onto the line to set the "anchor point". The PAL labeling engine will be modified to handle this.

It will be possible for the user to manipulate this anchor point for curved / parallel labels. The "move label" tool used for manual placement will display an anchor point constrained to be on the support curve/line.

anchor_points
Examples of curved labels with anchor points materialized

Multi-line support for curved labels

It is sometimes desirable to have multiple line labels for curved labels. But this feature is not supported yet by the labeling engine.

Following the discussion started here http://hub.qgis.org/issues/4442, we propose to handle multiline curved labels.

One option will be added to choose which algorithm is used to extend the linear support for labels that will be displayed below or above:

  • either these additional curves are computed by shifting the main curve (using an averaged normal vector). In this case curvatures of additional curves
    stay identical to the main curve, but the distance between two lines is not constant and may result in labels too close from one line to another and leads to labels not shown.
  • either they are computed by offsetting the main curve (using QgsGeometry::offsetCurve). In this case the distance between two curves are always the same.
    But it may results in curves with high curvatures that will also be ignored by the labeling engine. An option to specify the type of joins will also be available.

The labeling engine will then be modified to allow multiline candidates. In particular, the PAL code around the function createCurvedCandidatesAlongLine() will be modified to handle multiline labels.
label_options
The multiline labeling options will be reused to compute the shift or offset distance needed below and above the main line.
Placement candidates will be chosen in order to respect the alignment option.

Example(s)

Difference between lines computed by offseting and shifting the main support
multiline_curved

Issue Tracking ID(s)

http://hub.qgis.org/issues/4442

@mhugo mhugo added the Draft label Jun 2, 2016
@mhugo
Copy link
Author

mhugo commented Jun 6, 2016

@dakcarto Any comments on this QEP ?

@mhugo
Copy link
Author

mhugo commented Jun 28, 2016

Small updates to the text and illustrations.

@nyalldawson
Copy link
Contributor

@mhugo Sorry - I really thought I'd replied to this weeks ago! Anyway, +1 to both proposals.

One follow up question (non-blocking):

  • should the anchor point for curved labels respect the text alignment? ie can i put a anchor point for the end or middle of the text?

@mhugo
Copy link
Author

mhugo commented Jul 4, 2016

@nyalldawson no problem and thanks for your feedback ! :)
Indeed, it makes sense to respect the text alignment for anchor points. The computation of candidate glyph boxes would have to be done in different directions: from the anchor point to the right, or from the anchor to the left or from the anchor to both left and right.

@andreasneumann
Copy link
Member

@mhugo - about the label anchor point. I wonder if this could event be taken one step further - that the labeling algorithm could analyze the line geometry and find out long-enough sections in the line string with minimal curvature - so that the user doesn't have to manually propose the anchor points, but the algorithm would do that. The user could still overwrite the positions if he wants to take full control on the anchor points.

@mhugo
Copy link
Author

mhugo commented Jul 18, 2016

@andreasneumann That may be an nice option to have, indeed. I'll add it to the text, thanks

@NathanW2 NathanW2 modified the milestone: 3.0 Oct 26, 2016
@NathanW2 NathanW2 changed the title QEP 41: Curved labels improvements QEP 62: Curved labels improvements Jan 29, 2017
@haubourg
Copy link
Member

a related improvement to curved labels and any line labeling option would be to allow to label lines from start or endpoint. See https://issues.qgis.org/issues/20847. It seems definitly doable according to @nyalldawson 's insights.

@wtc1909
Copy link

wtc1909 commented Apr 15, 2021

Can't seem to move a curved line label without it becoming aligned as a horizontal line. Of course I can then rotate it but how due I get it formatted as a curved label in the new position? What am I missing?

@gioman
Copy link

gioman commented Apr 15, 2021

What am I missing?

@wtc1909 qgis/QGIS#33374

@dinizime
Copy link

Label anchoring helps the label position however in 3.18 implementation it considers the visible portion of the line, and not the entire line.
It would be nice to have an option to choose between the entire line or the visible line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants