コード例 #1
0
ファイル: RTree.cs プロジェクト: springmin/VelocityDB
        /// <summary>
        /// Finds the nearest rectangles to the passed point. If multiple rectangles are equally near, they will all be returned.
        /// </summary>
        /// <param name="p">the point we are looking for</param>
        /// <param name="furthestDistance">The furthest distance away from the rectangle to search. Rectangles further than this will not be found.</param>
        /// <returns>a PriorityQue containing the found recatngles and their priorities (distances from point)</returns>
        public PriorityQueueRTree Nearest(Point p, double furthestDistance)
        {
            PriorityQueueRTree distanceQueue = new PriorityQueueRTree();

            double furthestDistanceSq = furthestDistance * furthestDistance;

            rootNode.Nearest(p, this, furthestDistanceSq, distanceQueue);
            return(distanceQueue);
        }
コード例 #2
0
 internal override double Nearest(Point p, RTree rTree, double furthestDistanceSq, PriorityQueueRTree nearestRectangles)
 {
     for (int i = 0; i < entryCount; i++)
     {
         double tempDistanceSq = entries[i].Value.distanceSq(p.x, p.y);
         // a rectangle nearer than actualNearest
         if (tempDistanceSq <= furthestDistanceSq)
         {
             NodeBase node = childNodes[i]; // search the child node
             furthestDistanceSq = node.Nearest(p, rTree, furthestDistanceSq, nearestRectangles);
         }
     }
     return(furthestDistanceSq);
 }