MCPcopy Create free account
hub / github.com/comaps/comaps / Generate

Method Generate

libs/routing/directions_engine.cpp:245–291  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

243}
244
245bool DirectionsEngine::Generate(IndexRoadGraph const & graph, vector<geometry::PointWithAltitude> const & path,
246 base::Cancellable const & cancellable, vector<RouteSegment> & routeSegments)
247{
248 CHECK(m_numMwmIds, ());
249
250 m_adjacentEdges.clear();
251 m_pathSegments.clear();
252
253 CHECK_NOT_EQUAL(m_vehicleType, VehicleType::Count, (m_vehicleType));
254
255 if (m_vehicleType == VehicleType::Transit)
256 {
257 auto const & segments = graph.GetRouteSegments();
258 uint32_t const segsCount = base::asserted_cast<uint32_t>(segments.size());
259 for (uint32_t i = 0; i < segsCount; ++i)
260 {
261 TurnItem turn;
262 if (i == segsCount - 1)
263 turn = TurnItem(segsCount, turns::PedestrianDirection::ReachedYourDestination);
264 routeSegments.emplace_back(segments[i], turn, path[i + 1], RouteSegment::RoadNameInfo());
265 }
266 return true;
267 }
268
269 if (path.size() <= 1)
270 return false;
271
272 IndexRoadGraph::EdgeVector routeEdges;
273 graph.GetRouteEdges(routeEdges);
274
275 if (routeEdges.empty())
276 return false;
277
278 if (cancellable.IsCancelled())
279 return false;
280
281 FillPathSegmentsAndAdjacentEdgesMap(graph, path, routeEdges, cancellable);
282
283 if (cancellable.IsCancelled())
284 return false;
285
286 MakeTurnAnnotation(routeEdges, routeSegments);
287
288 CHECK_EQUAL(routeSegments.size(), routeEdges.size(), ());
289
290 return true;
291}
292
293/*!
294 * \brief Compute turn and time estimation structs for the abstract route result.

Callers 1

ReconstructRouteFunction · 0.80

Calls 8

RoadNameInfoClass · 0.85
TurnItemClass · 0.70
clearMethod · 0.45
sizeMethod · 0.45
emplace_backMethod · 0.45
GetRouteEdgesMethod · 0.45
emptyMethod · 0.45
IsCancelledMethod · 0.45

Tested by

no test coverage detected