Use global uturns parameter.
Instead of previously per-via settings like uturns=true;false;true;; it now only supports a global setting uturns=true.
This commit is contained in:
@@ -60,10 +60,10 @@ struct RouteParameters : public BaseParameters
|
||||
const bool alternatives_,
|
||||
const GeometriesType geometries_,
|
||||
const OverviewType overview_,
|
||||
std::vector<boost::optional<bool>> uturns_,
|
||||
boost::optional<bool> uturns_,
|
||||
Args... args_)
|
||||
: BaseParameters{std::forward<Args>(args_)...}, steps{steps_}, alternatives{alternatives_},
|
||||
geometries{geometries_}, overview{overview_}, uturns{std::move(uturns_)}
|
||||
geometries{geometries_}, overview{overview_}, uturns{uturns_}
|
||||
{
|
||||
}
|
||||
|
||||
@@ -71,12 +71,11 @@ struct RouteParameters : public BaseParameters
|
||||
bool alternatives = true;
|
||||
GeometriesType geometries = GeometriesType::Polyline;
|
||||
OverviewType overview = OverviewType::Simplified;
|
||||
std::vector<boost::optional<bool>> uturns;
|
||||
boost::optional<bool> uturns;
|
||||
|
||||
bool IsValid() const
|
||||
{
|
||||
return coordinates.size() >= 2 && BaseParameters::IsValid() &&
|
||||
(uturns.empty() || uturns.size() == coordinates.size());
|
||||
return coordinates.size() >= 2 && BaseParameters::IsValid();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -240,11 +240,9 @@ class ShortestPathRouting final
|
||||
static const constexpr bool UTURN_DEFAULT = false;
|
||||
|
||||
void operator()(const std::vector<PhantomNodes> &phantom_nodes_vector,
|
||||
const std::vector<boost::optional<bool>> &uturn_indicators,
|
||||
const boost::optional<bool> uturns,
|
||||
InternalRouteResult &raw_route_data) const
|
||||
{
|
||||
BOOST_ASSERT(uturn_indicators.empty() ||
|
||||
uturn_indicators.size() == phantom_nodes_vector.size() + 1);
|
||||
engine_working_data.InitializeOrClearFirstThreadLocalStorage(
|
||||
super::facade->GetNumberOfNodes());
|
||||
engine_working_data.InitializeOrClearSecondThreadLocalStorage(
|
||||
@@ -270,7 +268,7 @@ class ShortestPathRouting final
|
||||
std::vector<NodeID> total_packed_path_to_reverse;
|
||||
std::vector<std::size_t> packed_leg_to_reverse_begin;
|
||||
|
||||
const bool use_uturn_indicators = !uturn_indicators.empty();
|
||||
const bool allow_u_turn_at_via = uturns ? *uturns : UTURN_DEFAULT;
|
||||
|
||||
std::size_t current_leg = 0;
|
||||
// this implements a dynamic program that finds the shortest route through
|
||||
@@ -286,12 +284,6 @@ class ShortestPathRouting final
|
||||
const auto &source_phantom = phantom_node_pair.source_phantom;
|
||||
const auto &target_phantom = phantom_node_pair.target_phantom;
|
||||
|
||||
const bool use_uturn_default =
|
||||
!use_uturn_indicators || !uturn_indicators[current_leg + 1];
|
||||
const bool allow_u_turn_at_via =
|
||||
(use_uturn_default && UTURN_DEFAULT) ||
|
||||
(!use_uturn_default && *uturn_indicators[current_leg + 1]);
|
||||
|
||||
bool search_to_forward_node = target_phantom.forward_node_id != SPECIAL_NODEID;
|
||||
bool search_to_reverse_node = target_phantom.reverse_node_id != SPECIAL_NODEID;
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ struct RouteParametersGrammar : public BaseParametersGrammar
|
||||
using AlternativeT = bool;
|
||||
using GeometriesT = engine::api::RouteParameters::GeometriesType;
|
||||
using OverviewT = engine::api::RouteParameters::OverviewType;
|
||||
using UturnsT = std::vector<boost::optional<bool>>;
|
||||
using UturnsT = bool;
|
||||
|
||||
RouteParametersGrammar() : BaseParametersGrammar(root_rule, parameters)
|
||||
{
|
||||
@@ -72,9 +72,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=") >> -qi::bool_ % ";";
|
||||
uturns_rule = qi::lit("uturns=default") | (qi::lit("uturns=") >> qi::bool_)[set_uturns];
|
||||
route_rule = steps_rule[set_steps] | alternatives_rule[set_alternatives] | geometries_rule |
|
||||
overview_rule | uturns_rule[set_uturns];
|
||||
overview_rule | uturns_rule;
|
||||
|
||||
root_rule =
|
||||
query_rule >> -qi::lit(".json") >> -(qi::lit("?") >> (route_rule | base_rule) % '&');
|
||||
|
||||
Reference in New Issue
Block a user