MCPcopy Create free account
hub / github.com/Project-OSRM/osrm-backend / ComputeRoute

Method ComputeRoute

src/engine/plugins/trip.cpp:33–62  ·  view source on GitHub ↗

given the node order in which to visit, compute the actual route (with geometry, travel time and so on) and return the result

Source from the content-addressed store, hash-verified

31// given the node order in which to visit, compute the actual route (with geometry, travel time and
32// so on) and return the result
33InternalRouteResult
34TripPlugin::ComputeRoute(const RoutingAlgorithmsInterface &algorithms,
35 const std::vector<PhantomNodeCandidates> &waypoint_candidates,
36 const std::vector<NodeID> &trip,
37 const bool roundtrip) const
38{
39
40 // TODO make a more efficient solution that doesn't require copying all the waypoints vectors.
41 std::vector<PhantomNodeCandidates> trip_candidates;
42 std::transform(trip.begin(),
43 trip.end(),
44 std::back_inserter(trip_candidates),
45 [&](const auto &node) { return waypoint_candidates[node]; });
46 // return back to the first node if it is a round trip
47 if (roundtrip)
48 {
49 trip_candidates.push_back(waypoint_candidates[trip.front()]);
50 // trip comes out to be something like 0 1 4 3 2 0
51 BOOST_ASSERT(trip_candidates.size() == trip.size() + 1);
52 }
53 else
54 {
55 // trip comes out to be something like 0 1 4 3 2
56 BOOST_ASSERT(trip_candidates.size() == trip.size());
57 }
58
59 auto min_route = algorithms.ShortestPathSearch(trip_candidates, {false});
60 BOOST_ASSERT_MSG(min_route.shortest_path_weight < INVALID_EDGE_WEIGHT, "unroutable route");
61 return min_route;
62}
63
64void ManipulateTableForFSE(const std::size_t source_id,
65 const std::size_t destination_id,

Callers

nothing calls this directly

Calls 6

ShortestPathSearchMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
push_backMethod · 0.45
frontMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected