Skip to content
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

Merged
merged 3 commits into from Feb 10, 2020
Merged

Conversation

kevinkreiser
Copy link
Member

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 for nan. 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.

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}})",
Copy link
Member Author

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 😄

Copy link
Contributor

@yuzheyan yuzheyan left a 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;
Copy link
Member Author

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

@kevinkreiser
Copy link
Member Author

docker build failed because ppa is randomly not reachable. its ephemeral. merging anyway

@kevinkreiser kevinkreiser merged commit 4a87622 into master Feb 10, 2020
yuzheyan added a commit that referenced this pull request Feb 11, 2020
* 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)
@kevinkreiser kevinkreiser deleted the kk_math_hardening branch April 12, 2020 02:30
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.

None yet

3 participants