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

Add maximum distance setting for point labels #57415

Merged
merged 12 commits into from
May 23, 2024

Conversation

nyalldawson
Copy link
Collaborator

(Temporarily includes #57404)

For the "Around point" and "Cartographic" placement modes, this adds a new optional setting for the maximum distance of the labels from the feature. It's used together with the existing distance setting to define a range of distances at which labels may be placed from their corresponding point features.

This adds more flexibility to the placement for these layers, ultimately allowing for more labels to be placed in busy maps.

When the layer is set to the "around point" mode, then label candidates which are closer to the point will always be prefered
over those which are further away.

When the layer is set to the "cartographic" mode, then the default behavior is also to prioritize closer labels. A new combo box
allows users to control the priority, with an option for prefering position ordering. If this option is set, then candidates at the corresponding positions (eg top left) are preferred regardless of how far they are from the point, with the labelling falling
back to alternate positions only when no labels can be placed up to the maximum label distance.

Sponsored by Rubicon Concierge Real Estate Services

To demonstrate, here's how the candidates look for a standard point layer in cartographic mode:

image

If we bump the maximum distance to 4.5 mm, then here's how the candidates look:

image

These videos demonstrate how the prioritization setting affects things:

In the default "prefer closest" mode, the label will remain as close as possible to the point. The top right placement is initially prefered, but then we fall back to close labels on the top right, bottom right, bottom left, etc. More distant labels are only placed as a last resort:

Peek.2024-05-14.15-02.mp4

In "Prefer position ordering" mode, the label will prefer to stay in the top right placement, immediately falling back further candidates to the top right. It's only when no candidates can be placed in the top right within the maximum distance that it falls back to the top left placement.

Peek.2024-05-14.15-02.3.mp4

@nyalldawson nyalldawson added Requires Tests! Waiting on the submitter to add unit tests before eligible for merging Feature Labeling Related to QGIS map labeling Needs Documentation When merging a labeled PR, an issue will be created in the Doc repo. Changelog Items that are queued to appear in the visual changelog - remove after harvesting labels May 14, 2024
@qgis-bot
Copy link
Collaborator

@nyalldawson
This pull request has been tagged as requiring documentation.

A documentation ticket will be opened at https://github.com/qgis/QGIS-Documentation when this PR is merged.

Please update the description (not the comments) with helpful description and screenshot to help the work from documentors.
Also, any commit having [needs-doc] or [Needs Documentation] in will see its message pushed to the issue, so please be as verbose as you can.

Thank you!

@qgis-bot
Copy link
Collaborator

@nyalldawson

This pull request has been tagged for the changelog.

  • The description will be harvested so please provide a "nearly-ready" text for the final changelog
  • If possible, add a nice illustration of the feature. Only the first one in the description will be harvested (GIF accepted as well)
  • If you can, it's better to give credits to your sponsor, see below for different formats.

You can edit the description.

Format available for credits
  • Funded by NAME
  • Funded by URL
  • Funded by NAME URL
  • Sponsored by NAME
  • Sponsored by URL
  • Sponsored by NAME URL

Thank you!

@github-actions github-actions bot added this to the 3.38.0 milestone May 14, 2024
Copy link

github-actions bot commented May 14, 2024

🪟 Windows builds ready!

Windows builds of this PR are available for testing here. Debug symbols for this build are available here.

(Built from commit 4137a57)

@qgis qgis deleted a comment from github-actions bot May 15, 2024
@qgis qgis deleted a comment from github-actions bot May 15, 2024
@nyalldawson nyalldawson force-pushed the point_label_distance_range2 branch 2 times, most recently from 3456978 to e8422db Compare May 16, 2024 00:44
@nyalldawson nyalldawson added Freeze Exempt Feature Freeze exemption granted and removed Requires Tests! Waiting on the submitter to add unit tests before eligible for merging labels May 17, 2024
* always be respected.
*
* \see setMaximumDistance()
* \see distLabel()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Completely unrelated to your PR: TODO QGIS 4.0: distLabel() -> distanceToLabel() or something 😆

src/core/labeling/qgspallabeling.cpp Show resolved Hide resolved
src/core/pal/feature.cpp Show resolved Hide resolved
src/core/pal/feature.cpp Outdated Show resolved Hide resolved
For the "Around point" and "Cartographic" placement modes, this
adds a new optional setting for the maximum distance of the labels from
the feature. It's used together with the existing distance setting
to define a range of distances at which labels may be placed
from their corresponding point features.

This adds more flexibility to the placement for these layers,
ultimately allowing for more labels to be placed in busy maps.

When the layer is set to the "around point" mode, then label
candidates which are closer to the point will always be prefered
over those which are further away.

When the layer is set to the "cartographic" mode, then the default
behavior is also to prioritize closer labels. A new combo box
allows users to control the priority, with an option for
prefering position ordering. If this option is set, then candidates
at the corresponding positions (eg top left) are preferred regardless
of how far they are from the point, with the labelling falling
back to alternate positions only when no labels can be placed
up to the maximum label distance.

Sponsored by Rubicon Concierge Real Estate Services
Let's fix one thing at a time
@nyalldawson nyalldawson merged commit 44604fc into qgis:master May 23, 2024
29 of 30 checks passed
@nyalldawson nyalldawson deleted the point_label_distance_range2 branch May 23, 2024 07:20
@qgis-bot
Copy link
Collaborator

@nyalldawson
A documentation ticket has been opened at qgis/QGIS-Documentation#9120
It is your responsibility to visit this ticket and add as much detail as possible for the documentation team to correctly document this change.
Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog Items that are queued to appear in the visual changelog - remove after harvesting Feature Freeze Exempt Feature Freeze exemption granted Labeling Related to QGIS map labeling Needs Documentation When merging a labeled PR, an issue will be created in the Doc repo.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants