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

Method BuildRTree

src/extractor/extractor.cpp:784–811  ·  view source on GitHub ↗

\brief Building rtree-based nearest-neighbor data structure Saves tree into '.ramIndex' and leaves into '.fileIndex'. */

Source from the content-addressed store, hash-verified

782 Saves tree into '.ramIndex' and leaves into '.fileIndex'.
783 */
784void Extractor::BuildRTree(std::vector<EdgeBasedNodeSegment> edge_based_node_segments,
785 const std::vector<util::Coordinate> &coordinates)
786{
787 util::Log() << "Constructing r-tree of " << edge_based_node_segments.size()
788 << " segments build on-top of " << coordinates.size() << " coordinates";
789
790 // Filter node based edges based on startpoint
791 auto start_point_count = std::accumulate(edge_based_node_segments.begin(),
792 edge_based_node_segments.end(),
793 0,
794 [](const size_t so_far, const auto &segment)
795 { return so_far + (segment.is_startpoint ? 1 : 0); });
796 if (start_point_count == 0)
797 {
798 throw util::exception("There are no snappable edges left after processing. Are you "
799 "setting travel modes correctly in the profile? Cannot continue." +
800 SOURCE_REF);
801 }
802
803 TIMER_START(construction);
804 util::StaticRTree<EdgeBasedNodeSegment> rtree(
805 edge_based_node_segments, coordinates, config.GetPath(".osrm.fileIndex"));
806
807 files::writeRamIndex(config.GetPath(".osrm.ramIndex"), rtree);
808
809 TIMER_STOP(construction);
810 util::Log() << "finished r-tree construction in " << TIMER_SEC(construction) << " seconds";
811}
812
813template <typename Map> auto convertIDMapToVector(const Map &map)
814{

Callers

nothing calls this directly

Calls 7

LogClass · 0.85
exceptionClass · 0.85
writeRamIndexFunction · 0.85
GetPathMethod · 0.80
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected