I self-host graphhopper for a use-case that typically involves shorter routes where users (runners, walkers, and bikers) want to see all of the bumps along the way and know how much they’ve climbed/descended. Currently, I sample the 2D route and find the elevation at each point along the route to get elevation profiles. I’m interested in adding elevation into graphhopper data to save on latency, bandwidth, leverage bridge/tunnel interpolation, and get more accurate total ascent/descent over long routes. I’ve noticed a few issues though that make the graphhopper elevation profiles not quite usable for this purpose:
- Elevation data can be “blocky” when going up/down climbs that I know are steady because the nearest elevation data is used at each point without interpolating along the slope (for example this gradual climb/descent looks like this in graphhopper)
- elevation data is only included at points that are still present after 2D polyline simplification which elevation data can be lost on long straight roads (for example this long straight road with elevation changes vs. this in graphhopper)
To fix these I was thinking of submitting these PRs that I’ve prototyped and appear to solve the problems but I want to get some feedback on the overall plan first:
- Implement bilinear interpolation in HeightTile.java to approximate elevations better between elevation data samples
- Post-process all way geometries to insert “sampled” points between any adjacent points that are further apart than a configurable threshold. So if you set the sample distance to 30m and 2 consecutive points are 25m apart it does nothing, but if they are 60m apart, one point would be inserted halfway between them.
- Make the Douglas Peucker polyline simplification implementation elevation-aware so that it still throws out points along a long straight road in the desert, but it keeps the important points defining the elevation profile for a long straight road over a mountain.
Let me know if you think these proposed changes make sense, what you think should be enabled by default vs. opt-in config, or if you’d rather move this discussion into a github issue.