diff --git a/features/car/access.feature b/features/car/access.feature index 47ac4e3c2..c950ab11a 100644 --- a/features/car/access.feature +++ b/features/car/access.feature @@ -305,3 +305,58 @@ Feature: Car - Restricted access | primary | psv | | | primary | no | | | primary | customers | x | + + # TODO: implement this for MLD + @ch + Scenario: Car - routing over private roads (default penalty) + Given the node map + """ + a f + | | + b---1---e + | | + c-------d + """ + + And the ways + | nodes | access | + | ab | | + | bc | | + | cd | | + | de | | + | ef | | + | be | private | + + When I route I should get + | from | to | route | + | a | f | ab,bc,cd,de,ef,ef | + | a | 1 | ab,be,be | + + # TODO: implement this for MLD + @ch + Scenario: Car - routing over private roads (no penalty) + Given the node map + """ + a f + | | + b---1---e + | | + c-------d + """ + + And the ways + | nodes | access | + | ab | | + | bc | | + | cd | | + | de | | + | ef | | + | be | private | + + And the query options + | permit | private | + + When I route I should get + | from | to | route | + | a | f | ab,be,ef,ef | + | a | 1 | ab,be,be | \ No newline at end of file diff --git a/include/engine/api/base_parameters.hpp b/include/engine/api/base_parameters.hpp index 4693c67a1..e9ffbf510 100644 --- a/include/engine/api/base_parameters.hpp +++ b/include/engine/api/base_parameters.hpp @@ -69,6 +69,7 @@ struct BaseParameters std::vector> bearings; std::vector> approaches; std::vector exclude; + std::vector permit; // Adds hints to response which can be included in subsequent requests, see `hints` above. bool generate_hints = true; @@ -79,9 +80,10 @@ struct BaseParameters std::vector> bearings_ = {}, std::vector> approaches_ = {}, bool generate_hints_ = true, - std::vector exclude = {}) + std::vector exclude = {}, + std::vector permit = {}) : coordinates(coordinates_), hints(hints_), radiuses(radiuses_), bearings(bearings_), - approaches(approaches_), exclude(std::move(exclude)), generate_hints(generate_hints_) + approaches(approaches_), exclude(std::move(exclude)), permit(std::move(permit)), generate_hints(generate_hints_) { } @@ -91,6 +93,7 @@ struct BaseParameters return (hints.empty() || hints.size() == coordinates.size()) && (bearings.empty() || bearings.size() == coordinates.size()) && (radiuses.empty() || radiuses.size() == coordinates.size()) && + (permit.empty() || (permit.size() == 1 && permit.front() == "private")) && (approaches.empty() || approaches.size() == coordinates.size()) && std::all_of(bearings.begin(), bearings.end(), diff --git a/include/engine/plugins/trip.hpp b/include/engine/plugins/trip.hpp index d49126e19..54bc42fe2 100644 --- a/include/engine/plugins/trip.hpp +++ b/include/engine/plugins/trip.hpp @@ -33,7 +33,8 @@ class TripPlugin final : public BasePlugin InternalRouteResult ComputeRoute(const RoutingAlgorithmsInterface &algorithms, const std::vector &phantom_node_list, const std::vector &trip, - const bool roundtrip) const; + const bool roundtrip, + const bool permit_private) const; public: explicit TripPlugin(const int max_locations_trip_) : max_locations_trip(max_locations_trip_) {} diff --git a/include/engine/routing_algorithms.hpp b/include/engine/routing_algorithms.hpp index 5d4a8a956..f83a02bf5 100644 --- a/include/engine/routing_algorithms.hpp +++ b/include/engine/routing_algorithms.hpp @@ -25,10 +25,11 @@ class RoutingAlgorithmsInterface virtual InternalRouteResult ShortestPathSearch(const std::vector &phantom_node_pair, - const boost::optional continue_straight_at_waypoint) const = 0; + const boost::optional continue_straight_at_waypoint, + const bool permit_private) const = 0; virtual InternalRouteResult - DirectShortestPathSearch(const PhantomNodes &phantom_node_pair) const = 0; + DirectShortestPathSearch(const PhantomNodes &phantom_node_pair, const bool permit_private) const = 0; virtual std::pair, std::vector> ManyToManySearch(const std::vector &phantom_nodes, @@ -78,10 +79,11 @@ template class RoutingAlgorithms final : public RoutingAlgo InternalRouteResult ShortestPathSearch( const std::vector &phantom_node_pair, - const boost::optional continue_straight_at_waypoint) const final override; + const boost::optional continue_straight_at_waypoint, + const bool permit_private) const final override; InternalRouteResult - DirectShortestPathSearch(const PhantomNodes &phantom_nodes) const final override; + DirectShortestPathSearch(const PhantomNodes &phantom_nodes, const bool permit_private) const final override; virtual std::pair, std::vector> ManyToManySearch(const std::vector &phantom_nodes, @@ -161,17 +163,18 @@ RoutingAlgorithms::AlternativePathSearch(const PhantomNodes &phantom_ template InternalRouteResult RoutingAlgorithms::ShortestPathSearch( const std::vector &phantom_node_pair, - const boost::optional continue_straight_at_waypoint) const + const boost::optional continue_straight_at_waypoint, + const bool permit_private) const { return routing_algorithms::shortestPathSearch( - heaps, *facade, phantom_node_pair, continue_straight_at_waypoint); + heaps, *facade, phantom_node_pair, continue_straight_at_waypoint, permit_private); } template InternalRouteResult -RoutingAlgorithms::DirectShortestPathSearch(const PhantomNodes &phantom_nodes) const +RoutingAlgorithms::DirectShortestPathSearch(const PhantomNodes &phantom_nodes, const bool permit_private) const { - return routing_algorithms::directShortestPathSearch(heaps, *facade, phantom_nodes); + return routing_algorithms::directShortestPathSearch(heaps, *facade, phantom_nodes, permit_private); } template diff --git a/include/engine/routing_algorithms/direct_shortest_path.hpp b/include/engine/routing_algorithms/direct_shortest_path.hpp index 055e789a5..a4736e5ce 100644 --- a/include/engine/routing_algorithms/direct_shortest_path.hpp +++ b/include/engine/routing_algorithms/direct_shortest_path.hpp @@ -24,7 +24,8 @@ namespace routing_algorithms template InternalRouteResult directShortestPathSearch(SearchEngineData &engine_working_data, const DataFacade &facade, - const PhantomNodes &phantom_nodes); + const PhantomNodes &phantom_nodes, + const bool permit_private); } // namespace routing_algorithms } // namespace engine diff --git a/include/engine/routing_algorithms/routing_base.hpp b/include/engine/routing_algorithms/routing_base.hpp index 4afaae71f..d4243cbba 100644 --- a/include/engine/routing_algorithms/routing_base.hpp +++ b/include/engine/routing_algorithms/routing_base.hpp @@ -37,6 +37,8 @@ namespace routing_algorithms static constexpr bool FORWARD_DIRECTION = true; static constexpr bool REVERSE_DIRECTION = false; static constexpr bool DO_NOT_FORCE_LOOPS = false; +static constexpr bool PERMIT_PRIVATE = true; +static constexpr bool AVOID_PRIVATE = false; bool needsLoopForward(const PhantomNode &source_phantom, const PhantomNode &target_phantom); bool needsLoopBackwards(const PhantomNode &source_phantom, const PhantomNode &target_phantom); diff --git a/include/engine/routing_algorithms/routing_base_ch.hpp b/include/engine/routing_algorithms/routing_base_ch.hpp index 79044c8d6..a2ee2b421 100644 --- a/include/engine/routing_algorithms/routing_base_ch.hpp +++ b/include/engine/routing_algorithms/routing_base_ch.hpp @@ -52,7 +52,8 @@ template void relaxOutgoingEdges(const DataFacade &facade, const NodeID node, const EdgeWeight weight, - SearchEngineData::QueryHeap &heap) + SearchEngineData::QueryHeap &heap, + const bool permit_private) { for (const auto edge : facade.GetAdjacentEdgeRange(node)) { @@ -63,7 +64,8 @@ void relaxOutgoingEdges(const DataFacade &facade, const EdgeWeight edge_weight = data.weight; BOOST_ASSERT_MSG(edge_weight > 0, "edge_weight invalid"); - const EdgeWeight to_weight = weight + edge_weight; + const EdgeWeight to_weight = weight + edge_weight + ((!permit_private && data.maneuver_restricted) ? std::numeric_limits::max() : 0); + // const EdgeWeight to_weight = weight + edge_weight; // New Node discovered -> Add to Heap + Node Info Storage if (!heap.WasInserted(to)) @@ -120,7 +122,8 @@ void routingStep(const DataFacade &facade, EdgeWeight &upper_bound, EdgeWeight min_edge_offset, const bool force_loop_forward, - const bool force_loop_reverse) + const bool force_loop_reverse, + const bool permit_private) { const NodeID node = forward_heap.DeleteMin(); const EdgeWeight weight = forward_heap.GetKey(node); @@ -182,7 +185,7 @@ void routingStep(const DataFacade &facade, return; } - relaxOutgoingEdges(facade, node, weight, forward_heap); + relaxOutgoingEdges(facade, node, weight, forward_heap, permit_private); } template @@ -471,7 +474,8 @@ void search(SearchEngineData &engine_working_data, const bool force_loop_forward, const bool force_loop_reverse, const PhantomNodes &phantom_nodes, - const int duration_upper_bound = INVALID_EDGE_WEIGHT); + const int duration_upper_bound, + const bool permit_private); // Requires the heaps for be empty // If heaps should be adjusted to be initialized outside of this function, @@ -482,7 +486,8 @@ double getNetworkDistance(SearchEngineData &engine_working_data, SearchEngineData::QueryHeap &reverse_heap, const PhantomNode &source_phantom, const PhantomNode &target_phantom, - int duration_upper_bound = INVALID_EDGE_WEIGHT); + int duration_upper_bound, + const bool permit_private); } // namespace ch } // namespace routing_algorithms diff --git a/include/engine/routing_algorithms/routing_base_mld.hpp b/include/engine/routing_algorithms/routing_base_mld.hpp index c3462039c..140f07201 100644 --- a/include/engine/routing_algorithms/routing_base_mld.hpp +++ b/include/engine/routing_algorithms/routing_base_mld.hpp @@ -520,7 +520,8 @@ inline void search(SearchEngineData &engine_working_data, const bool force_loop_forward, const bool force_loop_reverse, const PhantomNodes &phantom_nodes, - const EdgeWeight weight_upper_bound = INVALID_EDGE_WEIGHT) + const EdgeWeight weight_upper_bound, + const bool /* permit_private */) // danpat TODO: implement this pls :-P { // TODO: change search calling interface to use unpacked_edges result std::tie(weight, unpacked_nodes, std::ignore) = search(engine_working_data, @@ -571,7 +572,8 @@ double getNetworkDistance(SearchEngineData &engine_working_data, typename SearchEngineData::QueryHeap &reverse_heap, const PhantomNode &source_phantom, const PhantomNode &target_phantom, - EdgeWeight weight_upper_bound = INVALID_EDGE_WEIGHT) + EdgeWeight weight_upper_bound, + const bool /* permit_private */) // danpat TODO: implement this { forward_heap.Clear(); reverse_heap.Clear(); diff --git a/include/engine/routing_algorithms/shortest_path.hpp b/include/engine/routing_algorithms/shortest_path.hpp index e98694694..3f92f1a2c 100644 --- a/include/engine/routing_algorithms/shortest_path.hpp +++ b/include/engine/routing_algorithms/shortest_path.hpp @@ -17,7 +17,8 @@ template InternalRouteResult shortestPathSearch(SearchEngineData &engine_working_data, const DataFacade &facade, const std::vector &phantom_nodes_vector, - const boost::optional continue_straight_at_waypoint); + const boost::optional continue_straight_at_waypoint, + const bool permit_private); } // namespace routing_algorithms } // namespace engine diff --git a/include/engine/routing_algorithms/shortest_path_impl.hpp b/include/engine/routing_algorithms/shortest_path_impl.hpp index 0dea19897..899930c4d 100644 --- a/include/engine/routing_algorithms/shortest_path_impl.hpp +++ b/include/engine/routing_algorithms/shortest_path_impl.hpp @@ -34,7 +34,8 @@ void searchWithUTurn(SearchEngineData &engine_working_data, const int total_weight_to_forward, const int total_weight_to_reverse, int &new_total_weight, - std::vector &leg_packed_path) + std::vector &leg_packed_path, + const bool permit_private) { forward_heap.Clear(); reverse_heap.Clear(); @@ -79,7 +80,9 @@ void searchWithUTurn(SearchEngineData &engine_working_data, leg_packed_path, needs_loop_forwards, needs_loop_backwards, - {source_phantom, target_phantom}); + {source_phantom, target_phantom}, + MAXIMAL_EDGE_WEIGHT, + permit_private); // if no route is found between two parts of the via-route, the entire route becomes // invalid. Adding to invalid edge weight sadly doesn't return an invalid edge weight. Here @@ -107,7 +110,8 @@ void search(SearchEngineData &engine_working_data, int &new_total_weight_to_forward, int &new_total_weight_to_reverse, std::vector &leg_packed_path_forward, - std::vector &leg_packed_path_reverse) + std::vector &leg_packed_path_reverse, + const bool permit_private) { if (search_to_forward_node) { @@ -140,7 +144,9 @@ void search(SearchEngineData &engine_working_data, leg_packed_path_forward, needsLoopForward(source_phantom, target_phantom), routing_algorithms::DO_NOT_FORCE_LOOP, - {source_phantom, target_phantom}); + {source_phantom, target_phantom}, + MAXIMAL_EDGE_WEIGHT, + permit_private); } if (search_to_reverse_node) @@ -173,7 +179,9 @@ void search(SearchEngineData &engine_working_data, leg_packed_path_reverse, routing_algorithms::DO_NOT_FORCE_LOOP, needsLoopBackwards(source_phantom, target_phantom), - {source_phantom, target_phantom}); + {source_phantom, target_phantom}, + MAXIMAL_EDGE_WEIGHT, + permit_private); } } @@ -232,7 +240,8 @@ template InternalRouteResult shortestPathSearch(SearchEngineData &engine_working_data, const DataFacade &facade, const std::vector &phantom_nodes_vector, - const boost::optional continue_straight_at_waypoint) + const boost::optional continue_straight_at_waypoint, + const bool permit_private) { InternalRouteResult raw_route_data; raw_route_data.segment_end_coordinates = phantom_nodes_vector; @@ -297,7 +306,8 @@ InternalRouteResult shortestPathSearch(SearchEngineData &engine_worki total_weight_to_forward, total_weight_to_reverse, new_total_weight_to_forward, - packed_leg_to_forward); + packed_leg_to_forward, + permit_private); // if only the reverse node is valid (e.g. when using the match plugin) we // actually need to move if (!target_phantom.IsValidForwardTarget()) @@ -335,7 +345,8 @@ InternalRouteResult shortestPathSearch(SearchEngineData &engine_worki new_total_weight_to_forward, new_total_weight_to_reverse, packed_leg_to_forward, - packed_leg_to_reverse); + packed_leg_to_reverse, + permit_private); } } diff --git a/include/server/api/base_parameters_grammar.hpp b/include/server/api/base_parameters_grammar.hpp index bb731e8d3..f5f31b747 100644 --- a/include/server/api/base_parameters_grammar.hpp +++ b/include/server/api/base_parameters_grammar.hpp @@ -166,12 +166,17 @@ struct BaseParametersGrammar : boost::spirit::qi::grammar (qi::as_string[+qi::char_("a-zA-Z0-9")] % ',')[ph::bind(&engine::api::BaseParameters::exclude, qi::_r1) = qi::_1]; + permit_rule = qi::lit("permit=") > + (qi::as_string[+qi::char_("a-zA-Z0-9")] % + ',')[ph::bind(&engine::api::BaseParameters::permit, qi::_r1) = qi::_1]; + base_rule = radiuses_rule(qi::_r1) // | hints_rule(qi::_r1) // | bearings_rule(qi::_r1) // | generate_hints_rule(qi::_r1) // | approach_rule(qi::_r1) // - | exclude_rule(qi::_r1); + | exclude_rule(qi::_r1) // + | permit_rule(qi::_r1); } protected: @@ -188,6 +193,7 @@ struct BaseParametersGrammar : boost::spirit::qi::grammar qi::rule generate_hints_rule; qi::rule approach_rule; qi::rule exclude_rule; + qi::rule permit_rule; qi::rule bearing_rule; qi::rule location_rule; diff --git a/include/util/typedefs.hpp b/include/util/typedefs.hpp index d647a7db7..d3d583113 100644 --- a/include/util/typedefs.hpp +++ b/include/util/typedefs.hpp @@ -112,6 +112,7 @@ static const SegmentDuration INVALID_SEGMENT_DURATION = (1u << SEGMENT_DURATION_ static const SegmentWeight MAX_SEGMENT_WEIGHT = INVALID_SEGMENT_WEIGHT - 1; static const SegmentDuration MAX_SEGMENT_DURATION = INVALID_SEGMENT_DURATION - 1; static const EdgeWeight INVALID_EDGE_WEIGHT = std::numeric_limits::max(); +static const EdgeWeight MAXIMAL_EDGE_WEIGHT = std::numeric_limits::max(); static const EdgeDuration MAXIMAL_EDGE_DURATION = std::numeric_limits::max(); static const EdgeDistance MAXIMAL_EDGE_DISTANCE = std::numeric_limits::max(); static const TurnPenalty INVALID_TURN_PENALTY = std::numeric_limits::max(); diff --git a/src/engine/plugins/match.cpp b/src/engine/plugins/match.cpp index 54ad24231..7286ca093 100644 --- a/src/engine/plugins/match.cpp +++ b/src/engine/plugins/match.cpp @@ -289,7 +289,7 @@ Status MatchPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms, // we split the phantom nodes anyway and only have bi-directional phantom nodes for // possible uturns sub_routes[index] = - algorithms.ShortestPathSearch(sub_routes[index].segment_end_coordinates, {false}); + algorithms.ShortestPathSearch(sub_routes[index].segment_end_coordinates, {false}, routing_algorithms::PERMIT_PRIVATE); BOOST_ASSERT(sub_routes[index].shortest_path_weight != INVALID_EDGE_WEIGHT); if (collapse_legs) { diff --git a/src/engine/plugins/trip.cpp b/src/engine/plugins/trip.cpp index f402a0c06..13183aec8 100644 --- a/src/engine/plugins/trip.cpp +++ b/src/engine/plugins/trip.cpp @@ -55,7 +55,8 @@ bool IsSupportedParameterCombination(const bool fixed_start, InternalRouteResult TripPlugin::ComputeRoute(const RoutingAlgorithmsInterface &algorithms, const std::vector &snapped_phantoms, const std::vector &trip, - const bool roundtrip) const + const bool roundtrip, + const bool permit_private = false) const { InternalRouteResult min_route; // given the final trip, compute total duration and return the route and location permutation @@ -85,7 +86,7 @@ InternalRouteResult TripPlugin::ComputeRoute(const RoutingAlgorithmsInterface &a BOOST_ASSERT(min_route.segment_end_coordinates.size() == trip.size() - 1); } - min_route = algorithms.ShortestPathSearch(min_route.segment_end_coordinates, {false}); + min_route = algorithms.ShortestPathSearch(min_route.segment_end_coordinates, {false}, permit_private); BOOST_ASSERT_MSG(min_route.shortest_path_weight < INVALID_EDGE_WEIGHT, "unroutable route"); return min_route; } @@ -267,9 +268,12 @@ Status TripPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms, std::rotate(std::begin(duration_trip), desired_start_index, std::end(duration_trip)); } + // TODO validate: + const bool permit_private = parameters.permit.size() == 1 && parameters.permit.front() == "private"; + // get the route when visiting all destinations in optimized order InternalRouteResult route = - ComputeRoute(algorithms, snapped_phantoms, duration_trip, parameters.roundtrip); + ComputeRoute(algorithms, snapped_phantoms, duration_trip, parameters.roundtrip, permit_private); // get api response const std::vector> trips = {duration_trip}; diff --git a/src/engine/plugins/viaroute.cpp b/src/engine/plugins/viaroute.cpp index fe749d0a1..abd546e65 100644 --- a/src/engine/plugins/viaroute.cpp +++ b/src/engine/plugins/viaroute.cpp @@ -68,6 +68,15 @@ Status ViaRoutePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithm json_result); } + if (route_parameters.permit.size() > 0) { + if (route_parameters.permit.size() > 1) { + return Error("InvalidValue", "Invalid numer of permit values - only 1 allowed.", json_result); + } + if (route_parameters.permit.front() != "private") { + return Error("InvalidValue", "Invalid permit value.", json_result); + } + } + if (!CheckAllCoordinates(route_parameters.coordinates)) { return Error("InvalidValue", "Invalid coordinate value.", json_result); @@ -107,6 +116,8 @@ Status ViaRoutePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithm (route_parameters.alternatives || route_parameters.number_of_alternatives > 0); const auto number_of_alternatives = std::max(1u, route_parameters.number_of_alternatives); + const bool permit_private = route_parameters.permit.size() == 1 && route_parameters.permit.front() == "private"; + // Alternatives do not support vias, only direct s,t queries supported // See the implementation notes and high-level outline. // https://github.com/Project-OSRM/osrm-backend/issues/3905 @@ -116,11 +127,11 @@ Status ViaRoutePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithm } else if (1 == start_end_nodes.size() && algorithms.HasDirectShortestPathSearch()) { - routes = algorithms.DirectShortestPathSearch(start_end_nodes.front()); + routes = algorithms.DirectShortestPathSearch(start_end_nodes.front(), permit_private); } else { - routes = algorithms.ShortestPathSearch(start_end_nodes, route_parameters.continue_straight); + routes = algorithms.ShortestPathSearch(start_end_nodes, route_parameters.continue_straight, permit_private); } // The post condition for all path searches is we have at least one route in our result. diff --git a/src/engine/routing_algorithms/alternative_path_ch.cpp b/src/engine/routing_algorithms/alternative_path_ch.cpp index 2efd6fe19..04ead7311 100644 --- a/src/engine/routing_algorithms/alternative_path_ch.cpp +++ b/src/engine/routing_algorithms/alternative_path_ch.cpp @@ -159,7 +159,8 @@ void computeWeightAndSharingOfViaPath(SearchEngineData &engine_workin EdgeWeight *real_weight_of_via_path, EdgeWeight *sharing_of_via_path, const std::vector &packed_shortest_path, - const EdgeWeight min_edge_offset) + const EdgeWeight min_edge_offset, + const bool permit_private) { engine_working_data.InitializeOrClearSecondThreadLocalStorage(facade.GetNumberOfNodes()); @@ -187,7 +188,8 @@ void computeWeightAndSharingOfViaPath(SearchEngineData &engine_workin upper_bound_s_v_path_weight, min_edge_offset, DO_NOT_FORCE_LOOPS, - DO_NOT_FORCE_LOOPS); + DO_NOT_FORCE_LOOPS, + permit_private); } // compute path by reusing backward search from node t NodeID v_t_middle = SPECIAL_NODEID; @@ -202,7 +204,8 @@ void computeWeightAndSharingOfViaPath(SearchEngineData &engine_workin upper_bound_of_v_t_path_weight, min_edge_offset, DO_NOT_FORCE_LOOPS, - DO_NOT_FORCE_LOOPS); + DO_NOT_FORCE_LOOPS, + permit_private); } *real_weight_of_via_path = upper_bound_s_v_path_weight + upper_bound_of_v_t_path_weight; @@ -328,7 +331,8 @@ bool viaNodeCandidatePassesTTest(SearchEngineData &engine_working_dat EdgeWeight *weight_of_via_path, NodeID *s_v_middle, NodeID *v_t_middle, - const EdgeWeight min_edge_offset) + const EdgeWeight min_edge_offset, + const bool permit_private) { new_forward_heap.Clear(); new_reverse_heap.Clear(); @@ -348,7 +352,8 @@ bool viaNodeCandidatePassesTTest(SearchEngineData &engine_working_dat upper_bound_s_v_path_weight, min_edge_offset, DO_NOT_FORCE_LOOPS, - DO_NOT_FORCE_LOOPS); + DO_NOT_FORCE_LOOPS, + permit_private); } if (INVALID_EDGE_WEIGHT == upper_bound_s_v_path_weight) @@ -369,7 +374,8 @@ bool viaNodeCandidatePassesTTest(SearchEngineData &engine_working_dat upper_bound_of_v_t_path_weight, min_edge_offset, DO_NOT_FORCE_LOOPS, - DO_NOT_FORCE_LOOPS); + DO_NOT_FORCE_LOOPS, + permit_private); } if (INVALID_EDGE_WEIGHT == upper_bound_of_v_t_path_weight) @@ -542,7 +548,8 @@ bool viaNodeCandidatePassesTTest(SearchEngineData &engine_working_dat upper_bound, min_edge_offset, DO_NOT_FORCE_LOOPS, - DO_NOT_FORCE_LOOPS); + DO_NOT_FORCE_LOOPS, + permit_private); } if (!reverse_heap3.Empty()) { @@ -553,7 +560,8 @@ bool viaNodeCandidatePassesTTest(SearchEngineData &engine_working_dat upper_bound, min_edge_offset, DO_NOT_FORCE_LOOPS, - DO_NOT_FORCE_LOOPS); + DO_NOT_FORCE_LOOPS, + permit_private); } } return (upper_bound <= t_test_path_weight); @@ -757,7 +765,8 @@ InternalManyRoutesResult alternativePathSearch(SearchEngineData &engi &weight_of_via_path, &sharing_of_via_path, packed_shortest_path, - min_edge_offset); + min_edge_offset, + routing_algorithms::AVOID_PRIVATE); // danpat TODO: parameterize this const EdgeWeight maximum_allowed_sharing = static_cast(upper_bound_to_shortest_path_weight * VIAPATH_GAMMA); if (sharing_of_via_path <= maximum_allowed_sharing && @@ -784,7 +793,8 @@ InternalManyRoutesResult alternativePathSearch(SearchEngineData &engi &weight_of_via_path, &s_v_middle, &v_t_middle, - min_edge_offset)) + min_edge_offset, + routing_algorithms::AVOID_PRIVATE)) // danpat TODO: parameterize permit_private { // select first admissable selected_via_node = candidate.node; diff --git a/src/engine/routing_algorithms/direct_shortest_path.cpp b/src/engine/routing_algorithms/direct_shortest_path.cpp index 08ca3249e..c086a1a6c 100644 --- a/src/engine/routing_algorithms/direct_shortest_path.cpp +++ b/src/engine/routing_algorithms/direct_shortest_path.cpp @@ -19,7 +19,8 @@ namespace routing_algorithms template <> InternalRouteResult directShortestPathSearch(SearchEngineData &engine_working_data, const DataFacade &facade, - const PhantomNodes &phantom_nodes) + const PhantomNodes &phantom_nodes, + const bool permit_private) { engine_working_data.InitializeOrClearFirstThreadLocalStorage(facade.GetNumberOfNodes()); auto &forward_heap = *engine_working_data.forward_heap_1; @@ -39,7 +40,9 @@ InternalRouteResult directShortestPathSearch(SearchEngineData &en packed_leg, DO_NOT_FORCE_LOOPS, DO_NOT_FORCE_LOOPS, - phantom_nodes); + phantom_nodes, + MAXIMAL_EDGE_WEIGHT, + permit_private); std::vector unpacked_nodes; std::vector unpacked_edges; @@ -66,7 +69,8 @@ InternalRouteResult directShortestPathSearch(SearchEngineData &en template <> InternalRouteResult directShortestPathSearch(SearchEngineData &engine_working_data, const DataFacade &facade, - const PhantomNodes &phantom_nodes) + const PhantomNodes &phantom_nodes, + const bool /* permit_private */) { engine_working_data.InitializeOrClearFirstThreadLocalStorage(facade.GetNumberOfNodes(), facade.GetMaxBorderNodeID() + 1); diff --git a/src/engine/routing_algorithms/map_matching.cpp b/src/engine/routing_algorithms/map_matching.cpp index 7d1b75901..60bc0d9dd 100644 --- a/src/engine/routing_algorithms/map_matching.cpp +++ b/src/engine/routing_algorithms/map_matching.cpp @@ -244,7 +244,8 @@ SubMatchingList mapMatching(SearchEngineData &engine_working_data, reverse_heap, prev_unbroken_timestamps_list[s].phantom_node, current_timestamps_list[s_prime].phantom_node, - weight_upper_bound); + weight_upper_bound, + PERMIT_PRIVATE); // get distance diff between loc1/2 and locs/s_prime const auto d_t = std::abs(network_distance - haversine_distance); diff --git a/src/engine/routing_algorithms/routing_base_ch.cpp b/src/engine/routing_algorithms/routing_base_ch.cpp index 695ebe923..86ae5ef72 100644 --- a/src/engine/routing_algorithms/routing_base_ch.cpp +++ b/src/engine/routing_algorithms/routing_base_ch.cpp @@ -98,7 +98,8 @@ void search(SearchEngineData & /*engine_working_data*/, const bool force_loop_forward, const bool force_loop_reverse, const PhantomNodes & /*phantom_nodes*/, - const EdgeWeight weight_upper_bound) + const EdgeWeight weight_upper_bound, + const bool permit_private) { if (forward_heap.Empty() || reverse_heap.Empty()) { @@ -127,7 +128,8 @@ void search(SearchEngineData & /*engine_working_data*/, weight, min_edge_offset, force_loop_forward, - force_loop_reverse); + force_loop_reverse, + permit_private); } if (!reverse_heap.Empty()) { @@ -138,7 +140,8 @@ void search(SearchEngineData & /*engine_working_data*/, weight, min_edge_offset, force_loop_reverse, - force_loop_forward); + force_loop_forward, + permit_private); } } @@ -174,7 +177,8 @@ double getNetworkDistance(SearchEngineData &engine_working_data, SearchEngineData::QueryHeap &reverse_heap, const PhantomNode &source_phantom, const PhantomNode &target_phantom, - EdgeWeight weight_upper_bound) + EdgeWeight weight_upper_bound, + const bool permit_private) { forward_heap.Clear(); reverse_heap.Clear(); @@ -192,7 +196,8 @@ double getNetworkDistance(SearchEngineData &engine_working_data, DO_NOT_FORCE_LOOPS, DO_NOT_FORCE_LOOPS, {source_phantom, target_phantom}, - weight_upper_bound); + weight_upper_bound, + permit_private); if (weight == INVALID_EDGE_WEIGHT) { diff --git a/src/engine/routing_algorithms/shortest_path.cpp b/src/engine/routing_algorithms/shortest_path.cpp index 8fadf6491..fae590460 100644 --- a/src/engine/routing_algorithms/shortest_path.cpp +++ b/src/engine/routing_algorithms/shortest_path.cpp @@ -13,13 +13,15 @@ template InternalRouteResult shortestPathSearch(SearchEngineData &engine_working_data, const DataFacade &facade, const std::vector &phantom_nodes_vector, - const boost::optional continue_straight_at_waypoint); + const boost::optional continue_straight_at_waypoint, + const bool permit_private); template InternalRouteResult shortestPathSearch(SearchEngineData &engine_working_data, const DataFacade &facade, const std::vector &phantom_nodes_vector, - const boost::optional continue_straight_at_waypoint); + const boost::optional continue_straight_at_waypoint, + const bool permit_private); } // namespace routing_algorithms } // namespace engine