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 handling improvements #4033

Merged
merged 15 commits into from
Mar 30, 2022

Conversation

flaktack
Copy link
Contributor

@flaktack flaktack commented Mar 28, 2022

Summary

This is a set of related changes to improve elevation handling. It fixes several bugs, along with adding new features.

Bugs

  • The elevation propagation was non-deterministic. The logic was moved to a separate class (MissingElevationHandler) and refactored so that it is deterministic and testable. A new build parameters is added to limit the propagation distance (maxElevationPropagationMeters).
  • The elevation profile was not copied to split edges and partial edges. This was fixed by merging StreetEdge and StreetWithElevationEdge, along with moving the partial edge splitting to StreetEdge.
  • The elevation profile for all StreetEdges was compacted. For split edges and propagated elevations the profile doesn't have uniform distances, which is required for compaction.StreetElevationExtension can store both the compacted and uncompacted profile.

Features

  • TIFF files may contain a NO_DATA tag to mark areas without elevation data. This was ignored, resulting in areas with unrealistic elevation. A NoDataGridCoverage class is added, which treats NO_DATA areas the same as areas outside the grid's bounds.
  • All elevation related errors are added to the DataImportIssueStore.
  • Leg#legElevation is added, which contains the elevation profile for the whole Leg. If the elevation is missing in some segments, than NaN segments are added.
  • An elevation graph is added to the debug client
    image
  • An elevation debug layer is added to the debug client. This uses the newly-added Graph#minElevation and Graph#maxElevation to have a consistent coloring between tiles.
    image

Refactors

  • Elevation is added to the Portland test graph. A snapshot test and a graph serialization test is added.
  • StreetWithElevationEdge is merged into StreetEdge, with the elevation specific parts moved into StreetElevationExtension. This was needed to simplify edge splitting, which previously discarded the elevation details.

Issue

closes #3862

Unit tests

Unit tests are added for:

  • elevation compaction
  • elevation propagation
  • graph serialization with elevation

A snapshot test is added for planning trips with elevation data.

Code style

☑️

Documentation

A single new build-config.json parameter is added (maxElevationPropagationMeters), for which the documentation is updated.

flaktack added 13 commits March 26, 2022 07:39
StreetVertex used a lambda to pass String parameters to
LocalizedString(), which meant that toString() wasn't overridden.

By using I18NString parameters in LocalizedString the need for the
lambda is removed, while generalising the code.
This allows testing the elevation related functionality on an actual
graph.
WalkStep also contains the elevation, but having it explicitly on Leg
simplifies its usage.

An explicit NaN value is added to differentiate when there is no
elevation data.
Due to the elevation data it is possible to have Infinity / NaN
bicycleSafetyFactor or edge traversal weight. To avoid errors latter on,
check for invalid values when setting updated values.

ElevationProfileFailure items are added to the issue store.
NoDataGridCoverage is added which throws a
PointOutsideCoverageException() if the value at a given point is the
NO_DATA value for the loaded file.
This simplifies edge splitting since less cases need to be handled,
while also allowing for cleaner code.
When the from/to vertices are along the same edge a partial
TemporaryPartialStreetEdge was created without copying the properties
from the original StreetEdge.

This remedies the oversight by:
 * moving the responsibility from SameEdgeAdjuster to StreetEdge
 * and reusing StreetEdge#copyPropertiesToSplitEdge()
All elevation profiles were compacted, which caused the uncompacted
profile to have differing distances. By compacting only "computed"
elevations this is avoided.
The existing logic is modified so that is deterministic and tested.

The new logic interpolates the elevation for each vertex that is within
maxElevationPropagationDistance on the street network using the two
closest vertices with elevation.
@flaktack flaktack requested a review from a team as a code owner March 28, 2022 07:15
hannesj
hannesj previously approved these changes Mar 28, 2022
* The elevation profile as a comma-separated list of x,y values. x is the distance from the start of the leg, y is the elevation at this
* distance.
*/
public String legElevation;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we use some more efficient data structure for this?

Copy link
Member

Choose a reason for hiding this comment

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

Isn't that what the WalkStep also uses?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is, but for example the same encoded polylines could be used as for the legGeometry.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Encoded polyline can't be used due to the different ranges the numbers have, so the existing string seems like the best solution, and so can stay the same.

@slvlirnoff
Copy link
Member

Why '[changelog skip]' ? This seems relevant to include to me.

@flaktack
Copy link
Contributor Author

Why '[changelog skip]' ? This seems relevant to include to me.

I'm not sure which parts should be in the changelog, and which parts shouldn't. I can rename the PR to better reflect what should be in the changelog, or create separate PRs for the relevant parts.

@t2gran t2gran added this to the 2.2 milestone Mar 29, 2022
@t2gran t2gran added the Improvement A functional improvement label Mar 29, 2022
Copy link
Member

@leonardehrenfried leonardehrenfried left a comment

Choose a reason for hiding this comment

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

I really thorough refactoring and bugfix with great test coverage. Thanks!

@flaktack flaktack changed the title Elevation handling improvements [changelog skip] Elevation handling improvements Mar 30, 2022
@flaktack flaktack merged commit e36a2c7 into opentripplanner:dev-2.x Mar 30, 2022
t2gran pushed a commit that referenced this pull request Mar 30, 2022
@flaktack flaktack deleted the feature/elevations branch March 30, 2022 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Improvement A functional improvement Skip Changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Elevation handling improvements
5 participants