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

Elevation profile plot #47990

Merged
merged 52 commits into from
Apr 7, 2022
Merged

Elevation profile plot #47990

merged 52 commits into from
Apr 7, 2022

Conversation

nyalldawson
Copy link
Collaborator

@nyalldawson nyalldawson commented Mar 28, 2022

This PR implements a native elevation profile tool.

Currently supports:

  • Vector, raster and mesh layers, based on the corresponding layer's elevation settings. (E.g. vector layer profiles will respect terrain clamping settings and extrusion heights). (Point cloud layers will be implemented following this PR)
  • Drawing profile lines interactively using a map tool which supports snapping, tracing, stream digitizing and curves
  • Interactive navigation of the plot canvas, using the standard QGIS pan/zoom shortcuts. E.g. middle mouse button = pan, hold space = pan, ctrl + space = zoom, ctrl + mouse wheel = fine zoom
  • Plots can be exported to PDF (as high quality vector objects, ready for any post-processing in Inkscape etc) or image formats

Some demonstrations:

Setting the profile curve line using a map tool:

Peek.2022-03-31.16-27.mp4

The profile chart style for layers can be set in their corresponding layer properties - elevation tab:

image

(Fun fact -- because these are rendered using standard QGIS line symbols, you can go really overboard with your profile tool appearance, by using geometry generators, paint effects, etc...!

image

)

@nyalldawson nyalldawson added the API API improvement only, no visible user interface changes label Mar 28, 2022
@github-actions github-actions bot added this to the 3.26.0 milestone Mar 28, 2022
@3nids
Copy link
Member

3nids commented Mar 30, 2022

It looks like you are re-creating all the canvas/tools/mouseevent logic here.

Wouldn't it have been possible to re-use the existing classes but stripping down the CRS notion or splitting them apart to have base common classes?

@nyalldawson
Copy link
Collaborator Author

It looks like you are re-creating all the canvas/tools/mouseevent logic here.
Wouldn't it have been possible to re-use the existing classes but stripping down the CRS notion or splitting them apart to have base common classes?

@3nids and I discussed this offline, and the conclusion was that trying to keep a common base class between map canvas and the profile plot would result in more complex code/complex API in order to handle all the requirements of both canvases.

@nyalldawson
Copy link
Collaborator Author

Showcase time!

Setting the profile curve line using a map tool:

(Thanks to recent work by @3nids, it was dead-simple to allow the profile curve to take advantage of ALL the digitizing options, including snapping, curve digitizing, stream digitizing, cad dock, tracing, ....!)

Peek.2022-03-31.16-27.mp4

The line style for raster and mesh layers can be set in their corresponding layer properties - elevation tab:

image

(Fun fact -- because these are rendered using standard QGIS line symbols, you can go really overboard with your profile tool appearance, by using geometry generators, paint effects, etc...!

image

)

@nyalldawson nyalldawson changed the title Elevation profile plot API (WIP) Elevation profile plot Mar 31, 2022
@nyalldawson nyalldawson added 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 and removed API API improvement only, no visible user interface changes labels Mar 31, 2022
@github-actions
Copy link

@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!

@nyalldawson
Copy link
Collaborator Author

I personally think this PR is ready for merging now (at least as a first step!). Additional functionality can be added in follow up PRs.

Copy link
Member

@3nids 3nids left a comment

Choose a reason for hiding this comment

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

I had a very very quick look, no objection!

src/gui/plot/qgsplotcanvas.h Show resolved Hide resolved
@nicogodet
Copy link
Member

In use, I notice a flickering of secondary tick at a certain zoom
export7

Happens also on Y axis

@DelazJ
Copy link
Contributor

DelazJ commented Apr 1, 2022

I personally think this PR is ready for merging now (at least as a first step!).

@nyalldawson I see this PR is labeled for changelog and docs so can you update the first message, please? Thanks.

@nyalldawson
Copy link
Collaborator Author

@nicogodet

In use, I notice a flickering of secondary tick at a certain zoom

Thanks, that's fixed now

@nyalldawson
Copy link
Collaborator Author

@DelazJ

I see this PR is labeled for changelog and docs so can you update the first message, please? Thanks.

Done

@nyalldawson
Copy link
Collaborator Author

Unrelated test failure

@nicogodet
Copy link
Member

I believe these next comments are features but I just wanted to give a little feedback of the use of this new AWESOME feature ! 😃

  • When plotting a long profile (I'm talking about kilometers) over a DEM, it can take few tens of seconds to plot it. It's full resolution, which is nice, but most of the times, we don't need the full resolution. ProfileTool plugin has a nice feature to disable the full resolution and instead, the DEM is sampled over the profile curve (max 1000 points per segment). A similar feature would be nice for speeding up the plot.

  • When using vector layer and in particular, point vector layer, ProfileTool layer allow the use of a search buffer around the profile curve with the visualisation of the buffer and projected points. This is more convenient than snapping the profile curve on each points.

  • Could be useful to allow the use of an attribute for vector layer instead of Z value only.

  • A legend on the plot (with possibility to enable/disable layer, direct access to symbology).

  • A mouse tracker when mouse over the plot (Distance and Z values) and visualisation of the position of the mouse on the profile curve.

  • An "Add selected layer to plot" button ? (instead of opening layer properties)

All these comments do not change the excellent work done.

Copy link
Member

@wonder-sk wonder-sk left a comment

Choose a reason for hiding this comment

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

👏 👏 👏 Really great work!

src/core/elevation/qgsprofilerenderer.cpp Outdated Show resolved Hide resolved
src/core/plot/qgsplot.cpp Outdated Show resolved Hide resolved
src/gui/plot/qgsplotpantool.h Outdated Show resolved Hide resolved
src/gui/plot/qgsplotcanvas.cpp Show resolved Hide resolved
@uclaros
Copy link
Contributor

uclaros commented Apr 6, 2022

Fantastic work! A few thoughts:

  • It feels weird that zooming with the zoom tool also changes the Y scale depending on the proportions of the dragged rectangle. I'd suggest to keep Y scale intact when drag-zooming and have a separate mechanism for modifying it.
  • The more you zoom, the rendering gets slower, while blocking the main thread. Update: This only happens with the fancy cat trail line style with svgs.
  • Which band is used in multiband rasters? It would be nice to have that selectable.
  • Zooming in way too much can get you trapped within Qgs2DPlot::calculateOptimisedIntervals()

@nyalldawson
Copy link
Collaborator Author

@nicogodet

I believe these next comments are features but I just wanted to give a little feedback of the use of this new AWESOME feature ! smiley

Thanks, it's definitely valued feedback!

When plotting a long profile (I'm talking about kilometers) over a DEM, it can take few tens of seconds to plot it. It's full resolution, which is nice, but most of the times, we don't need the full resolution. ProfileTool plugin has a nice feature to disable the full resolution and instead, the DEM is sampled over the profile curve (max 1000 points per segment). A similar feature would be nice for speeding up the plot.

I'm planning on addressing this in a followup (when the point cloud profiling is added). But yes, I agree that the performance on large raster layers in currently sub par.

When using vector layer and in particular, point vector layer, ProfileTool layer allow the use of a search buffer around the profile curve with the visualisation of the buffer and projected points. This is more convenient than snapping the profile curve on each points.

That's supported in the new API, but I haven't yet exposed a means for the user to set the search tolerance yet. That'll be added in a follow up.

Could be useful to allow the use of an attribute for vector layer instead of Z value only.

Agreed -- I'd like to see field/expression based support for both the height and the extrusion values. I'll see if I can fit this in, but no promises.

A legend on the plot (with possibility to enable/disable layer, direct access to symbology).

I've no plans for this at the moment, but I'll keep it in mind for future work.

A mouse tracker when mouse over the plot (Distance and Z values) and visualisation of the position of the mouse on the profile curve.

That's planned as a follow up PR.

An "Add selected layer to plot" button ? (instead of opening layer properties)

Right now the tool is using the assumption that the user wants to see all their project elevation enabled layers on the same plot. I also think we'll need to revise this in future, but I'm not sure what the best way to expose this will be. I'm leaning toward showing a filtered, checkable layer list on the left of the plot showing only elevation enabled layers, allowing users to check and rearrange the plot layers. But I'm also concerned about the loss of plot area this would cost. Ideas welcome 😄

@github-actions github-actions bot added the GUI/UX Related to QGIS application GUI or User Experience label Apr 7, 2022
@nyalldawson
Copy link
Collaborator Author

@uclaros

It feels weird that zooming with the zoom tool also changes the Y scale depending on the proportions of the dragged rectangle. I'd suggest to keep Y scale intact when drag-zooming and have a separate mechanism for modifying it.

I've added a dedicated tool for x-axis zoom only now, and put the action for it before the standard zoom.

The more you zoom, the rendering gets slower, while blocking the main thread. Update: This only happens with the fancy cat trail line style with svgs.

I'll try to find time to move the rendering to a background thread in a follow up

Which band is used in multiband rasters? It would be nice to have that selectable.

I've just added support for selecting the band in the layer- elevation properties tab.

Zooming in way too much can get you trapped within Qgs2DPlot::calculateOptimisedIntervals()

Thanks, fixed

@nicogodet
Copy link
Member

A legend on the plot (with possibility to enable/disable layer, direct access to symbology).

I've no plans for this at the moment, but I'll keep it in mind for future work.

An "Add selected layer to plot" button ? (instead of opening layer properties)

Right now the tool is using the assumption that the user wants to see all their project elevation enabled layers on the same plot. I also think we'll need to revise this in future, but I'm not sure what the best way to expose this will be. I'm leaning toward showing a filtered, checkable layer list on the left of the plot showing only elevation enabled layers, allowing users to check and rearrange the plot layers. But I'm also concerned about the loss of plot area this would cost. Ideas welcome 😄

I think these two could be the same.
What I was think for the legend is at least a reminder of which plot belongs to which layer.
Regarding the loss of space, as long as it is not as much as the plugin, I think we are fine 😄
image

  • Possibility to export plots as table (clip board, csv, ...) for external use like in Excel
  • Use an existing curve layer/feature in addition to the temporary maptool
  • As I try to maintain the current ProfileTool plugin, I noticed people use DXF export

@nyalldawson nyalldawson merged commit 19c2c3d into qgis:master Apr 7, 2022
@nyalldawson nyalldawson deleted the profile_tool_p3 branch April 7, 2022 09:22
@github-actions
Copy link

github-actions bot commented Apr 7, 2022

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

@nyalldawson
Copy link
Collaborator Author

@nicogodet

Could be useful to allow the use of an attribute for vector layer instead of Z value only.

Done in #48177

@nyalldawson
Copy link
Collaborator Author

@nicogodet

Use an existing curve layer/feature in addition to the temporary maptool

Done in #48179

@nyalldawson
Copy link
Collaborator Author

@nicogodet

A legend on the plot (with possibility to enable/disable layer, direct access to symbology).

Done in #48248

@Jean-Roc
Copy link
Member

Hi nyall, are you planning to present an option to set a "same scale axis" like in ProfileTool ? We funded this feature in the plugin because the different x/y scales for the same unit of measure often were a source of misreading for our users, the default scale behaviour being surprising for those coming from CAD tools (road profiles, building cross sections, river bed, etc.).

@nyalldawson
Copy link
Collaborator Author

@Jean-Roc

Hi nyall, are you planning to present an option to set a "same scale axis" like in ProfileTool ?

It's not in the scope of the current project, but would definitely be possible!

@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 May 28, 2022
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 GUI/UX Related to QGIS application GUI or User Experience 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.

8 participants