Initial left hand driving implementation
This commit is contained in:
parent
b0873e2aa4
commit
c09b9b4c99
@ -4,6 +4,7 @@
|
|||||||
#include "engine/guidance/leg_geometry.hpp"
|
#include "engine/guidance/leg_geometry.hpp"
|
||||||
#include "engine/guidance/route_step.hpp"
|
#include "engine/guidance/route_step.hpp"
|
||||||
#include "engine/phantom_node.hpp"
|
#include "engine/phantom_node.hpp"
|
||||||
|
#include "engine/datafacade/datafacade_base.hpp"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include "extractor/guidance/intersection_handler.hpp"
|
#include "extractor/guidance/intersection_handler.hpp"
|
||||||
#include "extractor/guidance/roundabout_type.hpp"
|
#include "extractor/guidance/roundabout_type.hpp"
|
||||||
#include "extractor/query_node.hpp"
|
#include "extractor/query_node.hpp"
|
||||||
|
#include "extractor/profile_properties.hpp"
|
||||||
|
|
||||||
#include "util/name_table.hpp"
|
#include "util/name_table.hpp"
|
||||||
#include "util/node_based_graph.hpp"
|
#include "util/node_based_graph.hpp"
|
||||||
@ -42,7 +43,8 @@ class RoundaboutHandler : public IntersectionHandler
|
|||||||
const std::vector<QueryNode> &node_info_list,
|
const std::vector<QueryNode> &node_info_list,
|
||||||
const CompressedEdgeContainer &compressed_edge_container,
|
const CompressedEdgeContainer &compressed_edge_container,
|
||||||
const util::NameTable &name_table,
|
const util::NameTable &name_table,
|
||||||
const SuffixTable &street_name_suffix_table);
|
const SuffixTable &street_name_suffix_table,
|
||||||
|
const ProfileProperties &profile_properties);
|
||||||
|
|
||||||
~RoundaboutHandler() override final = default;
|
~RoundaboutHandler() override final = default;
|
||||||
|
|
||||||
@ -81,6 +83,7 @@ class RoundaboutHandler : public IntersectionHandler
|
|||||||
bool qualifiesAsRoundaboutIntersection(const std::set<NodeID> &roundabout_nodes) const;
|
bool qualifiesAsRoundaboutIntersection(const std::set<NodeID> &roundabout_nodes) const;
|
||||||
|
|
||||||
const CompressedEdgeContainer &compressed_edge_container;
|
const CompressedEdgeContainer &compressed_edge_container;
|
||||||
|
const ProfileProperties &profile_properties;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace guidance
|
} // namespace guidance
|
||||||
|
@ -42,7 +42,8 @@ class TurnAnalysis
|
|||||||
const std::unordered_set<NodeID> &barrier_nodes,
|
const std::unordered_set<NodeID> &barrier_nodes,
|
||||||
const CompressedEdgeContainer &compressed_edge_container,
|
const CompressedEdgeContainer &compressed_edge_container,
|
||||||
const util::NameTable &name_table,
|
const util::NameTable &name_table,
|
||||||
const SuffixTable &street_name_suffix_table);
|
const SuffixTable &street_name_suffix_table,
|
||||||
|
const ProfileProperties &profile_properties);
|
||||||
|
|
||||||
// the entry into the turn analysis
|
// the entry into the turn analysis
|
||||||
Intersection getIntersection(const NodeID from_node, const EdgeID via_eid) const;
|
Intersection getIntersection(const NodeID from_node, const EdgeID via_eid) const;
|
||||||
|
@ -12,7 +12,7 @@ struct ProfileProperties
|
|||||||
{
|
{
|
||||||
ProfileProperties()
|
ProfileProperties()
|
||||||
: traffic_signal_penalty(0), u_turn_penalty(0), continue_straight_at_waypoint(true),
|
: traffic_signal_penalty(0), u_turn_penalty(0), continue_straight_at_waypoint(true),
|
||||||
use_turn_restrictions(false)
|
use_turn_restrictions(false), left_hand_driving(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,6 +36,7 @@ struct ProfileProperties
|
|||||||
int u_turn_penalty;
|
int u_turn_penalty;
|
||||||
bool continue_straight_at_waypoint;
|
bool continue_straight_at_waypoint;
|
||||||
bool use_turn_restrictions;
|
bool use_turn_restrictions;
|
||||||
|
bool left_hand_driving;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -138,13 +138,14 @@ properties.u_turn_penalty = 20
|
|||||||
properties.traffic_signal_penalty = 2
|
properties.traffic_signal_penalty = 2
|
||||||
properties.use_turn_restrictions = true
|
properties.use_turn_restrictions = true
|
||||||
properties.continue_straight_at_waypoint = true
|
properties.continue_straight_at_waypoint = true
|
||||||
|
properties.left_hand_driving = false
|
||||||
|
|
||||||
local side_road_speed_multiplier = 0.8
|
local side_road_speed_multiplier = 0.8
|
||||||
|
|
||||||
local turn_penalty = 10
|
local turn_penalty = 10
|
||||||
-- Note: this biases right-side driving. Should be
|
-- Note: this biases right-side driving. Should be
|
||||||
-- inverted for left-driving countries.
|
-- inverted for left-driving countries.
|
||||||
local turn_bias = 1.2
|
local turn_bias = properties.left_hand_driving and 1/1.2 or 1.2
|
||||||
|
|
||||||
local obey_oneway = true
|
local obey_oneway = true
|
||||||
local ignore_areas = true
|
local ignore_areas = true
|
||||||
|
19
profiles/lhs.lua
Normal file
19
profiles/lhs.lua
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
-- Testbot, with turn penalty
|
||||||
|
-- Used for testing turn penalties
|
||||||
|
|
||||||
|
require 'testbot'
|
||||||
|
|
||||||
|
properties.left_hand_driving = true
|
||||||
|
|
||||||
|
local turn_penalty = 500
|
||||||
|
local turn_bias = properties.left_hand_driving and 1/1.2 or 1.2
|
||||||
|
|
||||||
|
function turn_function (angle)
|
||||||
|
---- compute turn penalty as angle^2, with a left/right bias
|
||||||
|
k = turn_penalty/(90.0*90.0)
|
||||||
|
if angle>=0 then
|
||||||
|
return angle*angle*k/turn_bias
|
||||||
|
else
|
||||||
|
return angle*angle*k*turn_bias
|
||||||
|
end
|
||||||
|
end
|
19
profiles/rhs.lua
Normal file
19
profiles/rhs.lua
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
-- Testbot, with turn penalty
|
||||||
|
-- Used for testing turn penalties
|
||||||
|
|
||||||
|
require 'testbot'
|
||||||
|
|
||||||
|
properties.left_hand_driving = false
|
||||||
|
|
||||||
|
local turn_penalty = 500
|
||||||
|
local turn_bias = properties.left_hand_driving and 1/1.2 or 1.2
|
||||||
|
|
||||||
|
function turn_function (angle)
|
||||||
|
---- compute turn penalty as angle^2, with a left/right bias
|
||||||
|
k = turn_penalty/(90.0*90.0)
|
||||||
|
if angle>=0 then
|
||||||
|
return angle*angle*k/turn_bias
|
||||||
|
else
|
||||||
|
return angle*angle*k*turn_bias
|
||||||
|
end
|
||||||
|
end
|
@ -342,7 +342,8 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
|
|||||||
m_barrier_nodes,
|
m_barrier_nodes,
|
||||||
m_compressed_edge_container,
|
m_compressed_edge_container,
|
||||||
name_table,
|
name_table,
|
||||||
street_name_suffix_table);
|
street_name_suffix_table,
|
||||||
|
profile_properties);
|
||||||
guidance::lanes::TurnLaneHandler turn_lane_handler(
|
guidance::lanes::TurnLaneHandler turn_lane_handler(
|
||||||
*m_node_based_graph, turn_lane_offsets, turn_lane_masks, m_node_info_list, turn_analysis);
|
*m_node_based_graph, turn_lane_offsets, turn_lane_masks, m_node_info_list, turn_analysis);
|
||||||
|
|
||||||
|
@ -25,9 +25,11 @@ RoundaboutHandler::RoundaboutHandler(const util::NodeBasedDynamicGraph &node_bas
|
|||||||
const std::vector<QueryNode> &node_info_list,
|
const std::vector<QueryNode> &node_info_list,
|
||||||
const CompressedEdgeContainer &compressed_edge_container,
|
const CompressedEdgeContainer &compressed_edge_container,
|
||||||
const util::NameTable &name_table,
|
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),
|
: 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 +66,15 @@ detail::RoundaboutFlags RoundaboutHandler::getRoundaboutFlags(
|
|||||||
bool on_roundabout = in_edge_data.roundabout;
|
bool on_roundabout = in_edge_data.roundabout;
|
||||||
bool can_enter_roundabout = false;
|
bool can_enter_roundabout = false;
|
||||||
bool can_exit_roundabout_separately = 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;
|
||||||
|
const signed int_size = static_cast<signed>(intersection.size());
|
||||||
|
|
||||||
|
for (signed i = lhs ? int_size - 1 : 0;
|
||||||
|
i >= 0 && i < int_size; i += step)
|
||||||
{
|
{
|
||||||
|
const auto &road = intersection[i];
|
||||||
const auto &edge_data = node_based_graph.GetEdgeData(road.turn.eid);
|
const auto &edge_data = node_based_graph.GetEdgeData(road.turn.eid);
|
||||||
// only check actual outgoing edges
|
// only check actual outgoing edges
|
||||||
if (edge_data.reversed || !road.entry_allowed)
|
if (edge_data.reversed || !road.entry_allowed)
|
||||||
@ -101,8 +110,14 @@ void RoundaboutHandler::invalidateExitAgainstDirection(const NodeID from_nid,
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
bool past_roundabout_angle = false;
|
bool past_roundabout_angle = false;
|
||||||
for (auto &road : intersection)
|
const bool lhs = profile_properties.left_hand_driving;
|
||||||
|
const int step = lhs ? -1 : 1;
|
||||||
|
const signed int_size = static_cast<signed>(intersection.size());
|
||||||
|
|
||||||
|
for (signed i = lhs ? int_size - 1 : 0;
|
||||||
|
i >= 0 && i < int_size; i += step)
|
||||||
{
|
{
|
||||||
|
auto &road = intersection[i];
|
||||||
const auto &edge_data = node_based_graph.GetEdgeData(road.turn.eid);
|
const auto &edge_data = node_based_graph.GetEdgeData(road.turn.eid);
|
||||||
// only check actual outgoing edges
|
// only check actual outgoing edges
|
||||||
if (edge_data.reversed)
|
if (edge_data.reversed)
|
||||||
@ -255,7 +270,7 @@ RoundaboutType RoundaboutHandler::getRoundaboutType(const NodeID nid) const
|
|||||||
};
|
};
|
||||||
// the roundabout radius has to be the same for all locations we look at it from
|
// 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
|
// 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
|
std::set<NodeID> roundabout_nodes; // needs to be sorted
|
||||||
|
|
||||||
// this value is a hard abort to deal with potential self-loops
|
// this value is a hard abort to deal with potential self-loops
|
||||||
@ -335,9 +350,9 @@ RoundaboutType RoundaboutHandler::getRoundaboutType(const NodeID nid) const
|
|||||||
|
|
||||||
if (radius <= MAX_ROUNDABOUT_INTERSECTION_RADIUS)
|
if (radius <= MAX_ROUNDABOUT_INTERSECTION_RADIUS)
|
||||||
{
|
{
|
||||||
const bool qualifies_as_roundabout_nitersection =
|
const bool qualifies_as_roundabout_intersection =
|
||||||
qualifiesAsRoundaboutIntersection(roundabout_nodes);
|
qualifiesAsRoundaboutIntersection(roundabout_nodes);
|
||||||
if (qualifies_as_roundabout_nitersection)
|
if (qualifies_as_roundabout_intersection)
|
||||||
{
|
{
|
||||||
return RoundaboutType::RoundaboutIntersection;
|
return RoundaboutType::RoundaboutIntersection;
|
||||||
}
|
}
|
||||||
@ -357,12 +372,19 @@ Intersection RoundaboutHandler::handleRoundabouts(const RoundaboutType roundabou
|
|||||||
{
|
{
|
||||||
// detect via radius (get via circle through three vertices)
|
// detect via radius (get via circle through three vertices)
|
||||||
NodeID node_v = node_based_graph.GetTarget(via_eid);
|
NodeID node_v = node_based_graph.GetTarget(via_eid);
|
||||||
|
|
||||||
|
const bool lhs = profile_properties.left_hand_driving;
|
||||||
|
const int step = lhs ? -1 : 1;
|
||||||
|
const signed int_size = static_cast<signed>(intersection.size());
|
||||||
|
|
||||||
if (on_roundabout)
|
if (on_roundabout)
|
||||||
{
|
{
|
||||||
// Shoule hopefully have only a single exit and continue
|
// Shoule hopefully have only a single exit and continue
|
||||||
// at least for cars. How about bikes?
|
// at least for cars. How about bikes?
|
||||||
for (auto &road : intersection)
|
for (signed i = lhs ? int_size - 1 : 0;
|
||||||
|
i >= 0 && i < int_size; i += step)
|
||||||
{
|
{
|
||||||
|
auto &road = intersection[i];
|
||||||
auto &turn = road.turn;
|
auto &turn = road.turn;
|
||||||
const auto &out_data = node_based_graph.GetEdgeData(road.turn.eid);
|
const auto &out_data = node_based_graph.GetEdgeData(road.turn.eid);
|
||||||
if (out_data.roundabout)
|
if (out_data.roundabout)
|
||||||
@ -395,8 +417,11 @@ Intersection RoundaboutHandler::handleRoundabouts(const RoundaboutType roundabou
|
|||||||
return intersection;
|
return intersection;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
for (auto &road : intersection)
|
{
|
||||||
|
for (signed i = lhs ? int_size - 1 : 0;
|
||||||
|
i >= 0 && i < int_size; i += step)
|
||||||
{
|
{
|
||||||
|
auto &road = intersection[i];
|
||||||
if (!road.entry_allowed)
|
if (!road.entry_allowed)
|
||||||
continue;
|
continue;
|
||||||
auto &turn = road.turn;
|
auto &turn = road.turn;
|
||||||
@ -416,6 +441,7 @@ Intersection RoundaboutHandler::handleRoundabouts(const RoundaboutType roundabou
|
|||||||
roundabout_type, getTurnDirection(turn.angle));
|
roundabout_type, getTurnDirection(turn.angle));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return intersection;
|
return intersection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,8 @@ TurnAnalysis::TurnAnalysis(const util::NodeBasedDynamicGraph &node_based_graph,
|
|||||||
const std::unordered_set<NodeID> &barrier_nodes,
|
const std::unordered_set<NodeID> &barrier_nodes,
|
||||||
const CompressedEdgeContainer &compressed_edge_container,
|
const CompressedEdgeContainer &compressed_edge_container,
|
||||||
const util::NameTable &name_table,
|
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,
|
: node_based_graph(node_based_graph), intersection_generator(node_based_graph,
|
||||||
restriction_map,
|
restriction_map,
|
||||||
barrier_nodes,
|
barrier_nodes,
|
||||||
@ -47,7 +48,8 @@ TurnAnalysis::TurnAnalysis(const util::NodeBasedDynamicGraph &node_based_graph,
|
|||||||
node_info_list,
|
node_info_list,
|
||||||
compressed_edge_container,
|
compressed_edge_container,
|
||||||
name_table,
|
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),
|
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),
|
turn_handler(node_based_graph, node_info_list, name_table, street_name_suffix_table),
|
||||||
sliproad_handler(intersection_generator,
|
sliproad_handler(intersection_generator,
|
||||||
|
@ -132,7 +132,8 @@ void LuaScriptingEnvironment::InitContext(LuaScriptingContext &context)
|
|||||||
&ProfileProperties::SetUturnPenalty)
|
&ProfileProperties::SetUturnPenalty)
|
||||||
.def_readwrite("use_turn_restrictions", &ProfileProperties::use_turn_restrictions)
|
.def_readwrite("use_turn_restrictions", &ProfileProperties::use_turn_restrictions)
|
||||||
.def_readwrite("continue_straight_at_waypoint",
|
.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(
|
luabind::class_<std::vector<std::string>>("vector").def(
|
||||||
"Add",
|
"Add",
|
||||||
|
Loading…
Reference in New Issue
Block a user