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
Zero Distance Match Leg Causes Nan Duration #2229
Conversation
R"({"costing":"auto","format":"osrm","shape_match":"map_snap","shape":[ | ||
{"lat": 52.0981280, "lon": 5.1297250, "type": "break", "time":10}, | ||
{"lat": 52.0981280, "lon": 5.1297250, "type": "break", "time":169}], | ||
"trace_options": {"interpolation_distance": 0}})", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is important, we never saw much of this before because people generally dont want to skip interpolation. i would argue they still dont 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch!
double dist_from_begin = (trivial_group ? end_pct : 1) - begin_pct; | ||
double dist_to_end = end_pct - (trivial_group ? begin_pct : 0); | ||
double begin_edge_scale = dist_from_begin > 0 ? 1 / dist_from_begin : 0; | ||
double end_edge_scale = dist_to_end > 0 ? 1 / dist_to_end : 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
zero-out the multiplier if its a degenerate leg
docker build failed because ppa is randomly not reachable. its ephemeral. merging anyway |
* master: missed leg weight to 3 decimal places (#2227) Zero Distance Match Leg Causes Nan Duration (#2229) Fixed the sharp turn phrase (#2226) Cleanup in test Cleanup whitespace in directions.proto Cleanup unused argument etp in narrativebuilder Code review feedback: test vector references, style nit Update to front and back. j/k: move TrimBuild to other geometry utilities. Test coverage, export TrimShape into header namespace; check for empty shape. Strip const from primitive types. Fix pointer invalidation bug in TrimShape. prevent calling path_map_match when path_edges are empty. (#2219)
So... we allow degenerate routes, where the input is the same location twice and the output is a route with 0 length. The problem is, when we got smart about computing the duration we didnt figure for this. What happens is we get a divide by 0 which sends double to
inf
and then using that later on makes fornan
. This PR adds a test, which fails with the old code, then it adds code to make sure that the denominator is positive. If the denominator is negative we set everything to 0.