From c6b0d479912616f5bd75db0aa1a47efe4e761ecc Mon Sep 17 00:00:00 2001 From: Huyen Chau Nguyen Date: Wed, 24 Jan 2018 18:14:20 -0500 Subject: [PATCH] add is_stop to ExtractionTurn, expose it to lua's process_turn and add tests testing intersection node tags --- .../options/extract/turn_function.feature | 42 +++++++++++++++++++ include/extractor/extraction_turn.hpp | 5 ++- src/extractor/edge_based_graph_factory.cpp | 1 + src/extractor/graph_compressor.cpp | 1 + src/extractor/scripting_environment_lua.cpp | 2 + 5 files changed, 49 insertions(+), 2 deletions(-) diff --git a/features/options/extract/turn_function.feature b/features/options/extract/turn_function.feature index 897c1187cdf..ed4f28351c6 100644 --- a/features/options/extract/turn_function.feature +++ b/features/options/extract/turn_function.feature @@ -43,6 +43,7 @@ Feature: Turn Function Information end function print_turn (profile, turn) + print ('is_stop ' .. string.format("%s", tostring(turn.is_stop))) print ('source_restricted ' .. string.format("%s", tostring(turn.source_restricted))) print ('source_is_motorway ' .. string.format("%s", tostring(turn.source_is_motorway))) print ('source_is_link ' .. string.format("%s", tostring(turn.source_is_link))) @@ -173,4 +174,45 @@ Feature: Turn Function Information + Scenario: Turns should show if intersection node is tagged with highway=stop + Given the node map + """ + a-b-c + """ + And the ways + | nodes | oneway | + | ab | yes | + | bc | yes | + And the nodes + | node | highway | + | b | stop | + + And the data has been saved to disk + + When I run "osrm-extract --profile {profile_file} {osm_file}" + Then it should exit successfully + And stdout should contain "is_stop true" + + + Scenario: Turns should not claim there is stop if there is not + Given the node map + """ + a-b-c + """ + And the ways + | nodes | oneway | + | ab | yes | + | bc | yes | + And the nodes + | node | highway | + | b | - | + + And the data has been saved to disk + + When I run "osrm-extract --profile {profile_file} {osm_file}" + Then it should exit successfully + And stdout should contain "is_stop false" + + + diff --git a/include/extractor/extraction_turn.hpp b/include/extractor/extraction_turn.hpp index 24624f489a6..d918f68b929 100644 --- a/include/extractor/extraction_turn.hpp +++ b/include/extractor/extraction_turn.hpp @@ -49,11 +49,11 @@ struct ExtractionTurn bool is_u_turn, bool has_traffic_light, bool is_left_hand_driving, + bool is_stop, bool source_restricted, 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, @@ -69,7 +69,7 @@ struct ExtractionTurn const std::vector &roads_on_the_right, const std::vector &roads_on_the_left) : angle(180. - angle), number_of_roads(number_of_roads), is_u_turn(is_u_turn), - has_traffic_light(has_traffic_light), is_left_hand_driving(is_left_hand_driving), + has_traffic_light(has_traffic_light), is_left_hand_driving(is_left_hand_driving), is_stop(is_stop), source_restricted(source_restricted), source_mode(source_mode), source_is_motorway(source_is_motorway), source_is_link(source_is_link), @@ -95,6 +95,7 @@ struct ExtractionTurn const bool is_u_turn; const bool has_traffic_light; const bool is_left_hand_driving; + const bool is_stop; // source info const bool source_restricted; diff --git a/src/extractor/edge_based_graph_factory.cpp b/src/extractor/edge_based_graph_factory.cpp index 62682654b99..7d9c24df1c0 100644 --- a/src/extractor/edge_based_graph_factory.cpp +++ b/src/extractor/edge_based_graph_factory.cpp @@ -610,6 +610,7 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges( is_traffic_light, m_edge_based_node_container.GetAnnotation(edge_data1.annotation_data) .is_left_hand_driving, + false, // @CHAUTODO is_stop // source info edge_data1.flags.restricted, m_edge_based_node_container.GetAnnotation(edge_data1.annotation_data).travel_mode, diff --git a/src/extractor/graph_compressor.cpp b/src/extractor/graph_compressor.cpp index 3b147b51592..603e93b8770 100644 --- a/src/extractor/graph_compressor.cpp +++ b/src/extractor/graph_compressor.cpp @@ -228,6 +228,7 @@ void GraphCompressor::Compress( true, false, false, + false, TRAVEL_MODE_DRIVING, false, false, diff --git a/src/extractor/scripting_environment_lua.cpp b/src/extractor/scripting_environment_lua.cpp index e446d587c6e..6f3bd9752d9 100644 --- a/src/extractor/scripting_environment_lua.cpp +++ b/src/extractor/scripting_environment_lua.cpp @@ -709,6 +709,8 @@ void Sol2ScriptingEnvironment::InitContext(LuaScriptingContext &context) &ExtractionTurn::has_traffic_light, "is_left_hand_driving", &ExtractionTurn::is_left_hand_driving, + "is_stop", + &ExtractionTurn::is_stop, "source_restricted", &ExtractionTurn::source_restricted,