check empty name string in turn collapsing
This commit is contained in:
committed by
Patrick Niklaus
parent
24562acd30
commit
3f7b5da683
@@ -41,15 +41,15 @@ bool noIntermediaryIntersections(const RouteStep &step)
|
||||
}
|
||||
|
||||
// Link roads, as far as we are concerned, are short unnamed segments between to named segments.
|
||||
bool isLinkroad(const RouteStep &pre_link_step,
|
||||
const RouteStep &link_step,
|
||||
const RouteStep &post_link_step)
|
||||
bool isLinkRoad(const RouteStep &link_step,
|
||||
const std::string &pre_link_step_name,
|
||||
const std::string &link_step_name,
|
||||
const std::string &post_link_step_name)
|
||||
{
|
||||
const constexpr double MAX_LINK_ROAD_LENGTH = 2 * MAX_COLLAPSE_DISTANCE;
|
||||
const auto is_short = link_step.distance <= MAX_LINK_ROAD_LENGTH;
|
||||
const auto unnamed = link_step.name_id == EMPTY_NAMEID;
|
||||
const auto between_named =
|
||||
(pre_link_step.name_id != EMPTY_NAMEID) && (post_link_step.name_id != EMPTY_NAMEID);
|
||||
const auto unnamed = link_step_name.empty();
|
||||
const auto between_named = !pre_link_step_name.empty() && !post_link_step_name.empty();
|
||||
|
||||
return is_short && unnamed && between_named && noIntermediaryIntersections(link_step);
|
||||
}
|
||||
@@ -163,7 +163,10 @@ bool isStaggeredIntersection(const RouteStepIterator step_prior_to_intersection,
|
||||
|
||||
bool isUTurn(const RouteStepIterator step_prior_to_intersection,
|
||||
const RouteStepIterator step_entering_intersection,
|
||||
const RouteStepIterator step_leaving_intersection)
|
||||
const RouteStepIterator step_leaving_intersection,
|
||||
const std::string &step_prior_name,
|
||||
const std::string &step_entering_name,
|
||||
const std::string &step_leaving_name)
|
||||
{
|
||||
if (!basicCollapsePreconditions(
|
||||
step_prior_to_intersection, step_entering_intersection, step_leaving_intersection))
|
||||
@@ -196,9 +199,10 @@ bool isUTurn(const RouteStepIterator step_prior_to_intersection,
|
||||
const auto only_allowed_turn = (numberOfAllowedTurns(*step_leaving_intersection) == 1) &&
|
||||
noIntermediaryIntersections(*step_entering_intersection);
|
||||
|
||||
return collapsable || isLinkroad(*step_prior_to_intersection,
|
||||
*step_entering_intersection,
|
||||
*step_leaving_intersection) ||
|
||||
return collapsable || isLinkRoad(*step_entering_intersection,
|
||||
step_prior_name,
|
||||
step_entering_name,
|
||||
step_leaving_name) ||
|
||||
only_allowed_turn;
|
||||
}
|
||||
|
||||
|
||||
@@ -326,7 +326,7 @@ void suppressStep(RouteStep &step_at_turn_location, RouteStep &step_after_turn_l
|
||||
|
||||
// OTHER IMPLEMENTATIONS
|
||||
OSRM_ATTR_WARN_UNUSED
|
||||
RouteSteps collapseTurnInstructions(RouteSteps steps)
|
||||
RouteSteps collapseTurnInstructions(RouteSteps steps, const datafacade::BaseDataFacade &facade)
|
||||
{
|
||||
// make sure we can safely iterate over all steps (has depart/arrive with TurnType::NoTurn)
|
||||
BOOST_ASSERT(!hasTurnType(steps.front()) && !hasTurnType(steps.back()));
|
||||
@@ -371,6 +371,9 @@ RouteSteps collapseTurnInstructions(RouteSteps steps)
|
||||
break;
|
||||
|
||||
const auto previous_step = findPreviousTurn(current_step);
|
||||
const auto previous_step_name = facade.GetNameForID(previous_step->name_id).to_string();
|
||||
const auto current_step_name = facade.GetNameForID(current_step->name_id).to_string();
|
||||
const auto next_step_name = facade.GetNameForID(next_step->name_id).to_string();
|
||||
|
||||
// don't collapse anything that does change modes
|
||||
if (current_step->mode != next_step->mode)
|
||||
@@ -387,7 +390,12 @@ RouteSteps collapseTurnInstructions(RouteSteps steps)
|
||||
TransferSignageStrategy(),
|
||||
NoModificationStrategy());
|
||||
}
|
||||
else if (isUTurn(previous_step, current_step, next_step))
|
||||
else if (isUTurn(previous_step,
|
||||
current_step,
|
||||
next_step,
|
||||
previous_step_name,
|
||||
current_step_name,
|
||||
next_step_name))
|
||||
{
|
||||
combineRouteSteps(
|
||||
*current_step,
|
||||
@@ -464,9 +472,15 @@ RouteSteps collapseTurnInstructions(RouteSteps steps)
|
||||
if (!hasWaypointType(*previous_step))
|
||||
{
|
||||
const auto far_back_step = findPreviousTurn(previous_step);
|
||||
const auto far_back_step_name = facade.GetNameForID(far_back_step->name_id).to_string();
|
||||
// due to name changes, we can find u-turns a bit late. Thats why we check far back as
|
||||
// well
|
||||
if (isUTurn(far_back_step, previous_step, current_step))
|
||||
if (isUTurn(far_back_step,
|
||||
previous_step,
|
||||
current_step,
|
||||
far_back_step_name,
|
||||
previous_step_name,
|
||||
current_step_name))
|
||||
{
|
||||
combineRouteSteps(
|
||||
*previous_step,
|
||||
|
||||
Reference in New Issue
Block a user