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

Add turn lane info at maneuver point #1830

Merged
merged 44 commits into from
May 31, 2019
Merged

Add turn lane info at maneuver point #1830

merged 44 commits into from
May 31, 2019

Conversation

dgearhart
Copy link
Member

@dgearhart dgearhart commented May 28, 2019

Issue

Updated data processing for turn lane info
Added turn lane info at maneuver point. Returns info when format=osrm - for example:
image

Tasklist

  • Test with new data
  • Review - you must request approval to merge any PR to master
  • Generally use squash merge to rebase and clean comments before merging
  • Update the changelog

gknisely and others added 30 commits May 16, 2019 10:14
…ecause we need to know what the turns, intesections, etc are so that we can properly aggment the turn lanes.
Copy link
Collaborator

@danpaz danpaz left a 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.
Copy link
Collaborator

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?

Copy link
Member

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;
Copy link
Collaborator

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

Copy link
Member

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.

Copy link
Collaborator

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()));
Copy link
Collaborator

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?

Copy link
Member

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.

// Add turn lanes
void GraphTileBuilder::AddTurnLanes(const std::vector<TurnLanes>& turn_lanes) {
turnlanes_builder_.clear();
// Add restrictions to the list
Copy link
Collaborator

Choose a reason for hiding this comment

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

Stray comment

Copy link
Member

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()) {
Copy link
Collaborator

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?

Copy link
Member Author

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
Copy link

codecov bot commented May 31, 2019

Codecov Report

❗ No coverage uploaded for pull request base (master@c1d8b39). Click here to learn what that means.
The diff coverage is 63.82%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #1830   +/-   ##
=========================================
  Coverage          ?   80.51%           
=========================================
  Files             ?      365           
  Lines             ?    49936           
  Branches          ?        0           
=========================================
  Hits              ?    40207           
  Misses            ?     9729           
  Partials          ?        0
Impacted Files Coverage Δ
valhalla/baldr/turnlanes.h 98.27% <ø> (ø)
valhalla/mjolnir/graphtilebuilder.h 100% <ø> (ø)
valhalla/mjolnir/osmdata.h 100% <ø> (ø)
src/tyr/route_serializer_osrm.cc 0.38% <0%> (ø)
src/mjolnir/osmdata.cc 10.66% <0%> (ø)
test/astar.cc 93.52% <100%> (ø)
src/mjolnir/graphtilebuilder.cc 74.95% <100%> (ø)
valhalla/odin/enhancedtrippath.h 77.43% <100%> (ø)
src/thor/triplegbuilder.cc 67.19% <100%> (ø)
test/countryaccess.cc 66.66% <100%> (ø)
... and 6 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c1d8b39...699b814. Read the comment docs.

@@ -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
Copy link
Member

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?

Copy link
Member

Choose a reason for hiding this comment

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

image

return false;
}

bool EnhancedTripLeg_Edge::ActivateTurnLanes(uint16_t turn_lane_direction) {
Copy link
Member Author

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) {
Copy link
Member Author

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(
Copy link
Member Author

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) {
Copy link
Member Author

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
Copy link
Member Author

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) {
Copy link
Member Author

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();
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 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);
Copy link
Member Author

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
Copy link
Member Author

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

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 {
Copy link
Member Author

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

@dgearhart dgearhart merged commit 583821f into master May 31, 2019
@dgearhart dgearhart deleted the turn_lanes branch June 3, 2019 11:42
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