Add road priority class to turn function (#4858)
* expose road priority class to turn function * update docs
This commit is contained in:
parent
92b7d581ce
commit
fa8d788bb6
@ -223,6 +223,7 @@ source_number_of_lanes | Read | Integer | How many lanes
|
||||
source_highway_turn_classification | Read | Integer | Classification based on highway tag defined by user during setup. (default when not set: 0, allowed classification values are: 0-15))
|
||||
source_access_turn_classification | Read | Integer | Classification based on access tag defined by user during setup. (default when not set: 0, allowed classification values are: 0-15))
|
||||
source_speed | Read | Integer | Speed on this source road in km/h
|
||||
source_priority_class | Read | Enum | The type of road priority class of the source. Defined in `include/extractor/guidance/road_classification.hpp`
|
||||
target_restricted | Read | Boolean | Is it from a restricted access road? (See definition in `process_way`)
|
||||
target_mode | Read | Enum | Travel mode before the turn. Defined in `include/extractor/travel_mode.hpp`
|
||||
target_is_motorway | Read | Boolean | Is the target road a motorway?
|
||||
@ -231,6 +232,7 @@ target_number_of_lanes | Read | Integer | How many lanes
|
||||
target_highway_turn_classification | Read | Integer | Classification based on highway tag defined by user during setup. (default when not set: 0, allowed classification values are: 0-15))
|
||||
target_access_turn_classification | Read | Integer | Classification based on access tag defined by user during setup. (default when not set: 0, allowed classification values are: 0-15))
|
||||
target_speed | Read | Integer | Speed on this target road in km/h
|
||||
target_priority_class | Read | Enum | The type of road priority class of the target. Defined in `include/extractor/guidance/road_classification.hpp`
|
||||
roads_on_the_right | Read | Vector<ExtractionTurnLeg> | Vector with information about other roads on the right of the turn that are also connected at the intersection
|
||||
roads_on_the_left | Read | Vector<ExtractionTurnLeg> | Vector with information about other roads on the left of the turn that are also connected at the intersection. If turn is a u turn, this is empty.
|
||||
weight | Read/write | Float | Penalty to be applied for this turn (routing weight)
|
||||
@ -250,6 +252,7 @@ number_of_lanes | Read | Integer | How many lanes does th
|
||||
highway_turn_classification | Read | Integer | Classification based on highway tag defined by user during setup. (default when not set: 0, allowed classification values are: 0-15)
|
||||
access_turn_classification | Read | Integer | Classification based on access tag defined by user during setup. (default when not set: 0, allowed classification values are: 0-15)
|
||||
speed | Read | Integer | Speed on this road in km/h
|
||||
priority_class | Read | Enum | The type of road priority class of the leg. Defined in `include/extractor/guidance/road_classification.hpp`
|
||||
is_incoming | Read | Boolean | Is the road an incoming road of the intersection
|
||||
is_outgoing | Read | Boolean | Is the road an outgoing road of the intersection
|
||||
|
||||
|
@ -40,6 +40,7 @@ Feature: Turn Function Information
|
||||
.. ', is_outgoing: ' .. tostring(leg.is_outgoing)
|
||||
.. ', highway_turn_classification: ' .. tostring(leg.highway_turn_classification)
|
||||
.. ', access_turn_classification: ' .. tostring(leg.access_turn_classification)
|
||||
.. ', priority_class: ' .. tostring(leg.priority_class)
|
||||
end
|
||||
|
||||
function print_turn (profile, turn)
|
||||
@ -50,6 +51,8 @@ Feature: Turn Function Information
|
||||
print ('source_highway_turn_classification ' .. string.format("%s", tostring(turn.source_highway_turn_classification)))
|
||||
print ('source_access_turn_classification ' .. string.format("%s", tostring(turn.source_access_turn_classification)))
|
||||
print ('source_speed ' .. string.format("%s", tostring(turn.source_speed)))
|
||||
print ('source_priority_class ' .. string.format("%s", tostring(turn.source_priority_class)))
|
||||
print ('source_mode ' .. string.format("%s", tostring(turn.source_mode)))
|
||||
|
||||
print ('target_restricted ' .. string.format("%s", tostring(turn.target_restricted)))
|
||||
print ('target_is_motorway ' .. string.format("%s", tostring(turn.target_is_motorway)))
|
||||
@ -58,6 +61,8 @@ Feature: Turn Function Information
|
||||
print ('target_highway_turn_classification ' .. string.format("%s", tostring(turn.target_highway_turn_classification)))
|
||||
print ('target_access_turn_classification ' .. string.format("%s", tostring(turn.target_access_turn_classification)))
|
||||
print ('target_speed ' .. string.format("%s", tostring(turn.target_speed)))
|
||||
print ('target_priority_class ' .. string.format("%s", tostring(turn.target_priority_class)))
|
||||
print ('target_mode ' .. string.format("%s", tostring(turn.target_mode)))
|
||||
|
||||
print ('number_of_roads ' .. string.format("%s", tostring(turn.number_of_roads)))
|
||||
if not turn.is_u_turn then
|
||||
@ -97,8 +102,10 @@ Feature: Turn Function Information
|
||||
And stdout should contain "source_is_motorway true"
|
||||
And stdout should contain "target_is_motorway true"
|
||||
And stdout should contain "source_is_link false"
|
||||
And stdout should contain "source_priority_class 0"
|
||||
And stdout should contain "target_is_motorway true"
|
||||
And stdout should contain "target_is_link false"
|
||||
And stdout should contain "target_priority_class 0"
|
||||
|
||||
|
||||
Scenario: Turns should detect when turn is leaving highway
|
||||
@ -143,6 +150,9 @@ Feature: Turn Function Information
|
||||
When I run "osrm-extract --profile {profile_file} {osm_file}"
|
||||
Then it should exit successfully
|
||||
And stdout should contain "number_of_roads 3"
|
||||
And stdout should contain "source_priority_class 4"
|
||||
And stdout should contain "target_priority_class 0"
|
||||
And stdout should contain "target_priority_class 11"
|
||||
# turning abd, give information about bc
|
||||
And stdout should contain /roads_on_the_right \[1\] speed: [0-9]+, is_incoming: false, is_outgoing: true, highway_turn_classification: 4, access_turn_classification: 0/
|
||||
# turning abc, give information about bd
|
||||
|
@ -1,7 +1,8 @@
|
||||
#ifndef OSRM_EXTRACTION_TURN_HPP
|
||||
#define OSRM_EXTRACTION_TURN_HPP
|
||||
|
||||
#include <extractor/travel_mode.hpp>
|
||||
#include "extractor/road_classification.hpp"
|
||||
#include "extractor/travel_mode.hpp"
|
||||
|
||||
#include <boost/numeric/conversion/cast.hpp>
|
||||
|
||||
@ -21,13 +22,14 @@ struct ExtractionTurnLeg
|
||||
int highway_turn_classification,
|
||||
int access_turn_classification,
|
||||
int speed,
|
||||
RoadPriorityClass::Enum priority_class,
|
||||
bool is_incoming,
|
||||
bool is_outgoing)
|
||||
: is_restricted(is_restricted), is_motorway(is_motorway), is_link(is_link),
|
||||
number_of_lanes(number_of_lanes),
|
||||
highway_turn_classification(highway_turn_classification),
|
||||
access_turn_classification(access_turn_classification), speed(speed),
|
||||
is_incoming(is_incoming), is_outgoing(is_outgoing)
|
||||
priority_class(priority_class), is_incoming(is_incoming), is_outgoing(is_outgoing)
|
||||
{
|
||||
}
|
||||
|
||||
@ -38,6 +40,7 @@ struct ExtractionTurnLeg
|
||||
const int highway_turn_classification;
|
||||
const int access_turn_classification;
|
||||
const int speed;
|
||||
const RoadPriorityClass::Enum priority_class;
|
||||
const bool is_incoming;
|
||||
const bool is_outgoing;
|
||||
};
|
||||
@ -53,11 +56,12 @@ struct ExtractionTurn
|
||||
TravelMode source_mode,
|
||||
bool source_is_motorway,
|
||||
bool source_is_link,
|
||||
|
||||
int source_number_of_lanes,
|
||||
int source_highway_turn_classification,
|
||||
int source_access_turn_classification,
|
||||
int source_speed,
|
||||
RoadPriorityClass::Enum source_priority_class,
|
||||
|
||||
bool target_restricted,
|
||||
TravelMode target_mode,
|
||||
bool target_is_motorway,
|
||||
@ -66,6 +70,8 @@ struct ExtractionTurn
|
||||
int target_highway_turn_classification,
|
||||
int target_access_turn_classification,
|
||||
int target_speed,
|
||||
RoadPriorityClass::Enum target_priority_class,
|
||||
|
||||
const std::vector<ExtractionTurnLeg> &roads_on_the_right,
|
||||
const std::vector<ExtractionTurnLeg> &roads_on_the_left)
|
||||
: angle(180. - angle), number_of_roads(number_of_roads), is_u_turn(is_u_turn),
|
||||
@ -76,14 +82,14 @@ struct ExtractionTurn
|
||||
source_number_of_lanes(source_number_of_lanes),
|
||||
source_highway_turn_classification(source_highway_turn_classification),
|
||||
source_access_turn_classification(source_access_turn_classification),
|
||||
source_speed(source_speed),
|
||||
source_speed(source_speed), source_priority_class(source_priority_class),
|
||||
|
||||
target_restricted(target_restricted), target_mode(target_mode),
|
||||
target_is_motorway(target_is_motorway), target_is_link(target_is_link),
|
||||
target_number_of_lanes(target_number_of_lanes),
|
||||
target_highway_turn_classification(target_highway_turn_classification),
|
||||
target_access_turn_classification(target_access_turn_classification),
|
||||
target_speed(target_speed),
|
||||
target_speed(target_speed), target_priority_class(target_priority_class),
|
||||
|
||||
roads_on_the_right(roads_on_the_right), roads_on_the_left(roads_on_the_left), weight(0.),
|
||||
duration(0.)
|
||||
@ -105,6 +111,7 @@ struct ExtractionTurn
|
||||
const int source_highway_turn_classification;
|
||||
const int source_access_turn_classification;
|
||||
const int source_speed;
|
||||
const RoadPriorityClass::Enum source_priority_class;
|
||||
|
||||
// target info
|
||||
const bool target_restricted;
|
||||
@ -115,6 +122,7 @@ struct ExtractionTurn
|
||||
const int target_highway_turn_classification;
|
||||
const int target_access_turn_classification;
|
||||
const int target_speed;
|
||||
const RoadPriorityClass::Enum target_priority_class;
|
||||
|
||||
const std::vector<ExtractionTurnLeg> roads_on_the_right;
|
||||
const std::vector<ExtractionTurnLeg> roads_on_the_left;
|
||||
|
@ -585,6 +585,7 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
|
||||
((double)intersection::findEdgeLength(edge_geometries, node_based_edge_from) /
|
||||
edge_data1.duration) *
|
||||
36,
|
||||
edge_data1.flags.road_classification.GetPriority(),
|
||||
// target info
|
||||
edge_data2.flags.restricted,
|
||||
m_edge_based_node_container.GetAnnotation(edge_data2.annotation_data).travel_mode,
|
||||
@ -596,6 +597,7 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
|
||||
((double)intersection::findEdgeLength(edge_geometries, node_based_edge_to) /
|
||||
edge_data2.duration) *
|
||||
36,
|
||||
edge_data2.flags.road_classification.GetPriority(),
|
||||
// connected roads
|
||||
road_legs_on_the_right,
|
||||
road_legs_on_the_left);
|
||||
@ -763,6 +765,7 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
|
||||
connected_edge.eid) /
|
||||
edge_data.duration) *
|
||||
36,
|
||||
edge_data.flags.road_classification.GetPriority(),
|
||||
!connected_edge.entry_allowed ||
|
||||
(edge_data.flags.forward &&
|
||||
edge_data.flags.backward), // is incoming
|
||||
|
@ -235,6 +235,7 @@ void GraphCompressor::Compress(
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
false,
|
||||
TRAVEL_MODE_DRIVING,
|
||||
false,
|
||||
@ -243,6 +244,7 @@ void GraphCompressor::Compress(
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
roads_on_the_right,
|
||||
roads_on_the_left);
|
||||
scripting_environment.ProcessTurn(extraction_turn);
|
||||
|
@ -692,6 +692,8 @@ void Sol2ScriptingEnvironment::InitContext(LuaScriptingContext &context)
|
||||
&ExtractionTurnLeg::access_turn_classification,
|
||||
"speed",
|
||||
&ExtractionTurnLeg::speed,
|
||||
"priority_class",
|
||||
&ExtractionTurnLeg::priority_class,
|
||||
"is_incoming",
|
||||
&ExtractionTurnLeg::is_incoming,
|
||||
"is_outgoing",
|
||||
@ -726,6 +728,8 @@ void Sol2ScriptingEnvironment::InitContext(LuaScriptingContext &context)
|
||||
&ExtractionTurn::source_access_turn_classification,
|
||||
"source_speed",
|
||||
&ExtractionTurn::source_speed,
|
||||
"source_priority_class",
|
||||
&ExtractionTurn::source_priority_class,
|
||||
|
||||
"target_restricted",
|
||||
&ExtractionTurn::target_restricted,
|
||||
@ -743,6 +747,8 @@ void Sol2ScriptingEnvironment::InitContext(LuaScriptingContext &context)
|
||||
&ExtractionTurn::target_access_turn_classification,
|
||||
"target_speed",
|
||||
&ExtractionTurn::target_speed,
|
||||
"target_priority_class",
|
||||
&ExtractionTurn::target_priority_class,
|
||||
|
||||
"roads_on_the_right",
|
||||
&ExtractionTurn::roads_on_the_right,
|
||||
|
Loading…
Reference in New Issue
Block a user