Merge pull request #2707 from oxidase/left_side_driving

Left side driving
This commit is contained in:
Patrick Niklaus
2016-08-05 18:09:10 +02:00
committed by GitHub
14 changed files with 203 additions and 21 deletions
+2 -1
View File
@@ -342,7 +342,8 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
m_barrier_nodes,
m_compressed_edge_container,
name_table,
street_name_suffix_table);
street_name_suffix_table,
profile_properties);
guidance::lanes::TurnLaneHandler turn_lane_handler(
*m_node_based_graph, turn_lane_offsets, turn_lane_masks, turn_analysis);
+31 -13
View File
@@ -25,9 +25,10 @@ RoundaboutHandler::RoundaboutHandler(const util::NodeBasedDynamicGraph &node_bas
const std::vector<QueryNode> &node_info_list,
const CompressedEdgeContainer &compressed_edge_container,
const util::NameTable &name_table,
const SuffixTable &street_name_suffix_table)
const SuffixTable &street_name_suffix_table,
const ProfileProperties &profile_properties)
: IntersectionHandler(node_based_graph, node_info_list, name_table, street_name_suffix_table),
compressed_edge_container(compressed_edge_container)
compressed_edge_container(compressed_edge_container), profile_properties(profile_properties)
{
}
@@ -64,8 +65,13 @@ detail::RoundaboutFlags RoundaboutHandler::getRoundaboutFlags(
bool on_roundabout = in_edge_data.roundabout;
bool can_enter_roundabout = false;
bool can_exit_roundabout_separately = false;
for (const auto &road : intersection)
const bool lhs = profile_properties.left_hand_driving;
const int step = lhs ? -1 : 1;
for (std::size_t cnt = 0, idx = lhs ? intersection.size() - 1 : 0; cnt < intersection.size();
++cnt, idx += step)
{
const auto &road = intersection[idx];
const auto &edge_data = node_based_graph.GetEdgeData(road.turn.eid);
// only check actual outgoing edges
if (edge_data.reversed || !road.entry_allowed)
@@ -81,8 +87,6 @@ detail::RoundaboutFlags RoundaboutHandler::getRoundaboutFlags(
// separate vertex than the one we are coming from that are in the direction of
// the roundabout.
// The sorting of the angles represents a problem for left-sided driving, though.
// FIXME in case of left-sided driving, we have to check whether we can enter the
// roundabout later in the cycle, rather than prior.
// FIXME requires consideration of crossing the roundabout
else if (node_based_graph.GetTarget(road.turn.eid) != from_nid && !can_enter_roundabout)
{
@@ -101,8 +105,12 @@ void RoundaboutHandler::invalidateExitAgainstDirection(const NodeID from_nid,
return;
bool past_roundabout_angle = false;
for (auto &road : intersection)
const bool lhs = profile_properties.left_hand_driving;
const int step = lhs ? -1 : 1;
for (std::size_t cnt = 0, idx = lhs ? intersection.size() - 1 : 0; cnt < intersection.size();
++cnt, idx += step)
{
auto &road = intersection[idx];
const auto &edge_data = node_based_graph.GetEdgeData(road.turn.eid);
// only check actual outgoing edges
if (edge_data.reversed)
@@ -118,8 +126,6 @@ void RoundaboutHandler::invalidateExitAgainstDirection(const NodeID from_nid,
// This workaround handles cases in which an exit precedes and entry. The resulting
// u-turn against the roundabout direction is invalidated.
// The sorting of the angles represents a problem for left-sided driving, though.
// FIXME in case of left-sided driving, we have to check whether we can enter the
// roundabout later in the cycle, rather than prior.
if (!edge_data.roundabout && node_based_graph.GetTarget(road.turn.eid) != from_nid &&
past_roundabout_angle)
{
@@ -255,7 +261,7 @@ RoundaboutType RoundaboutHandler::getRoundaboutType(const NodeID nid) const
};
// the roundabout radius has to be the same for all locations we look at it from
// to guarantee this, we search the full roundabout for its vertices
// and select the three smalles ids
// and select the three smallest ids
std::set<NodeID> roundabout_nodes; // needs to be sorted
// this value is a hard abort to deal with potential self-loops
@@ -335,9 +341,9 @@ RoundaboutType RoundaboutHandler::getRoundaboutType(const NodeID nid) const
if (radius <= MAX_ROUNDABOUT_INTERSECTION_RADIUS)
{
const bool qualifies_as_roundabout_nitersection =
const bool qualifies_as_roundabout_intersection =
qualifiesAsRoundaboutIntersection(roundabout_nodes);
if (qualifies_as_roundabout_nitersection)
if (qualifies_as_roundabout_intersection)
{
return RoundaboutType::RoundaboutIntersection;
}
@@ -357,12 +363,19 @@ Intersection RoundaboutHandler::handleRoundabouts(const RoundaboutType roundabou
{
// detect via radius (get via circle through three vertices)
NodeID node_v = node_based_graph.GetTarget(via_eid);
const bool lhs = profile_properties.left_hand_driving;
const int step = lhs ? -1 : 1;
if (on_roundabout)
{
// Shoule hopefully have only a single exit and continue
// at least for cars. How about bikes?
for (auto &road : intersection)
for (std::size_t cnt = 0, idx = lhs ? intersection.size() - 1 : 0;
cnt < intersection.size();
++cnt, idx += step)
{
auto &road = intersection[idx];
auto &turn = road.turn;
const auto &out_data = node_based_graph.GetEdgeData(road.turn.eid);
if (out_data.roundabout)
@@ -395,8 +408,12 @@ Intersection RoundaboutHandler::handleRoundabouts(const RoundaboutType roundabou
return intersection;
}
else
for (auto &road : intersection)
{
for (std::size_t cnt = 0, idx = lhs ? intersection.size() - 1 : 0;
cnt < intersection.size();
++cnt, idx += step)
{
auto &road = intersection[idx];
if (!road.entry_allowed)
continue;
auto &turn = road.turn;
@@ -416,6 +433,7 @@ Intersection RoundaboutHandler::handleRoundabouts(const RoundaboutType roundabou
roundabout_type, getTurnDirection(turn.angle));
}
}
}
return intersection;
}
+4 -2
View File
@@ -37,7 +37,8 @@ TurnAnalysis::TurnAnalysis(const util::NodeBasedDynamicGraph &node_based_graph,
const std::unordered_set<NodeID> &barrier_nodes,
const CompressedEdgeContainer &compressed_edge_container,
const util::NameTable &name_table,
const SuffixTable &street_name_suffix_table)
const SuffixTable &street_name_suffix_table,
const ProfileProperties &profile_properties)
: node_based_graph(node_based_graph), intersection_generator(node_based_graph,
restriction_map,
barrier_nodes,
@@ -47,7 +48,8 @@ TurnAnalysis::TurnAnalysis(const util::NodeBasedDynamicGraph &node_based_graph,
node_info_list,
compressed_edge_container,
name_table,
street_name_suffix_table),
street_name_suffix_table,
profile_properties),
motorway_handler(node_based_graph, node_info_list, name_table, street_name_suffix_table),
turn_handler(node_based_graph, node_info_list, name_table, street_name_suffix_table),
sliproad_handler(intersection_generator,
+2 -1
View File
@@ -132,7 +132,8 @@ void LuaScriptingEnvironment::InitContext(LuaScriptingContext &context)
&ProfileProperties::SetUturnPenalty)
.def_readwrite("use_turn_restrictions", &ProfileProperties::use_turn_restrictions)
.def_readwrite("continue_straight_at_waypoint",
&ProfileProperties::continue_straight_at_waypoint),
&ProfileProperties::continue_straight_at_waypoint)
.def_readwrite("left_hand_driving", &ProfileProperties::left_hand_driving),
luabind::class_<std::vector<std::string>>("vector").def(
"Add",