fix cucumber tests and issues

This commit is contained in:
Moritz Kobitzsch
2016-04-01 11:39:47 +02:00
committed by Patrick Niklaus
parent e60ebee3f2
commit ef1fb08723
24 changed files with 217 additions and 339 deletions
+7 -5
View File
@@ -301,7 +301,7 @@ void trimShortSegments(std::vector<RouteStep> &steps, LegGeometry &geometry)
// few seconds of inaccuracy at both ends. This is acceptable, however, since the turn should
// usually not be as relevant.
if (steps.size() < 2)
if (steps.size() < 2 || geometry.locations.size() <= 2)
return;
// if phantom node is located at the connection of two segments, either one can be selected as
@@ -320,7 +320,8 @@ void trimShortSegments(std::vector<RouteStep> &steps, LegGeometry &geometry)
BOOST_ASSERT(geometry.locations.size() >= steps.size());
// Look for distances under 1m
const bool zero_length_step = steps.front().distance <= 1;
const bool duplicated_coordinate = geometry.locations[0] == geometry.locations[1];
const bool duplicated_coordinate = util::coordinate_calculation::haversineDistance(
geometry.locations[0], geometry.locations[1]) <= 1;
if (zero_length_step || duplicated_coordinate)
{
// fixup the coordinate
@@ -381,7 +382,7 @@ void trimShortSegments(std::vector<RouteStep> &steps, LegGeometry &geometry)
}
// make sure we still have enough segments
if (steps.size() < 2)
if (steps.size() < 2 || geometry.locations.size() == 2)
return;
BOOST_ASSERT(geometry.locations.size() >= steps.size());
@@ -410,8 +411,9 @@ void trimShortSegments(std::vector<RouteStep> &steps, LegGeometry &geometry)
next_to_last_step.mode = new_next_to_last.mode;
// the geometry indices of the last step are already correct;
}
else if (geometry.locations[geometry.locations.size() - 2] ==
geometry.locations[geometry.locations.size() - 1])
else if (util::coordinate_calculation::haversineDistance(
geometry.locations[geometry.locations.size() - 2],
geometry.locations[geometry.locations.size() - 1]) <= 1)
{
// correct steps but duplicated coordinate in the end.
// This can happen if the last coordinate snaps to a node in the unpacked geometry
+15 -15
View File
@@ -749,6 +749,9 @@ TurnInstruction TurnAnalysis::getInstructionForObvious(const std::size_t num_roa
const ConnectedRoad &road) const
{
const auto type = findBasicTurnType(via_edge, road);
// handle travel modes:
const auto in_mode = node_based_graph.GetEdgeData(via_edge).travel_mode;
const auto out_mode = node_based_graph.GetEdgeData(road.turn.eid).travel_mode;
if (type == TurnType::Ramp)
{
return {TurnType::Ramp, getTurnDirection(road.turn.angle)};
@@ -767,9 +770,18 @@ TurnInstruction TurnAnalysis::getInstructionForObvious(const std::size_t num_roa
name_table.GetNameForID(out_data.name_id)))
return {TurnType::NewName, getTurnDirection(road.turn.angle)};
else
return {TurnType::Suppressed, getTurnDirection(road.turn.angle)};
{
if (in_mode == out_mode)
return {TurnType::Suppressed, getTurnDirection(road.turn.angle)};
else
return {TurnType::Notification, getTurnDirection(road.turn.angle)};
}
}
BOOST_ASSERT(type == TurnType::Continue);
if (in_mode != out_mode)
{
return {TurnType::Notification, getTurnDirection(road.turn.angle)};
}
if (num_roads > 2)
{
return {TurnType::Suppressed, getTurnDirection(road.turn.angle)};
@@ -984,17 +996,9 @@ TurnAnalysis::handleThreeWayTurn(const EdgeID via_edge,
}
else
{
const unsigned in_name_id = node_based_graph.GetEdgeData(via_edge).name_id;
const unsigned out_names[2] = {
node_based_graph.GetEdgeData(intersection[1].turn.eid).name_id,
node_based_graph.GetEdgeData(intersection[2].turn.eid).name_id};
if (isObviousOfTwo(intersection[1], intersection[2]))
{
intersection[1].turn.instruction = {
(in_name_id != INVALID_NAME_ID || out_names[0] != INVALID_NAME_ID)
? TurnType::NewName
: TurnType::NoTurn,
getTurnDirection(intersection[1].turn.angle)};
intersection[1].turn.instruction = getInstructionForObvious(3,via_edge,intersection[1]);
}
else
{
@@ -1004,11 +1008,7 @@ TurnAnalysis::handleThreeWayTurn(const EdgeID via_edge,
if (isObviousOfTwo(intersection[2], intersection[1]))
{
intersection[2].turn.instruction = {
(in_name_id != INVALID_NAME_ID || out_names[1] != INVALID_NAME_ID)
? TurnType::NewName
: TurnType::NoTurn,
getTurnDirection(intersection[2].turn.angle)};
intersection[2].turn.instruction = getInstructionForObvious(3,via_edge,intersection[2]);
}
else
{