private Dictionary <BUCoverNode <T>, SpatialObj <T> > FindNearestRectToPoint(Point p, BUCoverNode <T> node) { Dictionary <BUCoverNode <T>, SpatialObj <T> > answer_dict = new Dictionary <BUCoverNode <T>, SpatialObj <T> >(); SimplePriorityQueue <BUCoverNode <T> > searching_nodes = new SimplePriorityQueue <BUCoverNode <T> >(); searching_nodes.Enqueue(node, 0); SpatialObj <T> answer = default(SpatialObj <T>); BUCoverNode <T> answer_node = null; bool used = false; double min_distance_sq = rootNode.GetMaxDistance(); while (searching_nodes.Count > 0) { BUCoverNode <T> current_node = searching_nodes.Dequeue(); Dictionary <SpatialObj <T>, double> nearest_rect = current_node.GetNearestRectangle(p); if (nearest_rect.Count > 0) { foreach (KeyValuePair <SpatialObj <T>, double> entry in nearest_rect) { if (entry.Value <= min_distance_sq || entry.Value < Statics.EPSILON) { min_distance_sq = entry.Value; answer = entry.Key; answer_node = current_node; used = false; if (min_distance_sq < Statics.EPSILON) { answer_dict.Add(answer_node, answer); used = true; } } } } if (current_node.HasChildren()) { foreach (BUCoverNode <T> child in current_node.GetChildren()) { double field_dist = child.GetDistanceToPointSq(p); if (field_dist <= min_distance_sq) { searching_nodes.Enqueue(child, (float)field_dist); } } } } if (!used) { answer_dict.Add(answer_node, answer); } return(answer_dict); }