diff --git a/features/testbot/uturn.feature b/features/testbot/uturn.feature deleted file mode 100644 index 27ae5a482..000000000 --- a/features/testbot/uturn.feature +++ /dev/null @@ -1,92 +0,0 @@ -@routing @uturn @via @testbot -Feature: U-turns at via points - - Background: - Given the profile "testbot" - - Scenario: U-turns at via points disabled by default - Given the node map - | a | b | c | d | - | | e | f | g | - - And the ways - | nodes | - | ab | - | bc | - | cd | - | be | - | dg | - | ef | - | fg | - - When I route I should get - | waypoints | route | - | a,e,c | ab,be,be,ef,fg,dg,cd,cd | - - Scenario: Query param to allow U-turns at all via points - Given the node map - | a | b | c | d | - | | e | f | g | - - And the query options - | uturns | true | - - And the ways - | nodes | - | ab | - | bc | - | cd | - | be | - | dg | - | ef | - | fg | - - When I route I should get - | waypoints | route | - | a,e,c | ab,be,be,be,bc,bc | - - Scenario: Instructions at via points at u-turns - Given the node map - | a | b | c | d | - | | e | f | g | - - And the query options - | uturns | true | - - And the ways - | nodes | - | ab | - | bc | - | cd | - | be | - | dg | - | ef | - | fg | - - When I route I should get - | waypoints | route | - | a,e,c | ab,be,be,be,bc,bc | - - Scenario: u-turn mixed with non-uturn vias - Given the node map - | a | 1 | b | 3 | c | 5 | d | - | | | 2 | | | | 4 | - | | | e | | f | | g | - - And the query options - | uturns | true | - - And the ways - | nodes | oneway | - | ab | no | - | bc | no | - | cd | no | - | be | yes | - | dg | no | - | ef | no | - | fg | no | - - When I route I should get - | waypoints | route | - | 1,2,3,4,5 | ab,be,be,be,ef,fg,dg,cd,bc,bc,bc,cd,dg,dg,dg,cd,cd | - diff --git a/include/engine/api/route_parameters.hpp b/include/engine/api/route_parameters.hpp index 7c97e61bd..59040205a 100644 --- a/include/engine/api/route_parameters.hpp +++ b/include/engine/api/route_parameters.hpp @@ -48,7 +48,7 @@ namespace api * - geometries: route geometry encoded in Polyline or GeoJSON * - overview: adds overview geometry either Full, Simplified (according to highest zoom level) or * False (not at all) - * - uturns: enable or disable uturns (disabled by default) + * - continue_straight: enable or disable continue_straight (disabled by default) * * \see OSRM, Coordinate, Hint, Bearing, RouteParame, RouteParameters, TableParameters, * NearestParameters, TripParameters, MatchParameters and TileParameters @@ -74,10 +74,10 @@ struct RouteParameters : public BaseParameters const bool alternatives_, const GeometriesType geometries_, const OverviewType overview_, - const boost::optional uturns_, + const boost::optional continue_straight_, Args... args_) : BaseParameters{std::forward(args_)...}, steps{steps_}, alternatives{alternatives_}, - geometries{geometries_}, overview{overview_}, uturns{uturns_} + geometries{geometries_}, overview{overview_}, continue_straight{continue_straight_} { } @@ -85,7 +85,7 @@ struct RouteParameters : public BaseParameters bool alternatives = false; GeometriesType geometries = GeometriesType::Polyline; OverviewType overview = OverviewType::Simplified; - boost::optional uturns; + boost::optional continue_straight; bool IsValid() const { return coordinates.size() >= 2 && BaseParameters::IsValid(); } }; diff --git a/include/engine/datafacade/datafacade_base.hpp b/include/engine/datafacade/datafacade_base.hpp index f4cb0c47a..1f608d947 100644 --- a/include/engine/datafacade/datafacade_base.hpp +++ b/include/engine/datafacade/datafacade_base.hpp @@ -144,7 +144,7 @@ class BaseDataFacade virtual std::string GetTimestamp() const = 0; - virtual bool GetUTurnsDefault() const = 0; + virtual bool GetContinueStraightDefault() const = 0; }; } } diff --git a/include/engine/datafacade/internal_datafacade.hpp b/include/engine/datafacade/internal_datafacade.hpp index 302af30cc..bda4869b8 100644 --- a/include/engine/datafacade/internal_datafacade.hpp +++ b/include/engine/datafacade/internal_datafacade.hpp @@ -649,7 +649,7 @@ class InternalDataFacade final : public BaseDataFacade std::string GetTimestamp() const override final { return m_timestamp; } - bool GetUTurnsDefault() const override final { return m_profile_properties.allow_u_turn_at_via; } + bool GetContinueStraightDefault() const override final { return m_profile_properties.continue_straight_at_waypoint; } }; } } diff --git a/include/engine/datafacade/shared_datafacade.hpp b/include/engine/datafacade/shared_datafacade.hpp index bd365653c..bd70e835e 100644 --- a/include/engine/datafacade/shared_datafacade.hpp +++ b/include/engine/datafacade/shared_datafacade.hpp @@ -709,7 +709,7 @@ class SharedDataFacade final : public BaseDataFacade std::string GetTimestamp() const override final { return m_timestamp; } - bool GetUTurnsDefault() const override final { return m_profile_properties->allow_u_turn_at_via; } + bool GetContinueStraightDefault() const override final { return m_profile_properties->continue_straight_at_waypoint; } }; } } diff --git a/include/engine/routing_algorithms/shortest_path.hpp b/include/engine/routing_algorithms/shortest_path.hpp index 0d3d0be32..7b8fd7c6b 100644 --- a/include/engine/routing_algorithms/shortest_path.hpp +++ b/include/engine/routing_algorithms/shortest_path.hpp @@ -245,10 +245,10 @@ class ShortestPathRouting final } void operator()(const std::vector &phantom_nodes_vector, - const boost::optional uturns, + const boost::optional continue_straight_at_waypoint, InternalRouteResult &raw_route_data) const { - const bool allow_u_turn_at_via = uturns ? *uturns : super::facade->GetUTurnsDefault(); + const bool allow_uturn_at_waypoint = !(continue_straight_at_waypoint ? *continue_straight_at_waypoint : super::facade->GetContinueStraightDefault()); engine_working_data.InitializeOrClearFirstThreadLocalStorage( super::facade->GetNumberOfNodes()); @@ -299,7 +299,7 @@ class ShortestPathRouting final if (search_to_reverse_node || search_to_forward_node) { - if (allow_u_turn_at_via) + if (allow_uturn_at_waypoint) { SearchWithUTurn(forward_heap, reverse_heap, forward_core_heap, reverse_core_heap, search_from_forward_node, diff --git a/include/extractor/profile_properties.hpp b/include/extractor/profile_properties.hpp index 859034c91..79768754f 100644 --- a/include/extractor/profile_properties.hpp +++ b/include/extractor/profile_properties.hpp @@ -11,7 +11,7 @@ namespace extractor struct ProfileProperties { ProfileProperties() - : traffic_signal_penalty(0), u_turn_penalty(0), allow_u_turn_at_via(false), use_turn_restrictions(false) + : traffic_signal_penalty(0), u_turn_penalty(0), continue_straight_at_waypoint(true), use_turn_restrictions(false) { } @@ -39,7 +39,7 @@ struct ProfileProperties int traffic_signal_penalty; //! penalty to do a uturn in deci-seconds int u_turn_penalty; - bool allow_u_turn_at_via; + bool continue_straight_at_waypoint; bool use_turn_restrictions; }; } diff --git a/include/server/api/route_parameters_grammar.hpp b/include/server/api/route_parameters_grammar.hpp index 4102d639e..d4280df44 100644 --- a/include/server/api/route_parameters_grammar.hpp +++ b/include/server/api/route_parameters_grammar.hpp @@ -47,7 +47,7 @@ struct RouteParametersGrammar : public BaseParametersGrammar const auto set_alternatives = [this](const AlternativeT alternatives) { parameters.alternatives = alternatives; }; - const auto set_uturns = [this](UturnsT uturns) { parameters.uturns = std::move(uturns); }; + const auto set_continue_straight = [this](UturnsT continue_straight) { parameters.continue_straight = std::move(continue_straight); }; alternatives_rule = qi::lit("alternatives=") > qi::bool_; steps_rule = qi::lit("steps=") > qi::bool_; @@ -56,9 +56,9 @@ struct RouteParametersGrammar : public BaseParametersGrammar overview_rule = qi::lit("overview=simplified")[set_simplified_type] | qi::lit("overview=full")[set_full_type] | qi::lit("overview=false")[set_false_type]; - uturns_rule = qi::lit("uturns=default") | (qi::lit("uturns=") > qi::bool_)[set_uturns]; + continue_straight_rule = qi::lit("continue_straight=default") | (qi::lit("continue_straight=") > qi::bool_)[set_continue_straight]; route_rule = steps_rule[set_steps] | alternatives_rule[set_alternatives] | geometries_rule | - overview_rule | uturns_rule; + overview_rule | continue_straight_rule; root_rule = query_rule > -qi::lit(".json") > -(qi::lit("?") > (route_rule | base_rule) % '&'); @@ -69,7 +69,7 @@ struct RouteParametersGrammar : public BaseParametersGrammar private: qi::rule root_rule; qi::rule route_rule, geometries_rule, overview_rule; - qi::rule uturns_rule; + qi::rule continue_straight_rule; qi::rule steps_rule; qi::rule alternatives_rule; }; diff --git a/profiles/bicycle.lua b/profiles/bicycle.lua index 426929226..84e02d8ce 100644 --- a/profiles/bicycle.lua +++ b/profiles/bicycle.lua @@ -91,10 +91,10 @@ surface_speeds = { } -- these need to be global because they are accesed externaly -properties.traffic_signal_penalty = 2 -properties.use_turn_restrictions = false -properties.u_turn_penalty = 20 -properties.allow_u_turn_at_via = true +properties.traffic_signal_penalty = 2 +properties.use_turn_restrictions = false +properties.u_turn_penalty = 20 +properties.continue_straight_at_waypoint = false local obey_oneway = true local ignore_areas = true diff --git a/profiles/car.lua b/profiles/car.lua index db1b56520..4033f315a 100644 --- a/profiles/car.lua +++ b/profiles/car.lua @@ -132,6 +132,7 @@ maxspeed_table = { properties.u_turn_penalty = 20 properties.traffic_signal_penalty = 2 properties.use_turn_restrictions = true +properties.continue_straight_at_waypoint = true local side_road_speed_multiplier = 0.8 diff --git a/profiles/foot.lua b/profiles/foot.lua index 120f35e77..04f16c2a2 100644 --- a/profiles/foot.lua +++ b/profiles/foot.lua @@ -64,10 +64,10 @@ leisure_speeds = { ["track"] = walking_speed } -properties.traffic_signal_penalty = 2 -properties.u_turn_penalty = 2 -properties.use_turn_restrictions = false -properties.allow_u_turn_at_via = true +properties.traffic_signal_penalty = 2 +properties.u_turn_penalty = 2 +properties.use_turn_restrictions = false +properties.continue_straight_at_waypoint = false local fallback_names = true diff --git a/profiles/testbot.lua b/profiles/testbot.lua index aecffae35..8bad8100c 100644 --- a/profiles/testbot.lua +++ b/profiles/testbot.lua @@ -16,10 +16,10 @@ speed_profile = { -- these settings are read directly by osrm -properties.allow_u_turn_at_via = false -properties.use_turn_restrictions = true -properties.traffic_signal_penalty = 7 -- seconds -properties.u_turn_penalty = 20 +properties.continue_straight_at_waypoint = true +properties.use_turn_restrictions = true +properties.traffic_signal_penalty = 7 -- seconds +properties.u_turn_penalty = 20 function limit_speed(speed, limits) -- don't use ipairs(), since it stops at the first nil value diff --git a/src/engine/plugins/trip.cpp b/src/engine/plugins/trip.cpp index c834f4618..35c651440 100644 --- a/src/engine/plugins/trip.cpp +++ b/src/engine/plugins/trip.cpp @@ -135,7 +135,7 @@ InternalRouteResult TripPlugin::ComputeRoute(const std::vector &sna } BOOST_ASSERT(min_route.segment_end_coordinates.size() == trip.size()); - shortest_path(min_route.segment_end_coordinates, parameters.uturns, min_route); + shortest_path(min_route.segment_end_coordinates, parameters.continue_straight, min_route); BOOST_ASSERT_MSG(min_route.shortest_path_length < INVALID_EDGE_WEIGHT, "unroutable route"); return min_route; diff --git a/src/engine/plugins/viaroute.cpp b/src/engine/plugins/viaroute.cpp index ffd62b35b..748151ae6 100644 --- a/src/engine/plugins/viaroute.cpp +++ b/src/engine/plugins/viaroute.cpp @@ -58,24 +58,26 @@ Status ViaRoutePlugin::HandleRequest(const api::RouteParameters &route_parameter auto snapped_phantoms = SnapPhantomNodes(phantom_node_pairs); - const bool allow_u_turn_at_via = - route_parameters.uturns ? *route_parameters.uturns : facade.GetUTurnsDefault(); + const bool continue_straight_at_waypoint = route_parameters.continue_straight + ? *route_parameters.continue_straight + : facade.GetContinueStraightDefault(); InternalRouteResult raw_route; - auto build_phantom_pairs = [&raw_route, allow_u_turn_at_via](const PhantomNode &first_node, - const PhantomNode &second_node) + auto build_phantom_pairs = [&raw_route, continue_straight_at_waypoint]( + const PhantomNode &first_node, const PhantomNode &second_node) { raw_route.segment_end_coordinates.push_back(PhantomNodes{first_node, second_node}); auto &last_inserted = raw_route.segment_end_coordinates.back(); // enable forward direction if possible if (last_inserted.source_phantom.forward_segment_id.id != SPECIAL_SEGMENTID) { - last_inserted.source_phantom.forward_segment_id.enabled |= allow_u_turn_at_via; + last_inserted.source_phantom.forward_segment_id.enabled |= + !continue_straight_at_waypoint; } // enable reverse direction if possible if (last_inserted.source_phantom.reverse_segment_id.id != SPECIAL_SEGMENTID) { - last_inserted.source_phantom.reverse_segment_id.enabled |= allow_u_turn_at_via; + last_inserted.source_phantom.reverse_segment_id.enabled |= !continue_straight_at_waypoint; } }; util::for_each_pair(snapped_phantoms, build_phantom_pairs); @@ -93,7 +95,7 @@ Status ViaRoutePlugin::HandleRequest(const api::RouteParameters &route_parameter } else { - shortest_path(raw_route.segment_end_coordinates, route_parameters.uturns, raw_route); + shortest_path(raw_route.segment_end_coordinates, route_parameters.continue_straight, raw_route); } // we can only know this after the fact, different SCC ids still diff --git a/src/extractor/scripting_environment.cpp b/src/extractor/scripting_environment.cpp index 53cc8e189..e3f9b6e45 100644 --- a/src/extractor/scripting_environment.cpp +++ b/src/extractor/scripting_environment.cpp @@ -101,7 +101,7 @@ void ScriptingEnvironment::InitContext(ScriptingEnvironment::Context &context) .property("u_turn_penalty", &ProfileProperties::GetUturnPenalty, &ProfileProperties::SetUturnPenalty) .def_readwrite("use_turn_restrictions", &ProfileProperties::use_turn_restrictions) - .def_readwrite("allow_u_turn_at_via", &ProfileProperties::allow_u_turn_at_via), + .def_readwrite("continue_straight_at_waypoint", &ProfileProperties::continue_straight_at_waypoint), luabind::class_>("vector") .def("Add", static_cast::*)(const std::string &)>( diff --git a/unit_tests/mocks/mock_datafacade.hpp b/unit_tests/mocks/mock_datafacade.hpp index cb05a9443..f608b66dc 100644 --- a/unit_tests/mocks/mock_datafacade.hpp +++ b/unit_tests/mocks/mock_datafacade.hpp @@ -170,7 +170,7 @@ class MockDataFacade final : public engine::datafacade::BaseDataFacade std::string GetNameForID(const unsigned /* name_id */) const override { return ""; } std::size_t GetCoreSize() const override { return 0; } std::string GetTimestamp() const override { return ""; } - bool GetUTurnsDefault() const override { return true; } + bool GetContinueStraightDefault() const override { return true; } }; } // ns test } // ns osrm diff --git a/unit_tests/server/parameters_parser.cpp b/unit_tests/server/parameters_parser.cpp index b2a42dd99..1b5161f71 100644 --- a/unit_tests/server/parameters_parser.cpp +++ b/unit_tests/server/parameters_parser.cpp @@ -87,8 +87,8 @@ BOOST_AUTO_TEST_CASE(invalid_route_urls) testInvalidOptions("1,2;3,4?overview=false&bearings=foo"), 32UL); BOOST_CHECK_EQUAL( - testInvalidOptions("1,2;3,4?overview=false&uturns=foo"), - 30UL); + testInvalidOptions("1,2;3,4?overview=false&continue_straight=foo"), + 41UL); BOOST_CHECK_EQUAL( testInvalidOptions("1,2;3,4?overview=false&radiuses=foo"), 32UL); @@ -133,7 +133,7 @@ BOOST_AUTO_TEST_CASE(valid_route_urls) BOOST_CHECK_EQUAL(reference_1.alternatives, result_1->alternatives); BOOST_CHECK_EQUAL(reference_1.geometries, result_1->geometries); BOOST_CHECK_EQUAL(reference_1.overview, result_1->overview); - BOOST_CHECK_EQUAL(reference_1.uturns, result_1->uturns); + BOOST_CHECK_EQUAL(reference_1.continue_straight, result_1->continue_straight); CHECK_EQUAL_RANGE(reference_1.bearings, result_1->bearings); CHECK_EQUAL_RANGE(reference_1.radiuses, result_1->radiuses); CHECK_EQUAL_RANGE(reference_1.coordinates, result_1->coordinates); @@ -149,7 +149,7 @@ BOOST_AUTO_TEST_CASE(valid_route_urls) BOOST_CHECK_EQUAL(reference_2.alternatives, result_2->alternatives); BOOST_CHECK_EQUAL(reference_2.geometries, result_2->geometries); BOOST_CHECK_EQUAL(reference_2.overview, result_2->overview); - BOOST_CHECK_EQUAL(reference_2.uturns, result_2->uturns); + BOOST_CHECK_EQUAL(reference_2.continue_straight, result_2->continue_straight); CHECK_EQUAL_RANGE(reference_2.bearings, result_2->bearings); CHECK_EQUAL_RANGE(reference_2.radiuses, result_2->radiuses); CHECK_EQUAL_RANGE(reference_2.coordinates, result_2->coordinates); @@ -159,13 +159,13 @@ BOOST_AUTO_TEST_CASE(valid_route_urls) engine::api::RouteParameters::OverviewType::False, true}; reference_3.coordinates = coords_1; auto result_3 = api::parseParameters( - "1,2;3,4?steps=false&alternatives=false&geometries=geojson&overview=false&uturns=true"); + "1,2;3,4?steps=false&alternatives=false&geometries=geojson&overview=false&continue_straight=true"); BOOST_CHECK(result_3); BOOST_CHECK_EQUAL(reference_3.steps, result_3->steps); BOOST_CHECK_EQUAL(reference_3.alternatives, result_3->alternatives); BOOST_CHECK_EQUAL(reference_3.geometries, result_3->geometries); BOOST_CHECK_EQUAL(reference_3.overview, result_3->overview); - BOOST_CHECK_EQUAL(reference_3.uturns, result_3->uturns); + BOOST_CHECK_EQUAL(reference_3.continue_straight, result_3->continue_straight); CHECK_EQUAL_RANGE(reference_3.bearings, result_3->bearings); CHECK_EQUAL_RANGE(reference_3.radiuses, result_3->radiuses); CHECK_EQUAL_RANGE(reference_3.coordinates, result_3->coordinates); @@ -199,7 +199,7 @@ BOOST_AUTO_TEST_CASE(valid_route_urls) BOOST_CHECK_EQUAL(reference_4.alternatives, result_4->alternatives); BOOST_CHECK_EQUAL(reference_4.geometries, result_4->geometries); BOOST_CHECK_EQUAL(reference_4.overview, result_4->overview); - BOOST_CHECK_EQUAL(reference_4.uturns, result_4->uturns); + BOOST_CHECK_EQUAL(reference_4.continue_straight, result_4->continue_straight); CHECK_EQUAL_RANGE(reference_4.bearings, result_4->bearings); CHECK_EQUAL_RANGE(reference_4.radiuses, result_4->radiuses); CHECK_EQUAL_RANGE(reference_4.coordinates, result_4->coordinates); @@ -223,7 +223,7 @@ BOOST_AUTO_TEST_CASE(valid_route_urls) BOOST_CHECK_EQUAL(reference_5.alternatives, result_5->alternatives); BOOST_CHECK_EQUAL(reference_5.geometries, result_5->geometries); BOOST_CHECK_EQUAL(reference_5.overview, result_5->overview); - BOOST_CHECK_EQUAL(reference_5.uturns, result_5->uturns); + BOOST_CHECK_EQUAL(reference_5.continue_straight, result_5->continue_straight); CHECK_EQUAL_RANGE(reference_5.bearings, result_5->bearings); CHECK_EQUAL_RANGE(reference_5.radiuses, result_5->radiuses); CHECK_EQUAL_RANGE(reference_5.coordinates, result_5->coordinates); @@ -241,7 +241,7 @@ BOOST_AUTO_TEST_CASE(valid_route_urls) BOOST_CHECK_EQUAL(reference_6.alternatives, result_6->alternatives); BOOST_CHECK_EQUAL(reference_6.geometries, result_6->geometries); BOOST_CHECK_EQUAL(reference_6.overview, result_6->overview); - BOOST_CHECK_EQUAL(reference_6.uturns, result_6->uturns); + BOOST_CHECK_EQUAL(reference_6.continue_straight, result_6->continue_straight); CHECK_EQUAL_RANGE(reference_6.bearings, result_6->bearings); CHECK_EQUAL_RANGE(reference_6.radiuses, result_6->radiuses); CHECK_EQUAL_RANGE(reference_6.coordinates, result_6->coordinates);