Repository navigation
Improve resolution of elevation profiles with 3D Douglas Peucker and long edge sampling - #1953
Conversation
…near'" This reverts commit 25c3d9b.
Sounds good to me, I set those default values in the comments in
I don't think it's an issue sampling the actual DEM file since this based on where the samples are located, there should be enough resolution to separate the river from the hill around that curve It's probably an irregularity with the DEM data provider. According to https://github.com/tilezen/joerd/blob/master/docs/data-sources.md, skadi uses EU-DEM for most of Europe which is "a hybrid product based on SRTM and ASTER GDEM data fused by a weighted averaging approach." So it could be artifacts from either in the SRTM/ASTER -> EU-DEM conversion or EU-DEM to skadi conversion. |
|
Thanks for the review @boldtrn! @karussell any more changes you want me to make here? |
|
Congrats on the 1.0 release! Think this might be safe to merge soon @karussell ? |
|
@otbutz (I'm unsure if my reply above was after your edits or before)
I don't think so. Basically what we do for bridges and tunnels is to get rid of elevation.
Yes, but at least the bridge/tunnel part is a different purpose. |
Yes, existing applications should not be affected whether they use bilinear interpolation or not since the 2 new config parameters default to Double.MAX_VALUE which retains existing behavior. |
|
Ok, thanks for confirming. Now I also better understand your images in #1953 (comment), i.e. red is the only area where the incline and decline increase ("got worse"). So this PR with the proposed settings in config-example.yml is always an improvement and should decrease incline&decline? (over CGIAR and interpolation only) |
| setElevationProvider(eleProvider). | ||
| setWorkerThreads(dataReaderWorkerThreads). | ||
| setWayPointMaxDistance(dataReaderWayPointMaxDistance). | ||
| setWayPointElevationMaxDistance(elevationWayPointMaxDistance). |
There was a problem hiding this comment.
@easbar probably a matter of taste but ... there are properties that are used while import and for the routing and they could be different which would motivate two variables, but likely not here. Should we still keep the two variables?
There was a problem hiding this comment.
We could also make elevation way point max distance controllable through a request parameter for routing?
There was a problem hiding this comment.
Thanks a lot for this very nice PR @msbarry!
As far as I can tell the elevationWayPointMaxDistance is used to control how many extra pillar nodes get created during import (to preserve elevation changes within the geometries) and it is also used during path simplification when running routing requests (to not throw away way points reflecting elevation changes). These two usages are different in that the first only can have an effect during import (after the first import it becomes meaningless unless we rebuild the graph) while the other could (at least in theory) be changed for every single request. Is that correct? For this reason I think it would be cleaner to use two parameters, e.g. one would go into the (not yet existing) ImporterConfig and the other would go to RouterConfig and the latter could also be changed via the routing hints in Router#createPathMerger. I just wonder if this is overkill and I do not think its urgent to separate this into two parameters already. In any case the parameter used for the import is a good default value for the one used during routing?
Should we still keep the two variables?
Which two variables do you mean? I thought so far there is only one (only one that has to do with import and routing).
We could also make elevation way point max distance controllable through a request parameter for routing?
Yes, exactly, in Router#createPathMerger.
There was a problem hiding this comment.
Thanks @easbar, longEdgeSamplingDistance controls how many extra pillar nodes are added and elevationWayPointMaxDistance prevents them from getting removed during simplification (on import, and during routing). I added a new elevation_way_point_max_distance request parameter in 9edbfbf to let you change elevationWayPointMaxDistance on each request or omit to default to what was used during import. I agree it's probably overkill to split out separate config parameters for data reader import and router default. Let me know if that change looks sufficient.
Those charts show increase/decrease relative to CGIAR without interpolation. 10m/60m plus bilinear interpolation proposed in config-example.yml should report an "improvement" with less total elevation gain/loss than people are used to with CGIAR and no interpolation today. |
|
Thanks! |

Improve the resolution of elevation profiles by:
These options have the potential to increase geometry size, so I added 2 configuration options to control them:
graph.elevation.long_edge_sampling_distancewhich defines the distance in meters that it will sample points along long edges, for example you might set this to somewhere around 30m if your elevation provider has 30m resolution. It defaults to 0 which disables long edge sampling.graph.elevation.way_point_max_distancewhich defines the elevation tolerance during polyline simplification, for example with a 1m lat/lon and elevation tolerance removes points that result in a <1m shift of the 3D polyline. It defaults to Double.MAX_VALUE which disables elevation-influenced simplification.Edge Geometry Size Increase
I ran this code on
north-america_us_pennsylvania.pbfwith CGIAR and bilinear interpolation with different values of those parameters and saw these edge geometry size increases over what's on master now:elevation max distance ⬇️
I ran the same test with mapzen/skadi provider from #1929. Results were similar, but the increase was slightly larger (26% instead of 19% for 15m/1m) probably because of the higher resolution of the underlying data.
Import time performance
I observed the "pass2" time during import. There was no change for different values of the elevation factor, but shorter long edge sampling distances did increase that time by 25% for 15m, 9% for 30m, 8% for 45m, and <2% for longer distances. Last time I imported the world pass2 took 110 minutes, so even a 25% increase is only about a 28 minute increase which seems negligible to me.
Examples
This 2km straight segment loses all elevation details on master

but with 30m edge sampling and 1m elevation resolution we get that elevation detail back:

Let me know if there are other examples or different values of the 2 parameters you want to see.
See further discussion here