handle non-through case

This commit is contained in:
Moritz Kobitzsch 2016-08-10 14:35:02 +02:00
parent 46fd17a9ff
commit 9b2f6585fb
7 changed files with 28 additions and 34 deletions

View File

@ -325,7 +325,6 @@ Feature: Collapse
| g,f | second,first,first | depart,turn right,arrive |
| g,c | second,first,first | depart,end of road left,arrive |
Scenario: Do not collapse turning roads
Given the node map
| | | e | | |
@ -333,12 +332,12 @@ Feature: Collapse
| a | | b | f | |
And the ways
| nodes | highway | name |
| ab | primary | first |
| bc | primary | first |
| cd | primary | first |
| ce | primary | second |
| bf | primary | third |
| nodes | highway | name | oneway |
| ab | primary | first | yes |
| bc | primary | first | yes |
| cd | primary | first | yes |
| ce | primary | second | yes |
| bf | primary | third | yes |
When I route I should get
| waypoints | route | turns |
@ -602,8 +601,8 @@ Feature: Collapse
| bc | road | yes | primary |
| de | road | yes | primary |
| fd | cross | no | secondary |
| dc | cross | no | secondary |
| cg | cross | no | secondary |
| dc | cross | no | secondary |
| cg | cross | no | secondary |
And the relations
| type | way:from | way:to | node:via | restriction |
@ -631,8 +630,8 @@ Feature: Collapse
| bc | road | yes | primary |
| de | road | yes | primary |
| fd | cross | no | secondary |
| dc | cross | no | secondary |
| cg | cross | no | secondary |
| dc | cross | no | secondary |
| cg | cross | no | secondary |
And the relations
| type | way:from | way:to | node:via | restriction |

View File

@ -931,6 +931,7 @@ Feature: Simple Turns
| waypoints | turns | route |
| a,h | depart,off ramp right,turn sharp left,arrive | Blue Star Memorial Hwy,bcde,Centreville Road,Centreville Road |
@todo
# https://www.openstreetmap.org/#map=20/52.51609/13.41080
Scenario: Unnecessary Slight Left onto Stralauer Strasse
Given the node map
@ -964,6 +965,6 @@ Feature: Simple Turns
| ec | Molkenmarkt | secondary | yes |
When I route I should get
| waypoints | turns | route |
| a,d | depart,arrive | Molkenmarkt,Stralauer Str |
| e,d | depart,arrive | Molkenmarkt,Stralauer Str |
| waypoints | turns | route |
| a,d | depart,new name straight,arrive | Molkenmarkt,Stralauer Str,Stralauer Str |
| e,d | depart,new name slight left,arrive | Molkenmarkt,Stralauer Str,Stralauer Str |

View File

@ -31,6 +31,11 @@ const double constexpr INCREASES_BY_FOURTY_PERCENT = 1.4;
const int constexpr MAX_SLIPROAD_THRESHOLD = 250;
// Road priorities give an idea of how obvious a turn is. If two priorities differ greatly (e.g.
// service road over a primary road, the better priority can be seen as obvious due to its road
// category).
const double constexpr PRIORITY_DISTINCTION_FACTOR = 2.0;
} // namespace guidance
} // namespace extractor
} // namespace osrm

View File

@ -15,6 +15,10 @@ namespace extractor
namespace guidance
{
// Priorities are used to distinguish between how likely a turn is in comparison to a different
// road. The priorities here are used to distinguish between obvious turns (e.g. following a primary
// road next to a residential one is obvious). The decision what is obvious is described in the
// guidance constants.
namespace RoadPriorityClass
{
typedef std::uint8_t Enum;

View File

@ -584,7 +584,6 @@ std::vector<RouteStep> removeNoTurnInstructions(std::vector<RouteStep> steps)
// that we come across.
std::vector<RouteStep> postProcess(std::vector<RouteStep> steps)
{
util::guidance::print(steps);
// the steps should always include the first/last step in form of a location
BOOST_ASSERT(steps.size() >= 2);
if (steps.size() == 2)

View File

@ -393,7 +393,8 @@ std::size_t IntersectionHandler::findObviousTurn(const EdgeID via_edge,
const RoadClassification obvious_candidate,
const RoadClassification compare_candidate) {
const bool has_high_priority =
2 * obvious_candidate.GetPriority() < compare_candidate.GetPriority();
PRIORITY_DISTINCTION_FACTOR * obvious_candidate.GetPriority() <
compare_candidate.GetPriority();
const bool continues_on_same_class = in_classification == obvious_candidate;
return (has_high_priority && continues_on_same_class) ||
(!obvious_candidate.IsLowPriorityRoadClass() &&
@ -445,8 +446,6 @@ std::size_t IntersectionHandler::findObviousTurn(const EdgeID via_edge,
}
}
std::cout << "Chose Best: " << best << std::endl;
if (best == 0)
return 0;
@ -504,17 +503,12 @@ std::size_t IntersectionHandler::findObviousTurn(const EdgeID via_edge,
if (angularDeviation(intersection[right_index].turn.angle, STRAIGHT_ANGLE) <=
FUZZY_ANGLE_DIFFERENCE &&
!obvious_to_right)
{
std::cout << "Index to the right prevents it." << std::endl;
return 0;
}
if (angularDeviation(intersection[left_index].turn.angle, STRAIGHT_ANGLE) <=
FUZZY_ANGLE_DIFFERENCE &&
!obvious_to_left)
{
std::cout << "Index to the left prevents it." << std::endl;
return 0;
}
const bool distinct_to_left =
left_deviation / best_deviation >= DISTINCTION_RATIO ||
@ -528,9 +522,6 @@ std::size_t IntersectionHandler::findObviousTurn(const EdgeID via_edge,
// Well distinct turn that is nearly straight
if ((distinct_to_left || obvious_to_left) && (distinct_to_right || obvious_to_right))
return best;
std::cout << "Failed: " << distinct_to_left << " " << distinct_to_right << " "
<< obvious_to_left << " " << obvious_to_right << std::endl;
}
else
{

View File

@ -121,9 +121,6 @@ bool TurnHandler::isObviousOfTwo(const EdgeID via_edge,
Intersection TurnHandler::handleThreeWayTurn(const EdgeID via_edge, Intersection intersection) const
{
const auto &in_data = node_based_graph.GetEdgeData(via_edge);
const auto &first_data = node_based_graph.GetEdgeData(intersection[1].turn.eid);
const auto &second_data = node_based_graph.GetEdgeData(intersection[2].turn.eid);
const auto obvious_index = findObviousTurn(via_edge, intersection);
BOOST_ASSERT(intersection[0].turn.angle < 0.001);
/* Two nearly straight turns -> FORK
@ -164,8 +161,7 @@ Intersection TurnHandler::handleThreeWayTurn(const EdgeID via_edge, Intersection
}
else
{
if (obvious_index == 1 &&
(in_data.name_id != second_data.name_id || first_data.name_id == second_data.name_id))
if (obvious_index == 1)
{
intersection[1].turn.instruction = getInstructionForObvious(
3, via_edge, isThroughStreet(1, intersection), intersection[1]);
@ -176,8 +172,7 @@ Intersection TurnHandler::handleThreeWayTurn(const EdgeID via_edge, Intersection
getTurnDirection(intersection[1].turn.angle)};
}
if (obvious_index == 2 &&
(in_data.name_id != first_data.name_id || first_data.name_id == second_data.name_id))
if (obvious_index == 2)
{
intersection[2].turn.instruction = getInstructionForObvious(
3, via_edge, isThroughStreet(2, intersection), intersection[2]);