Bug report #6482

Label rotation with angles between 90 and 270 degrees

Added by Bernhard Ströbl about 12 years ago. Updated about 12 years ago.

Status:Closed
Priority:Normal
Assignee:Larry Shaffer
Category:Labelling
Affected QGIS version:master Regression?:No
Operating System:any Easy fix?:No
Pull Request or Patch supplied:No Resolution:fixed
Crashes QGIS or corrupts data:No Copied to github as #:15710

Description

Labels with a rotation angle defined are always displayed so they are readible and never upside down. Example: If the label is drawn "normal" (facing upward) when I enter an angle of 0 degrees, then I would assume it to be drawn facing downward when I enter 180 degrees. But they are drawn identically. IMHO if the user has the option to enter an angle the angle must be honoured under all circumstances by the software even if it can be assumed that readability suffers. If the user does not like the result it is up to him/her to change the angle.
Beyond systematic thoughts there exists at least one use case: labelling contour lines. Labels are written so the top of the numbers are facing uphill. Another use case is that the user wants to rotate the output in the composer but wants to make sure all labels face in a certain directtion.

contourlines-options.png (35.7 KB) Larry Shaffer, 2012-10-09 07:06 PM

contourlines-wrongdirection.png (77.1 KB) Larry Shaffer, 2012-10-09 07:06 PM

contourlines-fixed.png (76.5 KB) Larry Shaffer, 2012-10-09 07:06 PM


Related issues

Related to QGIS Application - Bug report #5593: upside down labels turned upside up with new labelling ma... Closed 2012-05-14

Associated revisions

Revision e125e98e
Added by Larry Shaffer about 12 years ago

[FEATURE] Fix #6482, options for showing upside-down labels

- Adv Labeling option to 'Show upside-down labels': never, when rotation defined, or always
- 'Never' (default) option is same as before, labels with 90 <= angle < 270 are turned so their text is always upright
- 'When rotation defined' option shows upside-down labels if their rotation is layer- or data-defined (dynamic labels are turned upright)
- 'Always' option shows upside-down labels at layer- or data-defined rotations and for dynamic labels

History

#1 Updated by Larry Shaffer about 12 years ago

  • Status changed from Open to Closed

#2 Updated by Larry Shaffer about 12 years ago

Hi Bernhard,

I have attempted to fix this issue (more of a feature request IMHO) with the noted master branch changeset.

Options for showing upside-down labels

  • Adv Labeling option to 'Show upside-down labels': never, when rotation defined, or always
  • 'Never' (default) option is same as before, labels with 90 <= angle < 270 are turned so their text is always upright
  • 'When rotation defined' option shows upside-down labels if their rotation is layer- or data-defined (dynamic labels are turned upright)
  • 'Always' option shows upside-down labels at layer- or data-defined rotations and for dynamic labels

Regarding your use of this to create uphill-relative text labels for contour lines, note that it is not a quick fix. In my testing, I used the 'always' option coupled with parallel placement (see contourlines-options.png) but found the label was drawn according to line direction. This is a problem with poorly generated contours. However, those lines can be manually fixed using Nathan's plugin:

Switch the direction of a polyline
http://plugins.qgis.org/plugins/lineswitch/

In the test (see contourlines-wrongdirection.png) I turned on 'Add direction symbol' to show the direction of each contour line, with the 'wrong' direction labels selected in orange. Once selected and in edit mode, just click Nathan's script and the lines will be reversed (see contourlines-fixed.png). There is currently no undo stack tracking for that plugin, so you can only undo by cancelling the editing mode (and not saving) for the layer.

BTW, none of this will work with curved labels, which would be much more difficult to do.

Please test this if you have the time.

#3 Updated by Bernhard Ströbl about 12 years ago

Hi Larry,

I just tested your patch and it works like charm! Thanks for that.

The former bug tracker had a category "does not work as expected" which IMHO would have been appropriate to describe the bug more decently.

Of course the labelling of contour lines depends on the digitizing direction of the line. I happen to have label points, though :)

I do not understand the difference between options 2 and 3. What are dynamic labels?

#4 Updated by Larry Shaffer about 12 years ago

Bernhard Ströbl wrote:

I do not understand the difference between options 2 and 3. What are dynamic labels?

By dynamic I am referring to labels produced by the PAL engine's solution where their position and rotation are derived from the engine's potential candidates and not overridden by the user.

Using the contour lines as an example:

When rotation defined option would do nothing because no rotation has been set by the user (either by layer- or data-defined means). You wrote 'if the user has the option to enter an angle the angle must be honoured under all circumstances' in your initial bug report: these 'dynamic' labels are the other circumstance where their rotation could be upside-down, but the user hasn't explicitly set a rotation value. Only labels for which the user can configure a rotation value are included when showing text upside down. Labels with PAL-derived rotation values are ignored (i.e. still turned upright).

'When rotation defined' option will be useful where you want control over showing upside-down labels for specific labels and let PAL do the rest using the always-upright default.

Always option works for the contour lines, because all labels, regardless of whether their rotation is layer-, data-, or PAL-derived (e.g. contour labels), have their text shown upside-down if their angle is >=90 and <270.

#5 Updated by Bernhard Ströbl about 12 years ago

ok, thanks Larry, I understand the difference now, but if I take my contour lines and place the labels parallel they are turned upside down, if I tick Curved they are not :-(

My 'if the user has the option to enter an angle the angle must be honoured under all circumstances' was kinda description for Does not work as expected

#6 Updated by Larry Shaffer about 12 years ago

Bernhard Ströbl wrote:

ok, thanks Larry, I understand the difference now, but if I take my contour lines and place the labels parallel they are turned upside down, if I tick Curved they are not :-(

Yes. I noted above it would not work with curved labels. I will look into this, but it will probably not be as straightforward as it was for the other label placements. (Example: what happens when some of the curved characters are upside-down and some aren't?) Several other labeling options already do not work with curved labels, due to its methodology.

#7 Updated by Bernhard Ströbl about 12 years ago

well I am not keen on it working with curved labels, I just noted it doesn't. For the sake of my ticket your fix has more options and thoughts in it than I was aiming at (I was only thinking that if the user sets an angle (either for the layer or via data) the labels must be rotated by that angle. This is option 2.)

#8 Updated by Larry Shaffer about 12 years ago

  • Resolution set to fixed
  • Status changed from In Progress to Closed

Bernhard,

Since the fix is working for you, I'm going to close the issue. Please reopen it if needed.

Also available in: Atom PDF