Repository navigation
Simplify edge geometry before the distance is calculated - #2222
Conversation
|
|
||
| ResponsePath res = rsp.getBest(); | ||
| assertEquals(1625.4, res.getDistance(), .1); | ||
| assertEquals(1614.3, res.getDistance(), .1); |
There was a problem hiding this comment.
This is the only test where my change lead to a distance deviation above 1m, is this ok?
There was a problem hiding this comment.
I had a look at this and the difference of about 11m is the result of multiple edges that have a slightly different distance due to the change in this PR. The biggest contribution is an edge with a 6.9m difference and the full geometry is shown here:
Due to the simplification it looks like this:
Because point 2 is removed we get a longer less steep segment instead of a short steep and a long flat one and this leads to the different distance with and without simplification. Note that the long edge sampling that would normally prevent the loss of these elevation details is not enabled in this test.
So yes this PR changes the distance of this edge by a significant amount, but no this is nothing to worry about, because all we do now is that we store the distance of this edge's final geometry instead of storing the distance of a geometry that we do not keep anyway.
|
To me the biggest question is whether the edge simplification should run before or after the long edge sampling. Or even before the elevation smoothing? @msbarry can you comment? Probably it should go before the long edge sampling otherwise we might not sample a long edge, because it only turns out to be a long edge during the simplification? |
|
Simplification boils down to loss of precision. There might be corner cases where we pick up wrong elevation data because we work with simplified paths. |
Edge simplification should run after long edge sampling, since long edge sampling inserts elevation detail on long straight edges that influences simplification (since simplification is now elevation-aware), see the example before/after elevation profile here #1953 (comment). It seems safe to calculate the edge distance before simplification since we use such a tight threshold is used to simplify before storing edge geometries, especially if the test diffs are so small. |
|
Thanks for your response!
Ok you mean first we should add all possible sample points and then simplify afterwards? That sounds reasonable, but actually I do not even expect much of a difference quality-wise(?). When we simplify first this just means some points might get removed, but then we actually add points again during the long edge sampling. Initially I was concerned that if we ran the sampling first we might miss adding some elevation details, because the long edge sampling would not run for all edges. But contrary to what I thought the long edge sampling always runs (and not just on long edges)? So yes let's run the sampling before the simplification (this is the current state of this PR anyway).
Do you mean we should or should not calculate the edge distance before the simplification? And by the way two more questions:
|
Yes, the long edge sampling is just meant to keep a minimum distance between elevation samples along all edges (it just has a shortcut to avoid touching short edges), then 3d-aware simplification throws out any edge samples that really aren't needed to retain elevation details in the profile. If we don't simplify after the long edge sampling, we'll keep too much extra data around.
It seems safe to calculate the edge distance before simplification like you have already in this PR.
Yes exactly, they need to run together. Long edge sampling adds in detail, then simplification throws out unnecessary detail.
Oops, I must have had it in there for debug logging. Looks like it's not used anymore, so safe to remove. Sorry about that! |
Removing points changes the path of the edge. In extreme cases the long edge sampling might pick up completely wrong elevation data because the inserted points are not part of the original edge. But i'm not sure if we really run into this kind of problems as we don't simplify that hard and our elevation data usually has low resolution. |
|
Ok
This whole PR is about calculating the edge distance after the simplification, but I guess this is just a typo :)
Yes sure. When we first sample the elevation details the edges will be protected from over-simplification. And yes the simplification threshold is very small anyway (1m) and it cannot really be larger so we keep details like sharp turns of footways or roundabouts etc. |
Sorry yes. That's what I meant!
"Long edge sampling" might be a bad name. We only add intermediate points along long edge segments, but never actually change the shape of a line. "Interpolate" might make more sense here? I think QGis calls it "points along geometry?" |
|
@karussell any objections? I think this is ready to merge. |
Hm 'sampling' works for me I guess. What confuses me more is the 'long edge' part of it: It sounds like we only do the sampling for 'long' edges. But really this parameter sets a minimum sampling interval. For example setting it to 30m means that whenever there is a segment longer than 30m we add additional sampling points every 30m along this segment. This way we make sure the elevation is sampled at least every 30m (unless the 3D simplification removes the sample point again because it is not needed). The total length of the edge does not even play a role. |



During import we calculate
edge.getDistance()before we simplify the edge geometry. Therefore the edge distance can be different to the distance we would calculate from the edge geometry:This doesn't seem right, so in this PR I moved the edge simplification in front of the distance calculation.