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

[feature] Add "Linear Referencing" symbol layer type #58484

Merged
merged 5 commits into from
Sep 4, 2024

Conversation

nyalldawson
Copy link
Collaborator

@nyalldawson nyalldawson commented Aug 26, 2024

This new symbol layer type allows placing text labels at regular intervals along a line (or at positions corresponding to existing vertices). Positions can be calculated using Cartesian distances, or interpolated from z/m values.

Functionality includes:

  • Labels can be placed using fixed cartesian 2d distances, at regular linearly interpolated spacing calculated using the Z or M values in geometries, or at existing vertices
  • Labels can show either the running total distance, or the linearly interpolated Z/M value
  • Uses text renderer to draw labels, so the full range of functionality is available for the labels (including buffers, shadows, etc)
  • Uses the QGIS numeric format classes to format numbers as strings, so users have full range of customisation options for eg decimal places
  • An optional "skip multiples of" setting. If set, then labels which are a multiple of this value will be skipped over. This allows construction of complex referencing labels, eg where a symbol has two linear referencing symbol layers, one set to label every 100m in a small font, skipping multiples of 1000, and a second set to label every 1000m in a big bold font
  • Labels are rendered using an angle calculated by averaging the linestring, so sharp tiny jaggies don't result in unslightly label rotation
  • Optionally, markers can be placed at referenced points in the line string, using a full QGIS marker symbol (this allows eg showing a cross-hatch at the labeled point, for a "ruler" style line)
  • Data defined control over the placement intervals, skip multiples setting, marker visibility and average angle calculation length

Notes:

  • When using the distance-based placement or labels, the distances are calculated using 2D only, Cartesian calculations based on the original layer CRS. This could potentially be extended in future to expose options for 3D Cartesian distances, or ellipsoidal distance calculations.

Sponsored by the Swiss QGIS User Group

image

@nyalldawson nyalldawson added Requires Tests! Waiting on the submitter to add unit tests before eligible for merging Feature 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 Aug 26, 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.40.0 milestone Aug 26, 2024
Copy link

github-actions bot commented Aug 26, 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 f7930bd)

@qgis qgis deleted a comment from github-actions bot Aug 27, 2024
@nyalldawson nyalldawson removed the Requires Tests! Waiting on the submitter to add unit tests before eligible for merging label Aug 27, 2024
@nyalldawson nyalldawson force-pushed the linear_ref_all branch 2 times, most recently from 6341775 to 972b7cf Compare September 3, 2024 05:57
Comment on lines +123 to +125
res->mMarkerSymbol.reset( mMarkerSymbol ? mMarkerSymbol->clone() : nullptr );
if ( mNumericFormat )
res->mNumericFormat.reset( mNumericFormat->clone() );
Copy link
Contributor

Choose a reason for hiding this comment

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

Purely cosmetic: why not using the same style for mNumericFormat here? I.e.

Suggested change
res->mMarkerSymbol.reset( mMarkerSymbol ? mMarkerSymbol->clone() : nullptr );
if ( mNumericFormat )
res->mNumericFormat.reset( mNumericFormat->clone() );
res->mMarkerSymbol.reset( mMarkerSymbol ? mMarkerSymbol->clone() : nullptr );
res->mNumericFormat.reset( mNumericFormat ? mNumericFormat->clone() : nullptr );

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Cos the marker symbol is optional, whereas we expected that the numeric format should always be set. I'm playing things extra careful with the if ( mNumericFormat ) check, but if somehow that happens then at least we won't overwrite the default format created for the cloned copy...

This new symbol layer type allows placing text labels at regular
intervals along a line (or at positions corresponding to
existing vertices). Positions can be calculated using
Cartesian distances, or interpolated from z/m values.

Functionality includes:

- Labels can be placed using fixed cartesian 2d distances,
at regular linearly interpolated spacing calculated using
the Z or M values in geometries, or at existing vertices
- Labels can show either the running total distance, or
the linearly interpolated Z/M value
- Uses text rendered to draw labels, so the full range
of functionality is available for the labels (including
buffers, shadows, etc)
- Uses the QGIS numeric format classes to format numbers
as strings, so users have full range of customisation
options for eg decimal places
- An optional "skip multiples of" setting. If set, then
labels which are a multiple of this value will be skipped
over. This allows construction of complex referencing labels,
eg where a symbol has two linear referencing symbol layers,
one set to label every 100m in a small font, skipping multiples
of 1000, and a second set to label every 1000m in a big
bold font
- Labels are rendered using an angle calculated by averaging
the linestring, so sharp tiny jaggies don't result in
unslightly label rotation
- Optionally, markers can be placed at referenced points
in the line string, using a full QGIS marker symbol (this allows
eg showing a cross-hatch at the labeled point, for a "ruler"
style line)
- Data defined control over the placement intervals, skip
multiples setting, marker visibility and average angle
calculation length

Notes:

- When using the distance-based placement or labels, the
distances are calculated using 2D only, Cartesian calculations
based on the original layer CRS. This could potentially be
extended in future to expose options for 3D Cartesian distances,
or ellipsoidal distance calculations.

Sponsored by the Swiss QGIS User Group
@nyalldawson
Copy link
Collaborator Author

Thanks @nirvn, all addressed!

@nyalldawson nyalldawson merged commit 519b821 into qgis:master Sep 4, 2024
30 checks passed
@nyalldawson nyalldawson deleted the linear_ref_all branch September 4, 2024 09:06
@qgis-bot
Copy link
Collaborator

qgis-bot commented Sep 4, 2024

@nyalldawson
A documentation ticket has been opened at qgis/QGIS-Documentation#9231
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!

@zacharlie zacharlie added ChangelogHarvested This PR description has been harvested in the Changelog already. and removed Changelog Items that are queued to appear in the visual changelog - remove after harvesting labels Sep 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ChangelogHarvested This PR description has been harvested in the Changelog already. Feature 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.

4 participants