Ejemplo n.º 1
0
        /// <summary>
        /// Gets all items within the boundary.
        /// </summary>
        /// <param name="boundary">Boundary to check.</param>
        /// <returns>Collection of all items within the boundary.</returns>
        public virtual IList <T> Query(IQTBoundary boundary)
        {
            List <T> itemsInRange = new List <T>(4);

            if (Boundary == null)
            {
                return(itemsInRange);
            }

            if (!Boundary.Intersects(boundary))
            {
                return(itemsInRange);
            }

            foreach (T item in items)
            {
                if (boundary.ContainsPoint(item))
                {
                    itemsInRange.Add(item);
                }
            }

            if (northWest == null)
            {
                return(itemsInRange);
            }

            itemsInRange.AddRange(northWest.Query(boundary));
            itemsInRange.AddRange(northEast.Query(boundary));
            itemsInRange.AddRange(southWest.Query(boundary));
            itemsInRange.AddRange(southEast.Query(boundary));

            return(itemsInRange);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Gets all items within <see cref="IQTBoundary"/>.
 /// </summary>
 /// <param name="boundary">Boundary to check.</param>
 /// <returns>Collection of all items within <see cref="IQTBoundary"/>.</returns>
 public virtual IList <T> Query(IQTBoundary boundary)
 {
     return(rootTree.Query(boundary));
 }