How to increase performance for nearest neighbour query using a multipoint? (Boost Ge

المشرف العام

Administrator
طاقم الإدارة
The following function takes about 10ms to run according to valgrind. Is there any way to make it faster?

TimingLink* JourneyPattern::getClosestFromTimingLink(multipoint g,int maxFromSequence) { std::vector result_n; linkFromTree.query(bgi::nearest(g, 1) && bgi::satisfies([maxFromSequence](LinkPair const& v) { return ((v.second)->fromSequence < maxFromSequence); }), std::back_inserter(result_n)); if (!result_n.empty()) return result_n[0].second; else return NULL;}The purpose of the function is to find a point in the rtree linkFromTree that is closest to the multipoint g and whose fromSequence is less than maxFromSequence. linkFromTree is an rtree created using the packing algorithm and it usually contains about 100 points. The multipoint g will also contain about 100 points.

The slow part seems to be using a multipoint (g) to do the nearest neighbour query, as I have a similar function that uses a point instead and it is much faster.



أكثر...
 
أعلى