Skip to content

Move curvature EncodedValue out of MotorcycleTagParser - #2665

Merged
karussell merged 8 commits into
masterfrom
curvature_ev
Sep 29, 2022
Merged

karussell merged 8 commits into
masterfrom
curvature_ev

Conversation

@karussell

@karussell karussell commented Sep 29, 2022 •

Copy link
Copy Markdown
Member

I kept the meaning of the curvature value but instead of (beeline/edge_distance)² it is now only beeline/edge_distance as it did not make a big difference (sure, the small deviations from 1 will be "earlier snap to 0.95", but in practise this didn't matter in my simple tests and having a simpler formula was preferable).

If you want to use curvature to prefer curves then do not overdo it and something like this is sufficient:

{ "priority": [{
   "if": "curvature > 0.9",
   "multiply_by": "0.3"
}]}

Otherwise, without proper turn costs, you'll see things like:

grafik

I tried to calculate some kind of a max_curve value instead as the curvature was sometimes a bit too similar to 1 and used the maximum orientation change of the PointList like:

for (int i = 1; i < pointList.size(); i++) {
    double orientation = ANGLE_CALC.calcOrientation(pointList.getLat(i - 1), pointList.getLon(i - 1),
            pointList.getLat(i), pointList.getLon(i), false);
    if (i > 1) {
        orientation = ANGLE_CALC.alignOrientation(prevOrientation, orientation);
        maxCurve = Math.max(maxCurve, Math.abs(orientation - prevOrientation));
    }
    prevOrientation = orientation;
}
maxCurveEnc.setDecimal(false, edgeFlags, Math.max(maxCurveEnc.getMinStorableDecimal(), Math.min(maxCurveEnc.getMaxStorableDecimal(),
       Math.toDegrees(maxCurve))));

But at the end it did not properly show when a road was curvy (even sometimes not for serpentines). Probably because a curvy road in OSM is often mapped smooth leading to relative small orientation changes. Of course this could happen with the curvature too if multiple ways are created but often this is not the case and of course we would need another feature like "turning angle" to complement this. A good test route for this was here.

@karussell karussell added this to the 7.0 milestone Sep 29, 2022
@karussell
karussell temporarily deployed to benchmarks September 29, 2022 08:02 Inactive
@karussell
karussell temporarily deployed to benchmarks September 29, 2022 08:23 Inactive
@easbar

easbar commented Sep 29, 2022

Copy link
Copy Markdown
Member

Nice! I did not look at the exact modeling of the curvature EV, but the code changes LGTM.

@karussell
karussell merged commit e4f67c3 into master Sep 29, 2022
@karussell
karussell deleted the curvature_ev branch September 29, 2022 09:05

This branch was previously deployed

1 inactive deployment
benchmarks — 33cdaf13 Deployed Sep 29, 2022 by karussell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants