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

Function getTileTurns

src/engine/routing_algorithms/tile_turns.cpp:194–243  ·  view source on GitHub ↗

CH Version of finding all turn penalties. Here is where the actual work is happening

Source from the content-addressed store, hash-verified

192
193// CH Version of finding all turn penalties. Here is where the actual work is happening
194std::vector<TurnData> getTileTurns(const DataFacade<ch::Algorithm> &facade,
195 const std::vector<RTreeLeaf> &edges,
196 const std::vector<std::size_t> &sorted_edge_indexes)
197{
198 // Define how to find the representative edge between two edge based nodes for a CH
199 struct EdgeFinderCH
200 {
201 EdgeFinderCH(const DataFacade<ch::Algorithm> &facade) : facade(facade) {}
202 const DataFacade<ch::Algorithm> &facade;
203
204 EdgeID operator()(const NodeID approach_node, const NodeID exit_node) const
205 {
206 // Find the connection between our source road and the target node
207 // Since we only want to find direct edges, we cannot check shortcut edges here.
208 // Otherwise we might find a forward edge even though a shorter backward edge
209 // exists (due to oneways).
210 //
211 // a > - > - > - b
212 // | |
213 // |------ c ----|
214 //
215 // would offer a backward edge at `b` to `a` (due to the oneway from a to b)
216 // but could also offer a shortcut (b-c-a) from `b` to `a` which is longer.
217 EdgeID edge_id = facade.FindSmallestEdge(approach_node,
218 exit_node,
219 [](const contractor::QueryEdge::EdgeData &data)
220 { return data.forward && !data.shortcut; });
221
222 // Depending on how the graph is constructed, we might have to look for
223 // a backwards edge instead. They're equivalent, just one is available for
224 // a forward routing search, and one is used for the backwards dijkstra
225 // steps. Their weight should be the same, we can use either one.
226 // If we didn't find a forward edge, try for a backward one
227 if (SPECIAL_EDGEID == edge_id)
228 {
229 edge_id = facade.FindSmallestEdge(exit_node,
230 approach_node,
231 [](const contractor::QueryEdge::EdgeData &data)
232 { return data.backward && !data.shortcut; });
233 }
234
235 BOOST_ASSERT_MSG(edge_id == SPECIAL_EDGEID || !facade.GetEdgeData(edge_id).shortcut,
236 "Connecting edge must not be a shortcut");
237 return edge_id;
238 }
239 };
240
241 EdgeFinderCH edge_finder(facade);
242 return generateTurns(facade, edges, sorted_edge_indexes, edge_finder);
243}
244
245// MLD version to find all turns
246std::vector<TurnData> getTileTurns(const DataFacade<mld::Algorithm> &facade,

Callers 1

GetTileTurnsMethod · 0.85

Calls 1

generateTurnsFunction · 0.85

Tested by

no test coverage detected