Add local left_hand_driving flag in API version 2
This commit is contained in:
@@ -578,9 +578,11 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
|
||||
|
||||
// compute weight and duration penalties
|
||||
auto is_traffic_light = m_traffic_lights.count(node_at_center_of_intersection);
|
||||
ExtractionTurn extracted_turn(turn, is_traffic_light);
|
||||
extracted_turn.source_restricted = edge_data1.restricted;
|
||||
extracted_turn.target_restricted = edge_data2.restricted;
|
||||
ExtractionTurn extracted_turn(turn,
|
||||
is_traffic_light,
|
||||
edge_data1.restricted,
|
||||
edge_data2.restricted,
|
||||
edge_data1.is_left_hand_driving);
|
||||
scripting_environment.ProcessTurn(extracted_turn);
|
||||
|
||||
// turn penalties are limited to [-2^15, 2^15) which roughly
|
||||
|
||||
@@ -205,16 +205,16 @@ void GraphCompressor::Compress(
|
||||
boost::optional<EdgeWeight> node_weight_penalty = boost::none;
|
||||
if (has_node_penalty)
|
||||
{
|
||||
// generate an artifical turn for the turn penalty generation
|
||||
ExtractionTurn extraction_turn(true);
|
||||
|
||||
extraction_turn.source_restricted = fwd_edge_data1.restricted;
|
||||
extraction_turn.target_restricted = fwd_edge_data2.restricted;
|
||||
|
||||
// we cannot handle this as node penalty, if it depends on turn direction
|
||||
if (extraction_turn.source_restricted != extraction_turn.target_restricted)
|
||||
if (fwd_edge_data1.restricted != fwd_edge_data2.restricted)
|
||||
continue;
|
||||
|
||||
// generate an artifical turn for the turn penalty generation
|
||||
ExtractionTurn extraction_turn(true,
|
||||
fwd_edge_data1.restricted,
|
||||
fwd_edge_data2.restricted,
|
||||
fwd_edge_data1.is_left_hand_driving);
|
||||
|
||||
scripting_environment.ProcessTurn(extraction_turn);
|
||||
node_duration_penalty = extraction_turn.duration * 10;
|
||||
node_weight_penalty = extraction_turn.weight * weight_multiplier;
|
||||
|
||||
@@ -74,7 +74,7 @@ detail::RoundaboutFlags RoundaboutHandler::getRoundaboutFlags(
|
||||
bool can_enter_roundabout = false;
|
||||
bool can_exit_roundabout_separately = false;
|
||||
|
||||
const bool lhs = profile_properties.left_hand_driving;
|
||||
const bool lhs = in_edge_data.is_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)
|
||||
@@ -433,8 +433,9 @@ Intersection RoundaboutHandler::handleRoundabouts(const RoundaboutType roundabou
|
||||
Intersection intersection) const
|
||||
{
|
||||
NodeID node_at_center_of_intersection = node_based_graph.GetTarget(via_eid);
|
||||
const auto &in_edge_data = node_based_graph.GetEdgeData(via_eid);
|
||||
|
||||
const bool lhs = profile_properties.left_hand_driving;
|
||||
const bool lhs = in_edge_data.is_left_hand_driving;
|
||||
const int step = lhs ? -1 : 1;
|
||||
|
||||
if (on_roundabout)
|
||||
|
||||
@@ -237,7 +237,7 @@ void Sol2ScriptingEnvironment::InitContext(LuaScriptingContext &context)
|
||||
"interpolate",
|
||||
&RasterContainer::GetRasterInterpolateFromSource);
|
||||
|
||||
context.state.new_usertype<ProfileProperties>(
|
||||
auto registration_ProfileProperties = context.state.new_usertype<ProfileProperties>(
|
||||
"ProfileProperties",
|
||||
"traffic_signal_penalty",
|
||||
sol::property(&ProfileProperties::GetTrafficSignalPenalty,
|
||||
@@ -446,7 +446,9 @@ void Sol2ScriptingEnvironment::InitContext(LuaScriptingContext &context)
|
||||
"source_restricted",
|
||||
&ExtractionTurn::source_restricted,
|
||||
"target_restricted",
|
||||
&ExtractionTurn::target_restricted);
|
||||
&ExtractionTurn::target_restricted,
|
||||
"is_left_hand_driving",
|
||||
&ExtractionTurn::is_left_hand_driving);
|
||||
|
||||
// Keep in mind .location is available only if .pbf is preprocessed to set the location with the
|
||||
// ref using osmium command "osmium add-locations-to-ways"
|
||||
@@ -580,6 +582,7 @@ void Sol2ScriptingEnvironment::InitContext(LuaScriptingContext &context)
|
||||
if (use_turn_restrictions != sol::nullopt)
|
||||
context.properties.use_turn_restrictions = use_turn_restrictions.value();
|
||||
|
||||
// DEPRECATED: global left_hand_driving will be removed in the next profile API
|
||||
sol::optional<bool> left_hand_driving = properties["left_hand_driving"];
|
||||
if (left_hand_driving != sol::nullopt)
|
||||
context.properties.left_hand_driving = left_hand_driving.value();
|
||||
@@ -992,6 +995,7 @@ void LuaScriptingContext::ProcessWay(const osmium::Way &way,
|
||||
case 1:
|
||||
case 0:
|
||||
way_function(way, result);
|
||||
result.is_left_hand_driving = properties.left_hand_driving;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user