improve slipway handling to allow multiple styles of turn lanes / turn roads

This commit is contained in:
Moritz Kobitzsch
2016-06-08 14:55:59 +02:00
committed by Patrick Niklaus
parent e9a0beb4e8
commit 2b5355edca
7 changed files with 260 additions and 55 deletions
+4 -4
View File
@@ -385,7 +385,7 @@ Intersection MotorwayHandler::fromRamp(const EdgeID via_eid, Intersection inters
{
// circular order indicates a merge to the left (0-3 onto 4
if (angularDeviation(intersection[1].turn.angle, STRAIGHT_ANGLE) <
NARROW_TURN_ANGLE)
2*NARROW_TURN_ANGLE)
intersection[1].turn.instruction = {TurnType::Merge,
DirectionModifier::SlightLeft};
else // fallback
@@ -407,12 +407,12 @@ Intersection MotorwayHandler::fromRamp(const EdgeID via_eid, Intersection inters
if (detail::isMotorwayClass(intersection[2].turn.eid, node_based_graph) &&
node_based_graph.GetEdgeData(intersection[1].turn.eid).name_id !=
EMPTY_NAMEID &&
node_based_graph.GetEdgeData(intersection[1].turn.eid).name_id ==
node_based_graph.GetEdgeData(intersection[0].turn.eid).name_id)
node_based_graph.GetEdgeData(intersection[2].turn.eid).name_id ==
node_based_graph.GetEdgeData(intersection[1].turn.eid).name_id)
{
// circular order (5-0) onto 4
if (angularDeviation(intersection[2].turn.angle, STRAIGHT_ANGLE) <
NARROW_TURN_ANGLE)
2 * NARROW_TURN_ANGLE)
intersection[2].turn.instruction = {TurnType::Merge,
DirectionModifier::SlightRight};
else // fallback
+35 -8
View File
@@ -1,5 +1,5 @@
#include "extractor/guidance/turn_analysis.hpp"
#include "extractor/guidance/constants.hpp"
#include "extractor/guidance/turn_analysis.hpp"
#include "util/coordinate.hpp"
#include "util/coordinate_calculation.hpp"
@@ -127,15 +127,15 @@ Intersection TurnAnalysis::handleSliproads(const EdgeID source_edge_id,
auto intersection_node_id = node_based_graph.GetTarget(source_edge_id);
const auto linkTest = [this](const ConnectedRoad &road) {
return isLinkClass(
node_based_graph.GetEdgeData(road.turn.eid).road_classification.road_class) &&
road.entry_allowed &&
angularDeviation(road.turn.angle, STRAIGHT_ANGLE) < NARROW_TURN_ANGLE;
return // isLinkClass(
// node_based_graph.GetEdgeData(road.turn.eid).road_classification.road_class) &&
!node_based_graph.GetEdgeData(road.turn.eid).roundabout && road.entry_allowed &&
angularDeviation(road.turn.angle, STRAIGHT_ANGLE) <= 2 * NARROW_TURN_ANGLE;
};
bool hasRamp =
bool hasNarrow =
std::find_if(intersection.begin(), intersection.end(), linkTest) != intersection.end();
if (!hasRamp)
if (!hasNarrow)
return intersection;
const auto source_edge_data = node_based_graph.GetEdgeData(source_edge_id);
@@ -171,6 +171,8 @@ Intersection TurnAnalysis::handleSliproads(const EdgeID source_edge_id,
const auto next_road_next_intersection =
intersection_generator(intersection_node_id, next_road->turn.eid);
const auto next_intersection_node = node_based_graph.GetTarget(next_road->turn.eid);
std::unordered_set<NameID> target_road_names;
for (const auto &road : next_road_next_intersection)
@@ -187,7 +189,8 @@ Intersection TurnAnalysis::handleSliproads(const EdgeID source_edge_id,
for (const auto &candidate_road : target_intersection)
{
const auto &candidate_data = node_based_graph.GetEdgeData(candidate_road.turn.eid);
if (target_road_names.count(candidate_data.name_id) > 0)
if (target_road_names.count(candidate_data.name_id) > 0 &&
node_based_graph.GetTarget(candidate_road.turn.eid) == next_intersection_node)
{
road.turn.instruction.type = TurnType::Sliproad;
break;
@@ -196,6 +199,30 @@ Intersection TurnAnalysis::handleSliproads(const EdgeID source_edge_id,
}
}
if (next_road->turn.instruction.type == TurnType::Fork)
{
const auto &next_data = node_based_graph.GetEdgeData(next_road->turn.eid);
if (next_data.name_id == source_edge_data.name_id)
{
if (angularDeviation(next_road->turn.angle, STRAIGHT_ANGLE) < 5)
next_road->turn.instruction.type = TurnType::Suppressed;
else
next_road->turn.instruction.type = TurnType::Continue;
next_road->turn.instruction.direction_modifier =
getTurnDirection(next_road->turn.angle);
}
else if (next_data.name_id != EMPTY_NAMEID)
{
next_road->turn.instruction.type = TurnType::NewName;
next_road->turn.instruction.direction_modifier =
getTurnDirection(next_road->turn.angle);
}
else
{
next_road->turn.instruction.type = TurnType::Suppressed;
}
}
return intersection;
}
+36 -4
View File
@@ -1,7 +1,7 @@
#include "extractor/guidance/turn_handler.hpp"
#include "extractor/guidance/constants.hpp"
#include "extractor/guidance/intersection_scenario_three_way.hpp"
#include "extractor/guidance/toolkit.hpp"
#include "extractor/guidance/turn_handler.hpp"
#include "util/guidance/toolkit.hpp"
@@ -377,8 +377,12 @@ std::size_t TurnHandler::findObviousTurn(const EdgeID via_edge,
}
const auto out_data = node_based_graph.GetEdgeData(intersection[i].turn.eid);
auto continue_class = node_based_graph.GetEdgeData(intersection[best_continue].turn.eid)
.road_classification.road_class;
if (intersection[i].entry_allowed && out_data.name_id == in_data.name_id &&
deviation < best_continue_deviation)
(best_continue == 0 || continue_class > out_data.road_classification.road_class ||
(deviation < best_continue_deviation &&
out_data.road_classification.road_class == continue_class)))
{
best_continue_deviation = deviation;
best_continue = i;
@@ -392,7 +396,12 @@ std::size_t TurnHandler::findObviousTurn(const EdgeID via_edge,
return 0;
// has no obvious continued road
if (best_continue == 0 || true)
if (best_continue == 0 || best_continue_deviation >= 2 * NARROW_TURN_ANGLE ||
(node_based_graph.GetEdgeData(intersection[best_continue].turn.eid)
.road_classification.road_class ==
node_based_graph.GetEdgeData(intersection[best].turn.eid)
.road_classification.road_class &&
std::abs(best_continue_deviation) > 1 && best_deviation / best_continue_deviation < 0.75))
{
// Find left/right deviation
const double left_deviation = angularDeviation(
@@ -422,8 +431,31 @@ std::size_t TurnHandler::findObviousTurn(const EdgeID via_edge,
return best;
}
}
else
{
const double deviation =
angularDeviation(intersection[best_continue].turn.angle, STRAIGHT_ANGLE);
const auto &continue_data =
node_based_graph.GetEdgeData(intersection[best_continue].turn.eid);
if (std::abs(deviation) < 1)
return best_continue;
return 0; // no obvious turn
// check if any other similar best continues exist
for (std::size_t i = 1; i < intersection.size(); ++i)
{
if (i == best_continue || !intersection[i].entry_allowed)
continue;
if (angularDeviation(intersection[i].turn.angle, STRAIGHT_ANGLE) / deviation < 1.1 &&
continue_data.road_classification.road_class ==
node_based_graph.GetEdgeData(intersection[i].turn.eid)
.road_classification.road_class)
return 0;
}
return best_continue; // no obvious turn
}
return 0;
}
// Assignment of left turns hands of to right turns.