Skip to content

Commit

Permalink
move on to current master
Browse files Browse the repository at this point in the history
  • Loading branch information
Moritz Kobitzsch committed Sep 7, 2016
1 parent bba7edd commit 7c15d0b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 59 deletions.
1 change: 0 additions & 1 deletion include/engine/guidance/post_processing.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ std::vector<RouteStep> collapseTurns(std::vector<RouteStep> steps);
// maneuvers that can, in some form, be seen as one. Lookahead of one step.
bool collapsable(const RouteStep &step, const RouteStep &next);

// Elongate a step by another. the data is added either at the front, or the back
OSRM_ATTR_WARN_UNUSED
RouteStep elongate(RouteStep step, const RouteStep &by_step);

Expand Down
84 changes: 26 additions & 58 deletions src/engine/guidance/post_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,42 +317,6 @@ void closeOffRoundabout(const bool on_roundabout,
}
}

// elongate a step by another. the data is added either at the front, or the back
OSRM_ATTR_WARN_UNUSED
RouteStep elongate(RouteStep step, const RouteStep &by_step)
{
BOOST_ASSERT(step.mode == by_step.mode);

step.duration += by_step.duration;
step.distance += by_step.distance;

// by_step comes after step -> we append at the end
if (step.geometry_end == by_step.geometry_begin + 1)
{
step.geometry_end = by_step.geometry_end;

// if we elongate in the back, we only need to copy the intersections to the beginning.
// the bearings remain the same, as the location of the turn doesn't change
step.intersections.insert(
step.intersections.end(), by_step.intersections.begin(), by_step.intersections.end());
}
// by_step comes before step -> we append at the front
else
{
BOOST_ASSERT(step.maneuver.waypoint_type == WaypointType::None &&
by_step.maneuver.waypoint_type == WaypointType::None);
BOOST_ASSERT(by_step.geometry_end == step.geometry_begin + 1);
step.geometry_begin = by_step.geometry_begin;

// elongating in the front changes the location of the maneuver
step.maneuver = by_step.maneuver;

step.intersections.insert(
step.intersections.begin(), by_step.intersections.begin(), by_step.intersections.end());
}
return step;
}

bool bearingsAreReversed(const double bearing_in, const double bearing_out)
{
// Nearly perfectly reversed angles have a difference close to 180 degrees (straight)
Expand Down Expand Up @@ -650,10 +614,33 @@ bool isStaggeredIntersection(const RouteStep &previous, const RouteStep &current

} // namespace

// A check whether two instructions can be treated as one. This is only the case for very short
// maneuvers that can, in some form, be seen as one. Lookahead of one step.
bool collapsable(const RouteStep &step, const RouteStep &next)
{
const auto is_short_step = step.distance < MAX_COLLAPSE_DISTANCE;
const auto instruction_can_be_collapsed = isCollapsableInstruction(step.maneuver.instruction);

const auto is_use_lane = step.maneuver.instruction.type == TurnType::UseLane;
const auto lanes_dont_change =
step.intersections.front().lanes == next.intersections.front().lanes;

if (is_short_step && instruction_can_be_collapsed)
return true;

// Prevent collapsing away important lane change steps
if (is_short_step && is_use_lane && lanes_dont_change)
return true;

return false;
}

// elongate a step by another. the data is added either at the front, or the back
OSRM_ATTR_WARN_UNUSED
RouteStep elongate(RouteStep step, const RouteStep &by_step)
{
BOOST_ASSERT(step.mode == by_step.mode);

step.duration += by_step.duration;
step.distance += by_step.distance;

Expand Down Expand Up @@ -684,29 +671,10 @@ RouteStep elongate(RouteStep step, const RouteStep &by_step)
return step;
}

// Post processing can invalidate some instructions. For example StayOnRoundabout
// is turned into exit counts. These instructions are removed by the following function

// A check whether two instructions can be treated as one. This is only the case for very short
// maneuvers that can, in some form, be seen as one. Lookahead of one step.
bool collapsable(const RouteStep &step, const RouteStep &next)
{
const auto is_short_step = step.distance < MAX_COLLAPSE_DISTANCE;
const auto instruction_can_be_collapsed = isCollapsableInstruction(step.maneuver.instruction);

const auto is_use_lane = step.maneuver.instruction.type == TurnType::UseLane;
const auto lanes_dont_change =
step.intersections.front().lanes == next.intersections.front().lanes;

if (is_short_step && instruction_can_be_collapsed)
return true;

// Prevent collapsing away important lane change steps
if (is_short_step && is_use_lane && lanes_dont_change)
return true;

return false;
}
// Post processing can invalidate some instructions. For example StayOnRoundabout
// is turned into exit counts. These instructions are removed by the following function

std::vector<RouteStep> removeNoTurnInstructions(std::vector<RouteStep> steps)
{
Expand Down Expand Up @@ -901,7 +869,7 @@ std::vector<RouteStep> collapseTurns(std::vector<RouteStep> steps)
// Turn Types in the response depend on whether we find the same road name
// (sliproad indcating a u-turn) or if we are turning onto a different road, in
// which case we use a turn.
if (steps[getPreviousIndex(one_back_index)].name_id ==
if (steps[getPreviousIndex(one_back_index,steps)].name_id ==
steps[step_index].name_id &&
steps[step_index].name_id != EMPTY_NAMEID)
steps[one_back_index].maneuver.instruction.type = TurnType::Continue;
Expand Down

0 comments on commit 7c15d0b

Please sign in to comment.