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

Function getEdgeIndex

src/engine/plugins/tile.cpp:240–263  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

238}
239
240std::vector<std::size_t> getEdgeIndex(const std::vector<RTreeLeaf> &edges)
241{
242 // In order to ensure consistent tile encoding, we need to process
243 // all edges in the same order. Differences in OSX/Linux/Windows
244 // sorting methods mean that GetEdgesInBox doesn't return the same
245 // ordered array on all platforms.
246 // GetEdgesInBox is marked `const`, so we can't sort the array itself,
247 // instead we create an array of indexes and sort that instead.
248 std::vector<std::size_t> sorted_edge_indexes(edges.size(), 0);
249 std::iota(
250 sorted_edge_indexes.begin(), sorted_edge_indexes.end(), 0); // fill with 0,1,2,3,...N-1
251
252 // Now, sort that array based on the edges list, using the u/v node IDs
253 // as the sort condition
254 std::sort(sorted_edge_indexes.begin(),
255 sorted_edge_indexes.end(),
256 [&edges](const std::size_t &left, const std::size_t &right) -> bool
257 {
258 return (edges[left].u != edges[right].u) ? edges[left].u < edges[right].u
259 : edges[left].v < edges[right].v;
260 });
261
262 return sorted_edge_indexes;
263}
264
265std::vector<NodeID> getSegregatedNodes(const DataFacadeBase &facade,
266 const std::vector<RTreeLeaf> &edges)

Callers 1

HandleRequestMethod · 0.85

Calls 3

sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected