check for empty name_id before getting data

This commit is contained in:
karenzshea
2017-11-30 13:10:46 +01:00
committed by Patrick Niklaus
parent 56459d37d1
commit 89080fb2b0
10 changed files with 158 additions and 135 deletions
@@ -41,14 +41,14 @@ 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 &link_step,
const std::string &pre_link_step_name,
const std::string &post_link_step_name)
bool isLinkRoad(const RouteStep &pre_link_step,
const RouteStep &link_step,
const RouteStep &post_link_step)
{
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.empty();
const auto between_named = !pre_link_step_name.empty() && !post_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,9 +163,6 @@ 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 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))
@@ -198,9 +195,9 @@ 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_entering_intersection,
step_prior_to_intersection->name,
step_leaving_intersection->name) ||
return collapsable || isLinkRoad(*step_prior_to_intersection,
*step_entering_intersection,
*step_leaving_intersection) ||
only_allowed_turn;
}
+1 -2
View File
@@ -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, const datafacade::BaseDataFacade &facade)
RouteSteps collapseTurnInstructions(RouteSteps steps)
{
// make sure we can safely iterate over all steps (has depart/arrive with TurnType::NoTurn)
BOOST_ASSERT(!hasTurnType(steps.front()) && !hasTurnType(steps.back()));
@@ -464,7 +464,6 @@ RouteSteps collapseTurnInstructions(RouteSteps steps, const datafacade::BaseData
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))