moved obviousness discovery. updated sliproad handler. back to original cases failing

This commit is contained in:
Moritz Kobitzsch 2016-08-10 13:35:21 +02:00
parent da73bae9c6
commit 46fd17a9ff
5 changed files with 85 additions and 40 deletions

View File

@ -601,17 +601,19 @@ Feature: Collapse
| bd | road | yes | primary |
| bc | road | yes | primary |
| de | road | yes | primary |
| fdcg | cross | no | secondary |
| fd | cross | no | secondary |
| dc | cross | no | secondary |
| cg | cross | no | secondary |
And the relations
| type | way:from | way:to | node:via | restriction |
| restriction | bd | fdcg | d | no_left_turn |
| restriction | bc | fdcg | c | no_right_turn |
| restriction | bd | dc | d | no_left_turn |
| restriction | bc | dc | c | no_right_turn |
When I route I should get
| waypoints | route | turns |
| a,g | road,cross,cross | depart,turn left,arrive |
| a,e | road,road | depart,arrive |
| waypoints | route | turns |
| a,g | road,cross,cross | depart,turn left,arrive |
| a,e | road,road | depart,arrive |
Scenario: Forking before a turn (forky)
Given the node map
@ -628,12 +630,14 @@ Feature: Collapse
| bd | road | yes | primary |
| bc | road | yes | primary |
| de | road | yes | primary |
| fdcg | cross | no | secondary |
| fd | cross | no | secondary |
| dc | cross | no | secondary |
| cg | cross | no | secondary |
And the relations
| type | way:from | way:to | node:via | restriction |
| restriction | bd | fdcg | d | no_left_turn |
| restriction | bc | fdcg | c | no_right_turn |
| restriction | bd | dc | d | no_left_turn |
| restriction | bc | dc | c | no_right_turn |
When I route I should get
| waypoints | route | turns |

View File

@ -584,6 +584,7 @@ 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

@ -458,14 +458,23 @@ std::size_t IntersectionHandler::findObviousTurn(const EdgeID via_edge,
return count;
}();
if (0 != best_continue && best != best_continue &&
angularDeviation(intersection[best].turn.angle, STRAIGHT_ANGLE) <
MAXIMAL_ALLOWED_NO_TURN_DEVIATION &&
node_based_graph.GetEdgeData(intersection[best_continue].turn.eid).road_classification ==
node_based_graph.GetEdgeData(intersection[best].turn.eid).road_classification)
{
// if the best angle is going straight but the road is turning, we don't name anything
// obvious
return 0;
}
// has no obvious continued road
if (best_continue == 0 || best_continue_deviation >= 2 * NARROW_TURN_ANGLE ||
num_continue_names > 2 ||
if (best_continue == 0 || num_continue_names > 2 ||
(node_based_graph.GetEdgeData(intersection[best_continue].turn.eid).road_classification ==
node_based_graph.GetEdgeData(intersection[best].turn.eid).road_classification &&
std::abs(best_continue_deviation) > 1 && best_deviation / best_continue_deviation < 0.75))
{
std::cout << "Checking best" << std::endl;
// Find left/right deviation
const double left_deviation = angularDeviation(
intersection[(best + 1) % intersection.size()].turn.angle, STRAIGHT_ANGLE);
@ -525,7 +534,6 @@ std::size_t IntersectionHandler::findObviousTurn(const EdgeID via_edge,
}
else
{
std::cout << "Checking best continue" << std::endl;
const double deviation =
angularDeviation(intersection[best_continue].turn.angle, STRAIGHT_ANGLE);
const auto &continue_data =

View File

@ -1,6 +1,6 @@
#include "extractor/guidance/sliproad_handler.hpp"
#include "extractor/guidance/constants.hpp"
#include "extractor/guidance/intersection_scenario_three_way.hpp"
#include "extractor/guidance/sliproad_handler.hpp"
#include "extractor/guidance/toolkit.hpp"
#include "util/guidance/toolkit.hpp"
@ -48,7 +48,62 @@ operator()(const NodeID, const EdgeID source_edge_id, Intersection intersection)
if (intersection.size() <= 2)
return intersection;
const auto obvious_turn_index = findObviousTurn(source_edge_id, intersection);
const auto findNextIntersectionForRoad =
[&](const NodeID at_node, const ConnectedRoad &road, NodeID *output_node) {
auto intersection = intersection_generator(at_node, road.turn.eid);
auto in_edge = road.turn.eid;
// skip over traffic lights
if (intersection.size() == 2)
{
const auto node = node_based_graph.GetTarget(in_edge);
in_edge = intersection[1].turn.eid;
if (output_node)
*output_node = node_based_graph.GetTarget(in_edge);
intersection = intersection_generator(node, in_edge);
}
return intersection;
};
const std::size_t obvious_turn_index = [&]() -> std::size_t {
const auto index = findObviousTurn(source_edge_id, intersection);
if (index != 0)
return index;
else if (intersection.size() == 3 &&
intersection[1].turn.instruction.type == TurnType::Fork)
{
// Forks themselves do not contain a `obvious` turn index. If we look at a fork that has
// a one-sided sliproad, however, the non-sliproad can be considered `obvious`. Here we
// assume that this could be the case and check for a potential sliproad/non-sliproad
// situation.
const auto intersection_following_index_one =
findNextIntersectionForRoad(intersection_node_id, intersection[1], NULL);
const auto intersection_following_index_two =
findNextIntersectionForRoad(intersection_node_id, intersection[2], NULL);
// a sliproad has to enter a road without choice
const auto couldBeSliproad = [](const Intersection &intersection) {
if (intersection.size() != 3)
return false;
if ((intersection[1].entry_allowed && intersection[2].entry_allowed) ||
intersection[0].entry_allowed)
return false;
return true;
};
if (couldBeSliproad(intersection_following_index_one))
return 2;
else if (couldBeSliproad(intersection_following_index_two))
return 1;
else
return 0;
}
else
return 0;
}();
if (obvious_turn_index == 0)
return intersection;
const auto &next_road = intersection[obvious_turn_index];
const auto linkTest = [this, next_road](const ConnectedRoad &road) {
@ -90,19 +145,8 @@ operator()(const NodeID, const EdgeID source_edge_id, Intersection intersection)
}
auto next_intersection_node = node_based_graph.GetTarget(next_road.turn.eid);
const auto next_road_next_intersection = [&]() {
auto intersection = intersection_generator(intersection_node_id, next_road.turn.eid);
auto in_edge = next_road.turn.eid;
// skip over traffic lights
if (intersection.size() == 2)
{
const auto node = node_based_graph.GetTarget(in_edge);
in_edge = intersection[1].turn.eid;
next_intersection_node = node_based_graph.GetTarget(in_edge);
intersection = intersection_generator(node, in_edge);
}
return intersection;
}();
const auto next_road_next_intersection =
findNextIntersectionForRoad(intersection_node_id, next_road, &next_intersection_node);
std::unordered_set<NameID> target_road_names;

View File

@ -125,10 +125,6 @@ Intersection TurnHandler::handleThreeWayTurn(const EdgeID via_edge, Intersection
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);
std::cout << "[intersection]\n";
for (auto road : intersection)
std::cout << "\t" << toString(road) << std::endl;
std::cout << "Obvious: " << obvious_index << std::endl;
BOOST_ASSERT(intersection[0].turn.angle < 0.001);
/* Two nearly straight turns -> FORK
OOOOOOO
@ -168,12 +164,9 @@ Intersection TurnHandler::handleThreeWayTurn(const EdgeID via_edge, Intersection
}
else
{
std::cout << "Name IDs: " << (int)in_data.name_id << " " << (int)first_data.name_id << " "
<< (int)second_data.name_id << std::endl;
if (obvious_index == 1 &&
(in_data.name_id != second_data.name_id || first_data.name_id == second_data.name_id))
{
std::cout << "Assigning Obvious first" << std::endl;
intersection[1].turn.instruction = getInstructionForObvious(
3, via_edge, isThroughStreet(1, intersection), intersection[1]);
}
@ -186,7 +179,6 @@ Intersection TurnHandler::handleThreeWayTurn(const EdgeID via_edge, Intersection
if (obvious_index == 2 &&
(in_data.name_id != first_data.name_id || first_data.name_id == second_data.name_id))
{
std::cout << "Assigning Obvious Second" << std::endl;
intersection[2].turn.instruction = getInstructionForObvious(
3, via_edge, isThroughStreet(2, intersection), intersection[2]);
}
@ -202,10 +194,6 @@ Intersection TurnHandler::handleThreeWayTurn(const EdgeID via_edge, Intersection
Intersection TurnHandler::handleComplexTurn(const EdgeID via_edge, Intersection intersection) const
{
const std::size_t obvious_index = findObviousTurn(via_edge, intersection);
std::cout << "[intersection]\n";
for (auto road : intersection)
std::cout << "\t" << toString(road) << std::endl;
std::cout << "Obvious: " << obvious_index << std::endl;
const auto fork_range = findFork(via_edge, intersection);
std::size_t straightmost_turn = 0;
double straightmost_deviation = 180;