\brief Building rtree-based nearest-neighbor data structure Saves tree into '.ramIndex' and leaves into '.fileIndex'. */
| 782 | Saves tree into '.ramIndex' and leaves into '.fileIndex'. |
| 783 | */ |
| 784 | void 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 | |
| 813 | template <typename Map> auto convertIDMapToVector(const Map &map) |
| 814 | { |