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 for Sign retrieval #3208

Merged
merged 7 commits into from
Jul 14, 2021
Merged

Fix for Sign retrieval #3208

merged 7 commits into from
Jul 14, 2021

Conversation

ktatterso
Copy link
Contributor

@ktatterso ktatterso commented Jul 13, 2021

I didn't realize graphreader.GetBeginNodeId() might modify the given graph_tile_ptr. This modified approach for retrieving Sign's solves the problem without that concern.

Issue

There were some routing issues. These coordinates exposed the issue: -116.768599,36.9116110;-116.72504902777372,36.220713408337346101001

Tasklist

  • Add tests
  • Add #fixes with the issue number that this PR addresses
  • Update the docs with any new request parameters or changes to behavior described
  • Update the changelog
  • If you made changes to the lua files, update the taginfo too.

Requirements / Relations

Link any requirements here. Other pull requests this PR is based on?

@ktatterso ktatterso marked this pull request as ready for review July 13, 2021 16:14
Copy link
Member

@kevinkreiser kevinkreiser left a comment

Choose a reason for hiding this comment

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

ive added a suggestion which i think is more inline with the rest of the code base. the operation you are trying to accomplish there is very common and my suggestion follows that common pattern

@kevinkreiser kevinkreiser dismissed their stale review July 13, 2021 20:29

more than one way to skin a cat really, but not good ways this time

// GraphReader::GetGraphTile(DirectedEdge *) returns the graph-tile for
// the "end node". Hence, I need to obtain the opposing-directed-edge
// and then ask for it's graph tile. (Sigh)
GraphId opp_intersecting_de = graphtile->GetOpposingEdgeId(intersecting_de);
Copy link
Member

@kevinkreiser kevinkreiser Jul 13, 2021

Choose a reason for hiding this comment

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

this call call is actually very dangerous and i think we should remove it have it check and throw if its the wrong tile! it assumes that the endnode of intersecting_de is in the tile you are calling it on. if intersecting_de is an edge that ends in another tile, this will get the wrong node and get the wrong opposing edge id: https://github.com/valhalla/valhalla/blob/master/valhalla/baldr/graphtile.h#L250

if the edge doesnt leave the tile it would work. also nitpick naming this with "_de" is confusing because its a graphid not a "de"

// the "end node". Hence, I need to obtain the opposing-directed-edge
// and then ask for it's graph tile. (Sigh)
GraphId opp_intersecting_de = graphtile->GetOpposingEdgeId(intersecting_de);
graph_tile_ptr opp_tile = graphreader.GetGraphTile(opp_intersecting_de);
Copy link
Member

Choose a reason for hiding this comment

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

nothing wrong here, assuming we really wanted to get the tile in which the opposing edge lives this would be just fine

// and then ask for it's graph tile. (Sigh)
GraphId opp_intersecting_de = graphtile->GetOpposingEdgeId(intersecting_de);
graph_tile_ptr opp_tile = graphreader.GetGraphTile(opp_intersecting_de);
size_t edge_idx = intersecting_de - opp_tile->directededge(0);
Copy link
Member

Choose a reason for hiding this comment

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

here we have another problem. if intersecting_de is not in the same tile as its opposing edge then this pointer arithmetic would be completely off because intersecting_de doesnt actually occur inside of opp_tiles directected edges array

GraphId opp_intersecting_de = graphtile->GetOpposingEdgeId(intersecting_de);
graph_tile_ptr opp_tile = graphreader.GetGraphTile(opp_intersecting_de);
size_t edge_idx = intersecting_de - opp_tile->directededge(0);
std::vector<SignInfo> edge_signs = opp_tile->GetSigns(edge_idx);
Copy link
Member

Choose a reason for hiding this comment

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

this is totally fine although if we have the graphid of the edge we can just call edge_id.id() to get the index into the directed edges.

@kevinkreiser
Copy link
Member

kevinkreiser commented Jul 13, 2021

There were some routing issues. These coordinates exposed the issue: -116.768599,36.9116110;-116.72504902777372,36.220713408337346101001

Is there any chance you know more specifically where it was happening along that route? Like what OSM way are we talking about it, it was OSM data right?

I think that the fix would be to collapse all those changed lines into one line:

//graphtile is the tile that contains intersecting_de, so we just need to get its index to grab the signs from the tile
std::vector<SignInfo> edge_signs = graphtile->GetSigns(intersecting_de - graphtile->directededge(0));

If that doesnt give you back the sign that you think should be present in your output you need to check which exact edge in the graph you expect the sign to be on and check that that sign is associated to that edge. Let me know if you want to pair up a bit on this.

@ktatterso
Copy link
Contributor Author

@kevinkreiser Hey... ugh. So I do believe I found the issue. I was passing the wrong graph-tile-ptr to AddTripIntersectingEdge. We call it from two places and it was a copy/paste error.

The code was "working" with my changes because when I asked for the opp-intersecting-de the edge returned was hierarchy level = 1, which then retrieved the correct tile inadvertently.

@@ -755,7 +753,7 @@ void AddIntersectingEdges(const AttributesController& controller,
continue;
}

AddTripIntersectingEdge(controller, graphreader, start_tile, directededge, prev_de,
AddTripIntersectingEdge(controller, graphreader, endtile, directededge, prev_de,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Was incorrectly passing start_tile before... need to pass endtile.

@ktatterso
Copy link
Contributor Author

Thanks to @kevinkreiser for questioning and @dgearhart and @gknisely for helping debug my error.

@ktatterso ktatterso merged commit 25351eb into master Jul 14, 2021
@ktatterso ktatterso deleted the sign-fix branch August 30, 2021 22:06
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.

4 participants