Take stop signs into account during routing

This commit is contained in:
Siarhei Fedartsou 2022-10-31 21:58:18 +01:00
parent a7142ee737
commit 3080be59ed
5 changed files with 47 additions and 11 deletions

View File

@ -31,12 +31,13 @@ Feature: Car - Handle give way signs
| e | give_way | | e | give_way |
| l | give_way | | l | give_way |
# TODO: give way signs with no direction has no any impact on routing at the moment
When I route I should get When I route I should get
| from | to | time | # | | from | to | time | # |
| 1 | 2 | 11.1s | no turn with no give way | | 1 | 2 | 11.1s | no turn with no give way |
| 3 | 4 | 13.1s | no turn with give way | | 3 | 4 | 11.1s | no turn with give way |
| g | j | 18.7s | turn with no give way | | g | j | 18.7s | turn with no give way |
| k | n | 20.7s | turn with give way | | k | n | 18.7s | turn with give way |
Scenario: Car - Give way direction Scenario: Car - Give way direction
@ -64,13 +65,12 @@ Feature: Car - Handle give way signs
| e | give_way | | | e | give_way | |
| h | give_way | forward | | h | give_way | forward |
| k | give_way | backward | | k | give_way | backward |
When I route I should get When I route I should get
| from | to | time | weight | # | | from | to | time | weight | # |
| 1 | 2 | 11.1s | 11.1 | no turn with no give way | | 1 | 2 | 11.1s | 11.1 | no turn with no give way |
| 2 | 1 | 11.1s | 11.1 | no turn with no give way | | 2 | 1 | 11.1s | 11.1 | no turn with no give way |
| 3 | 4 | 13.1s | 13.1 | no turn with give way | | 3 | 4 | 11.1s | 11.1 | no turn with give way |
| 4 | 3 | 13.1s | 13.1 | no turn with give way | | 4 | 3 | 11.1s | 11.1 | no turn with give way |
| 5 | 6 | 13.1s | 13.1 | no turn with give way | | 5 | 6 | 13.1s | 13.1 | no turn with give way |
| 6 | 5 | 11.1s | 11.1 | no turn with no give way | | 6 | 5 | 11.1s | 11.1 | no turn with no give way |
| 7 | 8 | 11.1s | 11.1 | no turn with no give way | | 7 | 8 | 11.1s | 11.1 | no turn with no give way |

View File

@ -31,12 +31,13 @@ Feature: Car - Handle stop signs
| e | stop | | e | stop |
| l | stop | | l | stop |
# TODO: stop signs with no direction has no any impact on routing at the moment
When I route I should get When I route I should get
| from | to | time | # | | from | to | time | # |
| 1 | 2 | 11.1s | no turn with no stop sign | | 1 | 2 | 11.1s | no turn with no stop sign |
| 3 | 4 | 13.1s | no turn with stop sign | | 3 | 4 | 11.1s | no turn with stop sign |
| g | j | 18.7s | turn with no stop sign | | g | j | 18.7s | turn with no stop sign |
| k | n | 20.7s | turn with stop sign | | k | n | 18.7s | turn with stop sign |
Scenario: Car - Stop sign direction Scenario: Car - Stop sign direction
Given the node map Given the node map
@ -68,8 +69,8 @@ Feature: Car - Handle stop signs
| from | to | time | weight | # | | from | to | time | weight | # |
| 1 | 2 | 11.1s | 11.1 | no turn with no stop sign | | 1 | 2 | 11.1s | 11.1 | no turn with no stop sign |
| 2 | 1 | 11.1s | 11.1 | no turn with no stop sign | | 2 | 1 | 11.1s | 11.1 | no turn with no stop sign |
| 3 | 4 | 13.1s | 13.1 | no turn with stop sign | | 3 | 4 | 11.1s | 11.1 | no turn with stop sign |
| 4 | 3 | 13.1s | 13.1 | no turn with stop sign | | 4 | 3 | 11.1s | 11.1 | no turn with stop sign |
| 5 | 6 | 13.1s | 13.1 | no turn with stop sign | | 5 | 6 | 13.1s | 13.1 | no turn with stop sign |
| 6 | 5 | 11.1s | 11.1 | no turn with no stop sign | | 6 | 5 | 11.1s | 11.1 | no turn with no stop sign |
| 7 | 8 | 11.1s | 11.1 | no turn with no stop sign | | 7 | 8 | 11.1s | 11.1 | no turn with no stop sign |

View File

@ -82,11 +82,13 @@ void ExtractorCallbacks::ProcessNode(const osmium::Node &input_node,
{ {
external_memory.external_traffic_signals.push_back({id, result_node.traffic_lights}); external_memory.external_traffic_signals.push_back({id, result_node.traffic_lights});
} }
if (result_node.give_way != TrafficFlowControlNodeDirection::NONE) // TODO: we ignore `ALL` for both stop signs and give way signs, because we cannot understand direction of the way they should be applied yet
// see: https://wiki.openstreetmap.org/wiki/Tag:highway%3Dstop#Direction
if (result_node.give_way != TrafficFlowControlNodeDirection::NONE && result_node.give_way != TrafficFlowControlNodeDirection::ALL)
{ {
external_memory.external_give_ways.push_back({id, result_node.give_way}); external_memory.external_give_ways.push_back({id, result_node.give_way});
} }
if (result_node.stop_sign != TrafficFlowControlNodeDirection::NONE) if (result_node.stop_sign != TrafficFlowControlNodeDirection::NONE && result_node.stop_sign != TrafficFlowControlNodeDirection::ALL)
{ {
external_memory.external_stop_signs.push_back({id, result_node.stop_sign}); external_memory.external_stop_signs.push_back({id, result_node.stop_sign});
} }

View File

@ -66,6 +66,8 @@ BOOST_AUTO_TEST_CASE(long_road_test)
std::unordered_set<NodeID> barrier_nodes; std::unordered_set<NodeID> barrier_nodes;
TrafficFlowControlNodes traffic_lights; TrafficFlowControlNodes traffic_lights;
TrafficFlowControlNodes stop_signs;
TrafficFlowControlNodes give_way_signs;
std::vector<TurnRestriction> restrictions; std::vector<TurnRestriction> restrictions;
std::vector<NodeBasedEdgeAnnotation> annotations(1); std::vector<NodeBasedEdgeAnnotation> annotations(1);
CompressedEdgeContainer container; CompressedEdgeContainer container;
@ -88,6 +90,8 @@ BOOST_AUTO_TEST_CASE(long_road_test)
compressor.Compress(barrier_nodes, compressor.Compress(barrier_nodes,
traffic_lights, traffic_lights,
stop_signs,
give_way_signs,
scripting_environment, scripting_environment,
restrictions, restrictions,
maneuver_overrides, maneuver_overrides,
@ -112,6 +116,8 @@ BOOST_AUTO_TEST_CASE(loop_test)
std::unordered_set<NodeID> barrier_nodes; std::unordered_set<NodeID> barrier_nodes;
TrafficFlowControlNodes traffic_lights; TrafficFlowControlNodes traffic_lights;
TrafficFlowControlNodes stop_signs;
TrafficFlowControlNodes give_way_signs;
std::vector<TurnRestriction> restrictions; std::vector<TurnRestriction> restrictions;
CompressedEdgeContainer container; CompressedEdgeContainer container;
std::vector<NodeBasedEdgeAnnotation> annotations(1); std::vector<NodeBasedEdgeAnnotation> annotations(1);
@ -148,6 +154,8 @@ BOOST_AUTO_TEST_CASE(loop_test)
compressor.Compress(barrier_nodes, compressor.Compress(barrier_nodes,
traffic_lights, traffic_lights,
stop_signs,
give_way_signs,
scripting_environment, scripting_environment,
restrictions, restrictions,
maneuver_overrides, maneuver_overrides,
@ -175,6 +183,8 @@ BOOST_AUTO_TEST_CASE(t_intersection)
std::unordered_set<NodeID> barrier_nodes; std::unordered_set<NodeID> barrier_nodes;
TrafficFlowControlNodes traffic_lights; TrafficFlowControlNodes traffic_lights;
TrafficFlowControlNodes stop_signs;
TrafficFlowControlNodes give_way_signs;
std::vector<NodeBasedEdgeAnnotation> annotations(1); std::vector<NodeBasedEdgeAnnotation> annotations(1);
std::vector<TurnRestriction> restrictions; std::vector<TurnRestriction> restrictions;
CompressedEdgeContainer container; CompressedEdgeContainer container;
@ -197,6 +207,8 @@ BOOST_AUTO_TEST_CASE(t_intersection)
compressor.Compress(barrier_nodes, compressor.Compress(barrier_nodes,
traffic_lights, traffic_lights,
stop_signs,
give_way_signs,
scripting_environment, scripting_environment,
restrictions, restrictions,
maneuver_overrides, maneuver_overrides,
@ -218,6 +230,8 @@ BOOST_AUTO_TEST_CASE(street_name_changes)
std::unordered_set<NodeID> barrier_nodes; std::unordered_set<NodeID> barrier_nodes;
TrafficFlowControlNodes traffic_lights; TrafficFlowControlNodes traffic_lights;
TrafficFlowControlNodes stop_signs;
TrafficFlowControlNodes give_way_signs;
std::vector<NodeBasedEdgeAnnotation> annotations(2); std::vector<NodeBasedEdgeAnnotation> annotations(2);
std::vector<TurnRestriction> restrictions; std::vector<TurnRestriction> restrictions;
CompressedEdgeContainer container; CompressedEdgeContainer container;
@ -236,6 +250,8 @@ BOOST_AUTO_TEST_CASE(street_name_changes)
compressor.Compress(barrier_nodes, compressor.Compress(barrier_nodes,
traffic_lights, traffic_lights,
stop_signs,
give_way_signs,
scripting_environment, scripting_environment,
restrictions, restrictions,
maneuver_overrides, maneuver_overrides,
@ -256,6 +272,8 @@ BOOST_AUTO_TEST_CASE(direction_changes)
std::unordered_set<NodeID> barrier_nodes; std::unordered_set<NodeID> barrier_nodes;
TrafficFlowControlNodes traffic_lights; TrafficFlowControlNodes traffic_lights;
TrafficFlowControlNodes stop_signs;
TrafficFlowControlNodes give_way_signs;
std::vector<NodeBasedEdgeAnnotation> annotations(1); std::vector<NodeBasedEdgeAnnotation> annotations(1);
std::vector<TurnRestriction> restrictions; std::vector<TurnRestriction> restrictions;
CompressedEdgeContainer container; CompressedEdgeContainer container;
@ -270,6 +288,8 @@ BOOST_AUTO_TEST_CASE(direction_changes)
Graph graph(5, edges); Graph graph(5, edges);
compressor.Compress(barrier_nodes, compressor.Compress(barrier_nodes,
traffic_lights, traffic_lights,
stop_signs,
give_way_signs,
scripting_environment, scripting_environment,
restrictions, restrictions,
maneuver_overrides, maneuver_overrides,

View File

@ -20,6 +20,9 @@ BOOST_AUTO_TEST_CASE(simple_intersection_connectivity)
{ {
std::unordered_set<NodeID> barrier_nodes{6}; std::unordered_set<NodeID> barrier_nodes{6};
TrafficFlowControlNodes traffic_lights; TrafficFlowControlNodes traffic_lights;
TrafficFlowControlNodes stop_signs;
TrafficFlowControlNodes give_way_signs;
std::vector<NodeBasedEdgeAnnotation> annotations{ std::vector<NodeBasedEdgeAnnotation> annotations{
{EMPTY_NAMEID, 0, INAVLID_CLASS_DATA, TRAVEL_MODE_DRIVING, false}, {EMPTY_NAMEID, 0, INAVLID_CLASS_DATA, TRAVEL_MODE_DRIVING, false},
{EMPTY_NAMEID, 1, INAVLID_CLASS_DATA, TRAVEL_MODE_DRIVING, false}}; {EMPTY_NAMEID, 1, INAVLID_CLASS_DATA, TRAVEL_MODE_DRIVING, false}};
@ -87,6 +90,8 @@ BOOST_AUTO_TEST_CASE(simple_intersection_connectivity)
GraphCompressor().Compress(barrier_nodes, GraphCompressor().Compress(barrier_nodes,
traffic_lights, traffic_lights,
stop_signs,
give_way_signs,
scripting_environment, scripting_environment,
restrictions, restrictions,
maneuver_overrides, maneuver_overrides,
@ -153,6 +158,8 @@ BOOST_AUTO_TEST_CASE(roundabout_intersection_connectivity)
{ {
std::unordered_set<NodeID> barrier_nodes; std::unordered_set<NodeID> barrier_nodes;
TrafficFlowControlNodes traffic_lights; TrafficFlowControlNodes traffic_lights;
TrafficFlowControlNodes stop_signs;
TrafficFlowControlNodes give_way_signs;
std::vector<NodeBasedEdgeAnnotation> annotations; std::vector<NodeBasedEdgeAnnotation> annotations;
std::vector<TurnRestriction> restrictions; std::vector<TurnRestriction> restrictions;
CompressedEdgeContainer container; CompressedEdgeContainer container;
@ -210,6 +217,8 @@ BOOST_AUTO_TEST_CASE(roundabout_intersection_connectivity)
GraphCompressor().Compress(barrier_nodes, GraphCompressor().Compress(barrier_nodes,
traffic_lights, traffic_lights,
stop_signs,
give_way_signs,
scripting_environment, scripting_environment,
restrictions, restrictions,
maneuver_overrides, maneuver_overrides,
@ -260,6 +269,8 @@ BOOST_AUTO_TEST_CASE(skip_degree_two_nodes)
{ {
std::unordered_set<NodeID> barrier_nodes{1}; std::unordered_set<NodeID> barrier_nodes{1};
TrafficFlowControlNodes traffic_lights = {{2}, {}}; TrafficFlowControlNodes traffic_lights = {{2}, {}};
TrafficFlowControlNodes stop_signs = {};
TrafficFlowControlNodes give_way_signs = {};
std::vector<NodeBasedEdgeAnnotation> annotations(1); std::vector<NodeBasedEdgeAnnotation> annotations(1);
std::vector<TurnRestriction> restrictions; std::vector<TurnRestriction> restrictions;
CompressedEdgeContainer container; CompressedEdgeContainer container;
@ -309,6 +320,8 @@ BOOST_AUTO_TEST_CASE(skip_degree_two_nodes)
GraphCompressor().Compress(barrier_nodes, GraphCompressor().Compress(barrier_nodes,
traffic_lights, traffic_lights,
stop_signs,
give_way_signs,
scripting_environment, scripting_environment,
restrictions, restrictions,
maneuver_overrides, maneuver_overrides,