make sure to not-collapse different travel modes
This commit is contained in:
parent
dcc1b5ab2b
commit
c306a59854
@ -792,3 +792,49 @@ Feature: Collapse
|
|||||||
When I route I should get
|
When I route I should get
|
||||||
| waypoints | route | turns |
|
| waypoints | route | turns |
|
||||||
| a,e | main,main | depart,arrive |
|
| a,e | main,main | depart,arrive |
|
||||||
|
|
||||||
|
Scenario: Don't collapse different travel modes
|
||||||
|
Given the node map
|
||||||
|
| g | | | | | | | h | |
|
||||||
|
| a | b | | c | | | | e | f |
|
||||||
|
| | | | | | d | | | |
|
||||||
|
| | | | i | j | | | | |
|
||||||
|
|
||||||
|
And the ways
|
||||||
|
| nodes | highway | route | name |
|
||||||
|
| ab | primary | | road |
|
||||||
|
| bc | primary | ferry | |
|
||||||
|
| cd | primary | | road |
|
||||||
|
| de | | ferry | |
|
||||||
|
| ef | primary | | road |
|
||||||
|
| bg | service | | turn |
|
||||||
|
| ci | service | | turn |
|
||||||
|
| dj | service | | turn |
|
||||||
|
| eh | service | | turn |
|
||||||
|
|
||||||
|
When I route I should get
|
||||||
|
| waypoints | route |
|
||||||
|
| a,f | road,,road,,road,road |
|
||||||
|
|
||||||
|
Scenario: U-Turn onto a Ferry
|
||||||
|
Given the node map
|
||||||
|
| | | | | | | i | | |
|
||||||
|
| j | e | | | | | d | c | h |
|
||||||
|
| | | | | | | | | |
|
||||||
|
| | | | | | | | | |
|
||||||
|
| k | g | | | | | a | b | f |
|
||||||
|
|
||||||
|
And the ways
|
||||||
|
| nodes | highway | route | name | oneway |
|
||||||
|
| bf | primary | | road | yes |
|
||||||
|
| hcd | primary | | road | yes |
|
||||||
|
| bc | primary | | | yes |
|
||||||
|
| di | service | | serv | yes |
|
||||||
|
| ed | | ferry | ferry | |
|
||||||
|
| gab | | ferry | ferry | |
|
||||||
|
| kg | primary | | on | yes |
|
||||||
|
| ej | primary | | off | yes |
|
||||||
|
|
||||||
|
When I route I should get
|
||||||
|
| waypoints | route | turns |
|
||||||
|
| k,j | on,ferry,,ferry,off,off | depart,new name straight,continue uturn,turn straight,new name straight,arrive |
|
||||||
|
@ -474,15 +474,18 @@ void collapseTurnAt(std::vector<RouteStep> &steps,
|
|||||||
{
|
{
|
||||||
steps[one_back_index] = elongate(std::move(steps[one_back_index]), steps[step_index]);
|
steps[one_back_index] = elongate(std::move(steps[one_back_index]), steps[step_index]);
|
||||||
invalidateStep(steps[step_index]);
|
invalidateStep(steps[step_index]);
|
||||||
if (u_turn_with_name_change)
|
if (u_turn_with_name_change &&
|
||||||
|
compatible(steps[one_back_index], steps[next_step_index]))
|
||||||
{
|
{
|
||||||
steps[one_back_index] =
|
steps[one_back_index] =
|
||||||
elongate(std::move(steps[one_back_index]), steps[next_step_index]);
|
elongate(std::move(steps[one_back_index]), steps[next_step_index]);
|
||||||
invalidateStep(steps[next_step_index]); // will be skipped due to the
|
invalidateStep(steps[next_step_index]); // will be skipped due to the
|
||||||
// continue statement at the
|
// continue statement at the
|
||||||
// beginning of this function
|
// beginning of this function
|
||||||
}
|
|
||||||
|
|
||||||
|
forwardStepSignage(steps[one_back_index], steps[two_back_index]);
|
||||||
|
}
|
||||||
|
if (direct_u_turn)
|
||||||
forwardStepSignage(steps[one_back_index], steps[two_back_index]);
|
forwardStepSignage(steps[one_back_index], steps[two_back_index]);
|
||||||
steps[one_back_index].maneuver.instruction.type = TurnType::Continue;
|
steps[one_back_index].maneuver.instruction.type = TurnType::Continue;
|
||||||
steps[one_back_index].maneuver.instruction.direction_modifier =
|
steps[one_back_index].maneuver.instruction.direction_modifier =
|
||||||
@ -541,6 +544,7 @@ RouteStep elongate(RouteStep step, const RouteStep &by_step)
|
|||||||
{
|
{
|
||||||
step.duration += by_step.duration;
|
step.duration += by_step.duration;
|
||||||
step.distance += by_step.distance;
|
step.distance += by_step.distance;
|
||||||
|
BOOST_ASSERT(step.mode == by_step.mode);
|
||||||
|
|
||||||
// by_step comes after step -> we append at the end
|
// by_step comes after step -> we append at the end
|
||||||
if (step.geometry_end == by_step.geometry_begin + 1)
|
if (step.geometry_end == by_step.geometry_begin + 1)
|
||||||
@ -738,6 +742,8 @@ std::vector<RouteStep> collapseTurns(std::vector<RouteStep> steps)
|
|||||||
if (steps[index].maneuver.instruction.type != TurnType::Suppressed &&
|
if (steps[index].maneuver.instruction.type != TurnType::Suppressed &&
|
||||||
steps[index].maneuver.instruction.type != TurnType::NewName)
|
steps[index].maneuver.instruction.type != TurnType::NewName)
|
||||||
return false;
|
return false;
|
||||||
|
if (index + 1 < end_index && !compatible(steps[index], steps[index + 1]))
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
@ -823,6 +829,7 @@ std::vector<RouteStep> collapseTurns(std::vector<RouteStep> steps)
|
|||||||
else if (isCollapsableInstruction(current_step.maneuver.instruction) &&
|
else if (isCollapsableInstruction(current_step.maneuver.instruction) &&
|
||||||
current_step.maneuver.instruction.type != TurnType::Suppressed &&
|
current_step.maneuver.instruction.type != TurnType::Suppressed &&
|
||||||
steps[getPreviousNameIndex(step_index)].name_id == current_step.name_id &&
|
steps[getPreviousNameIndex(step_index)].name_id == current_step.name_id &&
|
||||||
|
// canCollapseAll is also checking for compatible(step,step+1) for all indices
|
||||||
canCollapseAll(getPreviousNameIndex(step_index) + 1, next_step_index))
|
canCollapseAll(getPreviousNameIndex(step_index) + 1, next_step_index))
|
||||||
{
|
{
|
||||||
BOOST_ASSERT(step_index > 0);
|
BOOST_ASSERT(step_index > 0);
|
||||||
@ -862,6 +869,8 @@ std::vector<RouteStep> collapseTurns(std::vector<RouteStep> steps)
|
|||||||
}
|
}
|
||||||
else if (nameSegmentLength(one_back_index, steps) < name_segment_cutoff_length &&
|
else if (nameSegmentLength(one_back_index, steps) < name_segment_cutoff_length &&
|
||||||
isBasicNameChange(one_back_step) && isBasicNameChange(current_step))
|
isBasicNameChange(one_back_step) && isBasicNameChange(current_step))
|
||||||
|
{
|
||||||
|
if (compatible(steps[two_back_index], steps[one_back_index]))
|
||||||
{
|
{
|
||||||
steps[two_back_index] =
|
steps[two_back_index] =
|
||||||
elongate(std::move(steps[two_back_index]), steps[one_back_index]);
|
elongate(std::move(steps[two_back_index]), steps[one_back_index]);
|
||||||
@ -873,12 +882,16 @@ std::vector<RouteStep> collapseTurns(std::vector<RouteStep> steps)
|
|||||||
invalidateStep(steps[step_index]);
|
invalidateStep(steps[step_index]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (step_index + 2 < steps.size() &&
|
else if (step_index + 2 < steps.size() &&
|
||||||
current_step.maneuver.instruction.type == TurnType::NewName &&
|
current_step.maneuver.instruction.type == TurnType::NewName &&
|
||||||
steps[next_step_index].maneuver.instruction.type == TurnType::NewName &&
|
steps[next_step_index].maneuver.instruction.type == TurnType::NewName &&
|
||||||
one_back_step.name_id == steps[next_step_index].name_id)
|
one_back_step.name_id == steps[next_step_index].name_id)
|
||||||
{
|
{
|
||||||
// if we are crossing an intersection and go immediately after into a name change,
|
if (compatible(steps[step_index], steps[next_step_index]))
|
||||||
|
{
|
||||||
|
// if we are crossing an intersection and go immediately after into a name
|
||||||
|
// change,
|
||||||
// we don't wan't to collapse the initial intersection.
|
// we don't wan't to collapse the initial intersection.
|
||||||
// a - b ---BRIDGE -- c
|
// a - b ---BRIDGE -- c
|
||||||
steps[one_back_index] =
|
steps[one_back_index] =
|
||||||
@ -887,6 +900,7 @@ std::vector<RouteStep> collapseTurns(std::vector<RouteStep> steps)
|
|||||||
invalidateStep(steps[step_index]);
|
invalidateStep(steps[step_index]);
|
||||||
invalidateStep(steps[next_step_index]);
|
invalidateStep(steps[next_step_index]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (choiceless(current_step, one_back_step) ||
|
else if (choiceless(current_step, one_back_step) ||
|
||||||
one_back_step.distance <= MAX_COLLAPSE_DISTANCE)
|
one_back_step.distance <= MAX_COLLAPSE_DISTANCE)
|
||||||
{
|
{
|
||||||
@ -903,6 +917,7 @@ std::vector<RouteStep> collapseTurns(std::vector<RouteStep> steps)
|
|||||||
// check for one of the multiple collapse scenarios and, if possible, collapse the turn
|
// check for one of the multiple collapse scenarios and, if possible, collapse the turn
|
||||||
const auto two_back_index = getPreviousIndex(one_back_index);
|
const auto two_back_index = getPreviousIndex(one_back_index);
|
||||||
BOOST_ASSERT(two_back_index < steps.size());
|
BOOST_ASSERT(two_back_index < steps.size());
|
||||||
|
// all turns that are handled lower down are also compatible
|
||||||
collapseTurnAt(steps, two_back_index, one_back_index, step_index);
|
collapseTurnAt(steps, two_back_index, one_back_index, step_index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,7 @@ double getMatchingQuality(const TurnLaneType::Mask tag, const ConnectedRoad &roa
|
|||||||
const auto modifier = getMatchingModifier(tag);
|
const auto modifier = getMatchingModifier(tag);
|
||||||
BOOST_ASSERT(static_cast<std::size_t>(modifier) <
|
BOOST_ASSERT(static_cast<std::size_t>(modifier) <
|
||||||
sizeof(idealized_turn_angles) / sizeof(*idealized_turn_angles));
|
sizeof(idealized_turn_angles) / sizeof(*idealized_turn_angles));
|
||||||
const auto idealized_angle = idealized_turn_angles[getMatchingModifier(tag)];
|
const auto idealized_angle = idealized_turn_angles[modifier];
|
||||||
return angularDeviation(idealized_angle, road.turn.angle);
|
return angularDeviation(idealized_angle, road.turn.angle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user