fix interaction between sliproads/segregated intersections

This commit is contained in:
Moritz Kobitzsch
2016-09-06 15:47:03 +02:00
parent a551286a8f
commit 9123c93a90
16 changed files with 73 additions and 111 deletions
@@ -1,5 +1,5 @@
#include "extractor/guidance/constants.hpp"
#include "extractor/guidance/intersection_handler.hpp"
#include "extractor/guidance/constants.hpp"
#include "extractor/guidance/toolkit.hpp"
#include "util/coordinate_calculation.hpp"
@@ -457,8 +457,8 @@ std::size_t IntersectionHandler::findObviousTurn(const EdgeID via_edge,
if (best == 0)
return 0;
const std::pair<std::size_t, std::size_t> num_continue_names = [&]() {
std::size_t count = 0, count_valid = 0;
const std::pair<std::int64_t, std::int64_t> num_continue_names = [&]() {
std::int64_t count = 0, count_valid = 0;
if (in_data.name_id != EMPTY_NAMEID)
{
for (std::size_t i = 1; i < intersection.size(); ++i)
@@ -486,11 +486,25 @@ std::size_t IntersectionHandler::findObviousTurn(const EdgeID via_edge,
return 0;
}
const bool all_continues_are_narrow = [&]() {
if (in_data.name_id == EMPTY_NAMEID)
return false;
return std::count_if(
intersection.begin() + 1, intersection.end(), [&](const ConnectedRoad &road) {
return (in_data.name_id ==
node_based_graph.GetEdgeData(road.turn.eid).name_id) &&
angularDeviation(road.turn.angle, STRAIGHT_ANGLE) < NARROW_TURN_ANGLE;
}) == num_continue_names.first;
}();
// has no obvious continued road
const auto &best_data = node_based_graph.GetEdgeData(intersection[best].turn.eid);
if (best_continue == 0 || (num_continue_names.first >= 2 && intersection.size() >= 4) ||
if (best_continue == 0 || (!all_continues_are_narrow &&
(num_continue_names.first >= 2 && intersection.size() >= 4)) ||
(num_continue_names.second >= 2 && best_continue_deviation >= 2 * NARROW_TURN_ANGLE) ||
(best_deviation < FUZZY_ANGLE_DIFFERENCE && !best_data.road_classification.IsRampClass()))
(best_deviation != best_continue_deviation && best_deviation < FUZZY_ANGLE_DIFFERENCE &&
!best_data.road_classification.IsRampClass()))
{
// Find left/right deviation
const double left_deviation = angularDeviation(
+1 -1
View File
@@ -1,5 +1,5 @@
#include "extractor/guidance/constants.hpp"
#include "extractor/guidance/motorway_handler.hpp"
#include "extractor/guidance/constants.hpp"
#include "extractor/guidance/road_classification.hpp"
#include "extractor/guidance/toolkit.hpp"
@@ -1,5 +1,5 @@
#include "extractor/guidance/constants.hpp"
#include "extractor/guidance/roundabout_handler.hpp"
#include "extractor/guidance/constants.hpp"
#include "extractor/guidance/toolkit.hpp"
#include "util/coordinate_calculation.hpp"
+1 -5
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"
@@ -129,10 +129,6 @@ operator()(const NodeID, const EdgeID source_edge_id, Intersection intersection)
const auto source_edge_data = node_based_graph.GetEdgeData(source_edge_id);
const bool hasNext = obvious_turn_index != 0;
if (!hasNext)
return intersection;
// check whether the continue road is valid
const auto check_valid = [this, source_edge_data](const ConnectedRoad &road) {
const auto road_edge_data = node_based_graph.GetEdgeData(road.turn.eid);
+1 -1
View File
@@ -1,6 +1,6 @@
#include "extractor/guidance/turn_analysis.hpp"
#include "extractor/guidance/constants.hpp"
#include "extractor/guidance/road_classification.hpp"
#include "extractor/guidance/turn_analysis.hpp"
#include "util/coordinate.hpp"
#include "util/coordinate_calculation.hpp"
+1 -1
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"
+20 -22
View File
@@ -42,6 +42,7 @@ TurnLaneHandler::TurnLaneHandler(const util::NodeBasedDynamicGraph &node_based_g
turn_lane_masks(turn_lane_masks), lane_description_map(lane_description_map),
node_info_list(node_info_list), turn_analysis(turn_analysis), id_map(id_map)
{
count_handled = count_called = 0;
}
TurnLaneHandler::~TurnLaneHandler()
@@ -285,12 +286,10 @@ TurnLaneScenario TurnLaneHandler::deduceScenario(const NodeID at,
// At b-c, we get access to either a new set of lanes, or -- via the previous intersection
// -- to
// the second part of | left | through | right |. Lane anticipation can then deduce which
// lanes
// correspond to what and suppress unnecessary instructions.
// lanes correspond to what and suppress unnecessary instructions.
//
// For our initial case, we consider only the turns that are available at the current
// location,
// which are given by partitioning the lane data and selecting the first part.
// location, which are given by partitioning the lane data and selecting the first part.
if (!lane_data.empty())
{
if (lane_data.size() >= possible_entries)
@@ -355,21 +354,22 @@ void TurnLaneHandler::extractLaneData(const EdgeID via_edge,
LaneDataVector &lane_data) const
{
const auto &edge_data = node_based_graph.GetEdgeData(via_edge);
// TODO access correct data
lane_description_id = edge_data.lane_description_id;
const auto lane_description =
lane_description_id != INVALID_LANE_DESCRIPTIONID
? TurnLaneDescription(turn_lane_masks.begin() + turn_lane_offsets[lane_description_id],
turn_lane_masks.begin() +
turn_lane_offsets[lane_description_id + 1])
: TurnLaneDescription();
// create an empty lane data
if (INVALID_LANE_DESCRIPTIONID != lane_description_id)
{
const auto lane_description = TurnLaneDescription(
turn_lane_masks.begin() + turn_lane_offsets[lane_description_id],
turn_lane_masks.begin() + turn_lane_offsets[lane_description_id + 1]);
if (!lane_description.empty())
lane_data = laneDataFromDescription(lane_description);
BOOST_ASSERT(lane_description.empty() ||
lane_description.size() == (turn_lane_offsets[lane_description_id + 1] -
turn_lane_offsets[lane_description_id]));
BOOST_ASSERT(lane_description.size() == (turn_lane_offsets[lane_description_id + 1] -
turn_lane_offsets[lane_description_id]));
}
else
{
lane_data.clear();
}
}
/* A simple intersection does not depend on the next intersection coming up. This is important
@@ -401,8 +401,7 @@ bool TurnLaneHandler::isSimpleIntersection(const LaneDataVector &lane_data,
}
// in case an intersection offers far more lane data items than actual turns, some of them
// have
// to be for another intersection. A single additional item can be for an invalid bus lane.
// have to be for another intersection. A single additional item can be for an invalid bus lane.
const auto num_turns = [&]() {
auto count = getNumberOfTurns(intersection);
if (count < lane_data.size() && !intersection[0].entry_allowed &&
@@ -476,6 +475,7 @@ bool TurnLaneHandler::isSimpleIntersection(const LaneDataVector &lane_data,
return intersection.begin();
}();
BOOST_ASSERT(best_match != intersection.end());
std::size_t match_index = std::distance(intersection.begin(), best_match);
all_simple &= (matched_indices.count(match_index) == 0);
matched_indices.insert(match_index);
@@ -521,10 +521,8 @@ std::pair<LaneDataVector, LaneDataVector> TurnLaneHandler::partitionLaneData(
* look back between (1) and (2) to make sure we find the correct lane for the left-turn.
*
* Intersections like these have two parts. Turns that can be made at the first intersection
* and
* turns that have to be made at the second. The partitioning returns the lane data split
* into
* two parts, one for the first and one for the second intersection.
* and turns that have to be made at the second. The partitioning returns the lane data split
* into two parts, one for the first and one for the second intersection.
*/
// Try and maitch lanes to available turns. For Turns that are not directly matchable, check
@@ -105,6 +105,9 @@ bool isValidMatch(const TurnLaneType::Mask tag, const TurnInstruction instructio
double getMatchingQuality(const TurnLaneType::Mask tag, const ConnectedRoad &road)
{
const constexpr double idealized_turn_angles[] = {0, 35, 90, 135, 180, 225, 270, 315};
const auto modifier = getMatchingModifier(tag);
BOOST_ASSERT(static_cast<std::size_t>(modifier) <
sizeof(idealized_turn_angles) / sizeof(*idealized_turn_angles));
const auto idealized_angle = idealized_turn_angles[getMatchingModifier(tag)];
return angularDeviation(idealized_angle, road.turn.angle);
}