uturns -> continue_straight
This commit is contained in:
parent
d6407e5095
commit
589767fe6d
@ -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 |
|
||||
|
@ -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<bool> uturns_,
|
||||
const boost::optional<bool> continue_straight_,
|
||||
Args... args_)
|
||||
: BaseParameters{std::forward<Args>(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<bool> uturns;
|
||||
boost::optional<bool> continue_straight;
|
||||
|
||||
bool IsValid() const { return coordinates.size() >= 2 && BaseParameters::IsValid(); }
|
||||
};
|
||||
|
@ -144,7 +144,7 @@ class BaseDataFacade
|
||||
|
||||
virtual std::string GetTimestamp() const = 0;
|
||||
|
||||
virtual bool GetUTurnsDefault() const = 0;
|
||||
virtual bool GetContinueStraightDefault() const = 0;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -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; }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -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; }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -245,10 +245,10 @@ class ShortestPathRouting final
|
||||
}
|
||||
|
||||
void operator()(const std::vector<PhantomNodes> &phantom_nodes_vector,
|
||||
const boost::optional<bool> uturns,
|
||||
const boost::optional<bool> 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,
|
||||
|
@ -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;
|
||||
};
|
||||
}
|
||||
|
@ -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<Iterator> root_rule;
|
||||
qi::rule<Iterator> route_rule, geometries_rule, overview_rule;
|
||||
qi::rule<Iterator, UturnsT()> uturns_rule;
|
||||
qi::rule<Iterator, UturnsT()> continue_straight_rule;
|
||||
qi::rule<Iterator, StepsT()> steps_rule;
|
||||
qi::rule<Iterator, AlternativeT()> alternatives_rule;
|
||||
};
|
||||
|
@ -94,7 +94,7 @@ surface_speeds = {
|
||||
properties.traffic_signal_penalty = 2
|
||||
properties.use_turn_restrictions = false
|
||||
properties.u_turn_penalty = 20
|
||||
properties.allow_u_turn_at_via = true
|
||||
properties.continue_straight_at_waypoint = false
|
||||
|
||||
local obey_oneway = true
|
||||
local ignore_areas = true
|
||||
|
@ -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
|
||||
|
||||
|
@ -67,7 +67,7 @@ leisure_speeds = {
|
||||
properties.traffic_signal_penalty = 2
|
||||
properties.u_turn_penalty = 2
|
||||
properties.use_turn_restrictions = false
|
||||
properties.allow_u_turn_at_via = true
|
||||
properties.continue_straight_at_waypoint = false
|
||||
|
||||
local fallback_names = true
|
||||
|
||||
|
@ -16,7 +16,7 @@ speed_profile = {
|
||||
|
||||
-- these settings are read directly by osrm
|
||||
|
||||
properties.allow_u_turn_at_via = false
|
||||
properties.continue_straight_at_waypoint = true
|
||||
properties.use_turn_restrictions = true
|
||||
properties.traffic_signal_penalty = 7 -- seconds
|
||||
properties.u_turn_penalty = 20
|
||||
|
@ -135,7 +135,7 @@ InternalRouteResult TripPlugin::ComputeRoute(const std::vector<PhantomNode> &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;
|
||||
|
@ -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
|
||||
|
@ -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_<std::vector<std::string>>("vector")
|
||||
.def("Add", static_cast<void (std::vector<std::string>::*)(const std::string &)>(
|
||||
|
@ -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
|
||||
|
@ -87,8 +87,8 @@ BOOST_AUTO_TEST_CASE(invalid_route_urls)
|
||||
testInvalidOptions<engine::api::RouteParameters>("1,2;3,4?overview=false&bearings=foo"),
|
||||
32UL);
|
||||
BOOST_CHECK_EQUAL(
|
||||
testInvalidOptions<engine::api::RouteParameters>("1,2;3,4?overview=false&uturns=foo"),
|
||||
30UL);
|
||||
testInvalidOptions<engine::api::RouteParameters>("1,2;3,4?overview=false&continue_straight=foo"),
|
||||
41UL);
|
||||
BOOST_CHECK_EQUAL(
|
||||
testInvalidOptions<engine::api::RouteParameters>("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<engine::api::RouteParameters>(
|
||||
"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);
|
||||
|
Loading…
Reference in New Issue
Block a user