-
Notifications
You must be signed in to change notification settings - Fork 660
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
Add turn lane info at maneuver point #1830
Conversation
…ecause we need to know what the turns, intesections, etc are so that we can properly aggment the turn lanes.
…nes at maneuver point
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.
Looks good to me! mostly just questions for my understanding
std::string turnlane_tags; | ||
if (forward && w.fwd_turn_lanes_index() > 0 && edge.attributes.way_end) { | ||
turnlane_tags = osmdata.name_offset_map.name(w.fwd_turn_lanes_index()); | ||
if (!turnlane_tags.empty()) { | ||
std::string str = TurnLanes::GetTurnLaneString(turnlane_tags); | ||
if (!str.empty()) { // don't add if invalid. |
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.
Should we trim
the string in case the value is empty space?
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.
Never really worried about this in the past. Always assumed that when the user enters in values in the editors, the value is checked.
bUpdated = true; | ||
break; | ||
} else | ||
break; |
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.
Think you can omit this else break
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.
No. Don't think so. We want to break out of the loop if any of the conditions are not found.
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.
I misread the code here 👍
LOG_ERROR("Mismatch in turn lane count before " + std::to_string(tl_before) + | ||
"" | ||
" and after " + | ||
std::to_string(turn_lanes.size()) + " tileid = " + std::to_string(tile_id.tileid())); |
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.
What action should we take if we see this error message?
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.
The tile creation process usually seg faults when things like this happen. This is just an indicator to help us figure it out.
src/mjolnir/graphtilebuilder.cc
Outdated
// Add turn lanes | ||
void GraphTileBuilder::AddTurnLanes(const std::vector<TurnLanes>& turn_lanes) { | ||
turnlanes_builder_.clear(); | ||
// Add restrictions to the list |
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.
Stray comment
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.
Thanks. Updated.
// Check if there is an active turn lane | ||
// Verify that turn lanes are not non-directional | ||
if (prev_edge && (prev_edge->turn_lanes_size() > 0) && prev_edge->HasActiveTurnLane() && | ||
!prev_edge->HasNonDirectionalTurnLane()) { |
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.
For my understanding - why did you exclude non-directional turn lanes? Is it to avoid having lanes that are all straight
?
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.
@danpaz this is so we do not return turn lanes with none
or empty
. If possible, our goal is to determine what they should be and mark them accordingly during data processing - mostly they will be marked as through
Codecov Report
@@ Coverage Diff @@
## master #1830 +/- ##
=========================================
Coverage ? 80.51%
=========================================
Files ? 365
Lines ? 49936
Branches ? 0
=========================================
Hits ? 40207
Misses ? 9729
Partials ? 0
Continue to review full report at Codecov.
|
@@ -1482,20 +1482,20 @@ function filter_tags_generic(kv) | |||
end | |||
|
|||
lane_count = numeric_prefix(kv["lanes"],false) | |||
if lane_count and lane_count > 10 then | |||
lane_count = 10 | |||
if lane_count and lane_count > 15 then |
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.
before it was if we have more than 10 we cap at 10, now its if we have more than 15 we have none?
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.
return false; | ||
} | ||
|
||
bool EnhancedTripLeg_Edge::ActivateTurnLanes(uint16_t turn_lane_direction) { |
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.
activates the turn lanes based on the specified turn lane direction
@@ -619,6 +652,11 @@ std::string EnhancedTripLeg_Edge::ToString() const { | |||
str += " | truck_route="; | |||
str += std::to_string(truck_route()); | |||
|
|||
if (turn_lanes_size() > 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.
output for debugging
@@ -891,6 +929,109 @@ std::string EnhancedTripLeg_Edge::SignElementsToParameterString( | |||
|
|||
return str; | |||
} | |||
|
|||
std::string EnhancedTripLeg_Edge::TurnLanesToString( |
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.
debug output to see turn lane info on each edge - it will like: turn_lanes=left|left;through|through;right
@@ -55,6 +56,49 @@ void CountAndSortExitSignList(std::vector<Sign>* prev_signs, std::vector<Sign>* | |||
SortExitSignList(curr_signs); | |||
} | |||
|
|||
uint16_t GetExpectedTurnLaneDirection(Maneuver& maneuver) { |
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.
determines the expected turn lane direction based on the specified maneuver type
@@ -83,6 +127,18 @@ std::list<Maneuver> ManeuversBuilder::Build() { | |||
// Combine maneuvers | |||
Combine(maneuvers); | |||
|
|||
#ifdef LOGGING_LEVEL_TRACE |
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.
moved this block to the proper spot in the code
@@ -2277,5 +2324,46 @@ void ManeuversBuilder::EnhanceSignlessInterchnages(std::list<Maneuver>& maneuver | |||
} | |||
} | |||
|
|||
void ManeuversBuilder::ProcessTurnLanes(std::list<Maneuver>& maneuvers) { |
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.
walks the maneuvers and activates the proper turn lanes at each transition point
@@ -1344,7 +1344,10 @@ TripLeg_Edge* TripLegBuilder::AddTripEdge(const AttributesController& controller | |||
// If turn lanes exist | |||
if (directededge->turnlanes()) { | |||
auto turnlanes = graphtile->turnlanes(idx); | |||
// TODO - add to TripLeg | |||
for (auto tl : turnlanes) { | |||
TurnLane* turn_lane = trip_edge->add_turn_lanes(); |
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 could be done in one line with out variable
@@ -388,6 +388,7 @@ json::ArrayPtr intersections(const valhalla::DirectionsLeg::Maneuver& maneuver, | |||
// NOTE: curr_edge does not exist for the arrive maneuver | |||
auto node = etp->GetEnhancedNode(i); | |||
auto curr_edge = etp->GetCurrEdge(i); | |||
auto prev_edge = etp->GetPrevEdge(i); |
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.
the previous edge is needed in multiple spots - so setting it here
// Process 'valid' flag | ||
lane->emplace("valid", turn_lane.is_active()); | ||
|
||
// Process 'indications' array - add indications from left to right |
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.
serialize the turn lanes from left to right
@@ -56,7 +56,7 @@ const static std::unordered_map<std::string, uint16_t> kTurnLaneMasks = | |||
{"slight_left", kTurnLaneSlightLeft}, | |||
{"slight_right", kTurnLaneSlightRight}, | |||
{"right", kTurnLaneRight}, | |||
{"sharp right", kTurnLaneSharpRight}, | |||
{"sharp_right", kTurnLaneSharpRight}, |
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.
fixed typo
@@ -316,6 +316,18 @@ class EnhancedTripLeg_Edge { | |||
return mutable_edge_->truck_route(); | |||
} | |||
|
|||
int turn_lanes_size() const { |
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.
added access to the turn lane methods
Issue
Updated data processing for turn lane info
Added turn lane info at maneuver point. Returns info when
format=osrm
- for example:Tasklist