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

fix garbage coordinates when map matched route has uturn #2517

Merged
merged 6 commits into from
Aug 7, 2020

Conversation

kevinkreiser
Copy link
Member

@kevinkreiser kevinkreiser commented Aug 6, 2020

fixes #2442

bool uturn_off_of =
next_segment && segment->edgeid != next_segment->edgeid && segment->target < 1.f;
if (uturn_onto || uturn_off_of) {
edge_trimming[i] = {{uturn_onto, match_results[segment->first_match_idx].lnglat,
Copy link
Member Author

@kevinkreiser kevinkreiser Aug 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as @dnesbitt61 mentioned the match index can be -1 but only in the case that we dont need to trim. sadly the trimming datastructure is a pair and so you have to specify both first and second. in this case, one of them doesnt need to be set. to get around this i assign one at a time and rely on the default initializer to intialize the pair with false and an invalid lat lon etc

yuzheyan
yuzheyan previously approved these changes Aug 6, 2020
danpat
danpat previously approved these changes Aug 7, 2020
Copy link
Member

@danpat danpat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should follow up on this with a test - if we can dream up how to make one. It's proved troublesome.

@kevinkreiser
Copy link
Member Author

so the request that exposes this ends up showing this at the important part of the code:

(gdb) p *prev_segment
$9 = {edgeid = {value = 397962009178}, source = 0, target = 1, first_match_idx = -1, 
  last_match_idx = -1, discontinuity = false}
(gdb) p *segment
$10 = {edgeid = {value = 985399450202}, source = 0, target = 0.974345565, 
  first_match_idx = -1, last_match_idx = 25, discontinuity = false}
(gdb) p *next_segment
$11 = {edgeid = {value = 1357316774490}, source = 0.0256544352, target = 1, 
  first_match_idx = 25, last_match_idx = -1, discontinuity = false}

basically it turns onto an edge and then just before reaching the end of the edge it turns around and leaves the edge.

so i made a test case for this:

TEST(Standalone, UturnTrimmingAsan) {
  const std::string ascii_map = R"(
A--1--2--B
         |
         |
D--3--4--C--5--6--E
                                )";

  const gurka::ways ways = {
      {"AB", {{"highway", "primary"}}},
      {"BC", {{"highway", "primary"}}},
      {"DCE", {{"highway", "primary"}}},
  };

  const auto layout = gurka::detail::map_to_coordinates(ascii_map, 10);
  auto map = gurka::buildtiles(layout, ways, {}, {}, "test/data/uturn_asan");

  auto result =
      gurka::match(map, {"2", "6", "3"}, "through", "auto", R"({"penalize_immediate_uturn":false})");
}

But it doesnt expose the same problem..

@danpat danpat added this to the Sprint 16 - Left Turn milestone Aug 7, 2020
@kevinkreiser kevinkreiser merged commit 2f490ca into master Aug 7, 2020
const auto layout = gurka::detail::map_to_coordinates(ascii_map, 10);
auto map = gurka::buildtiles(layout, ways, {}, {}, "test/data/uturn_asan");

auto result =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the result be checked?

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

4 participants