Exemplo n.º 1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="searchEnv"></param>
 /// <param name="visitor"></param>
 private void VisitItems(Envelope searchEnv, IItemVisitor <T> visitor)
 {
     // would be nice to filter items based on search envelope, but can't until they contain an envelope
     for (IEnumerator <T> i = _items.GetEnumerator(); i.MoveNext();)
     {
         visitor.VisitItem(i.Current);
     }
 }
Exemplo n.º 2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="searchEnv"></param>
 /// <param name="visitor"></param>
 public virtual void Query(IEnvelope searchEnv, IItemVisitor visitor)
 {
     /*
      * the items that are matched are the items in quads which
      * overlap the search envelope
      */
     root.Visit(searchEnv, visitor);
 }
        public override void Query(double queryMin, double queryMax, IItemVisitor <T> visitor)
        {
            if (!Intersects(queryMin, queryMax))
            {
                return;
            }

            visitor.VisitItem(_item);
        }
Exemplo n.º 4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="searchEnv"></param>
 /// <param name="visitor"></param>
 public virtual void Query(Rectangle searchEnv, IItemVisitor <TItem> visitor)
 {
     /*
      * the items that are matched are the items in quads which
      * overlap the search envelope
      */
     searchEnv = searchEnv.NormalizedRectangle();
     _root.Visit(searchEnv, visitor);
 }
Exemplo n.º 5
0
            /*
             * public IList Query(double min, double max)
             * {
             *  ArrayListVisitor visitor = new ArrayListVisitor();
             *  index.Query(min, max, visitor);
             *  return visitor.Items;
             * }
             */

            public void Query(double min, double max, IItemVisitor <LineSegment> visitor)
            {
                if (_isEmpty)
                {
                    return;
                }

                _index.Query(min, max, visitor);
            }
        /// <inheritdoc cref="ISpatialIndex{T}.Query(Envelope, IItemVisitor{T})"/>
        public void Query(Envelope searchBounds, IItemVisitor <T> visitor)
        {
            // if the tree has not been built, do it now.
            if (_pos != _boxes.Length)
            {
                Build();
            }

            int nodeIndex = _boxes.Length - 1;
            int level     = _levelBounds.Length - 1;

            // stack for traversing nodes
            var  stack = new Stack <int>();
            bool done  = false;

            while (!done)
            {
                // find the end index of the node
                int end = Math.Min(nodeIndex + _nodeSize, UpperBound(nodeIndex, _levelBounds));

                // search through child nodes
                for (int pos = nodeIndex; pos < end; pos++)
                {
                    int index = _indices[pos];

                    // check if node bbox intersects with query bbox
                    if (!searchBounds.Intersects(_boxes[pos]))
                    {
                        continue;
                    }

                    if (nodeIndex < _numItems)
                    {
                        visitor.VisitItem(_items[index]);
                    }
                    else
                    {
                        // push node index and level for further traversal
                        stack.Push(index);
                        stack.Push(level - 1);
                    }
                }

                if (stack.Count > 1)
                {
                    level     = stack.Pop();
                    nodeIndex = stack.Pop();
                }
                else
                {
                    done = true;
                }
            }
        }
Exemplo n.º 7
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="searchEnv"></param>
 /// <param name="visitor"></param>
 protected virtual void VisitItems(Rectangle searchEnv, IItemVisitor <TItem> visitor)
 {
     // would be nice to filter items based on search envelope, but can't until they contain an envelope
     // lytico: what about having IItemVisitor.GetEnvelope(TItem item)
     if (HasItems)
     {
         foreach (var current in Items)
         {
             visitor.VisitItem(current);
         }
     }
 }
Exemplo n.º 8
0
        /// <summary>
        /// Search for intervals in the index which intersect the given closed interval
        /// and apply the visitor to them.
        /// </summary>
        /// <param name="min">The lower bound of the query interval</param>
        /// <param name="max">The upper bound of the query interval</param>
        /// <param name="visitor">The visitor to pass any matched items to</param>
        public void Query(double min, double max, IItemVisitor <T> visitor)
        {
            Init();

            // if root is null tree must be empty
            if (_root == null)
            {
                return;
            }

            _root.Query(min, max, visitor);
        }
Exemplo n.º 9
0
 public override void Query(double queryMin, double queryMax, IItemVisitor <T> visitor)
 {
     if (!Intersects(queryMin, queryMax))
     {
         // System.out.println("Does NOT Overlap branch: " + this);
         return;
     }
     // System.out.println("Overlaps branch: " + this);
     if (_node1 != null)
     {
         _node1.Query(queryMin, queryMax, visitor);
     }
     if (_node2 != null)
     {
         _node2.Query(queryMin, queryMax, visitor);
     }
 }
Exemplo n.º 10
0
        /// <summary>
        /// Also builds the tree, if necessary.
        /// </summary>
        /// <param name="searchBounds"></param>
        /// <param name="visitor"></param>
        protected virtual void Query(Object searchBounds, IItemVisitor visitor)
        {
            if (!built)
            {
                Build();
            }

            if (itemBoundables.Count == 0)
            {
                Assert.IsTrue(root.Bounds == null);
            }

            if (IntersectsOp.Intersects(root.Bounds, searchBounds))
            {
                Query(searchBounds, root, visitor);
            }
        }
Exemplo n.º 11
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="searchEnv"></param>
        /// <param name="visitor"></param>
        public void Visit(Envelope searchEnv, IItemVisitor <T> visitor)
        {
            if (!IsSearchMatch(searchEnv))
            {
                return;
            }

            // this node may have items as well as subnodes (since items may not
            // be wholely contained in any single subnode
            VisitItems(searchEnv, visitor);

            for (int i = 0; i < 4; i++)
            {
                if (Subnode[i] != null)
                {
                    Subnode[i].Visit(searchEnv, visitor);
                }
            }
        }
Exemplo n.º 12
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="searchEnv"></param>
        /// <param name="visitor"></param>
        public virtual void Visit(Rectangle searchEnv, IItemVisitor <TItem> visitor)
        {
            if (!IsSearchMatch(searchEnv))
            {
                return;
            }

            // this node may have items as well as subnodes (since items may not
            // be wholely contained in any single subnode
            VisitItems(searchEnv, visitor);

            // TODO: lytico: here we should make getSubNodeIndex (this.envelope, searchEnv) to speed up
            foreach (Node <TItem> sub in Subnodes)
            {
                if (sub != null)
                {
                    sub.Visit(searchEnv, visitor);
                }
            }
        }
Exemplo n.º 13
0
        protected void Query(T searchBounds, IItemVisitor <TItem> visitor)
        {
            Build();

            if (IsEmpty)
            {
                return;
            }

            //if (_itemBoundables.Count == 0)
            //{
            //    //nothing in tree, so return
            //    //Assert.IsTrue(_root.Bounds == null);
            //    return;
            //}

            if (IntersectsOp.Intersects(_root.Bounds, searchBounds))
            {
                Query(searchBounds, _root, visitor);
            }
        }
Exemplo n.º 14
0
 private void Query(T searchBounds, AbstractNode <T, TItem> node, IItemVisitor <TItem> visitor)
 {
     foreach (var childBoundable in node.ChildBoundables)
     {
         if (!IntersectsOp.Intersects(childBoundable.Bounds, searchBounds))
         {
             continue;
         }
         if (childBoundable is AbstractNode <T, TItem> )
         {
             Query(searchBounds, (AbstractNode <T, TItem>)childBoundable, visitor);
         }
         else if (childBoundable is ItemBoundable <T, TItem> )
         {
             visitor.VisitItem(((ItemBoundable <T, TItem>)childBoundable).Item);
         }
         else
         {
             Assert.ShouldNeverReachHere();
         }
     }
 }
Exemplo n.º 15
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="searchBounds"></param>
 /// <param name="node"></param>
 /// <param name="visitor"></param>
 private void Query(object searchBounds, AbstractNode node, IItemVisitor visitor)
 {
     foreach (object obj in node.ChildBoundables)
     {
         IBoundable childBoundable = (IBoundable)obj;
         if (!IntersectsOp.Intersects(childBoundable.Bounds, searchBounds))
         {
             continue;
         }
         if (childBoundable is AbstractNode)
         {
             Query(searchBounds, (AbstractNode)childBoundable, visitor);
         }
         else if (childBoundable is ItemBoundable)
         {
             visitor.VisitItem(((ItemBoundable)childBoundable).Item);
         }
         else
         {
             Assert.ShouldNeverReachHere();
         }
     }
 }
Exemplo n.º 16
0
 /// <summary>
 /// Returns items whose bounds intersect the given envelope.
 /// </summary>
 /// <param name="searchEnv"></param>
 /// <param name="visitor"></param>
 public void Query(IEnvelope searchEnv, IItemVisitor visitor)
 {
     //Yes this method does something. It specifies that the bounds is an
     //Envelope. super.query takes an Object, not an Envelope. [Jon Aquino 10/24/2003]
     base.Query(searchEnv, visitor);
 }
Exemplo n.º 17
0
 //public override string GetView(IViewer viewer)
 //{
 //    return viewer.View(this);
 //}
 public override string AcceptViewVisitor(IItemVisitor visitor)
 {
     return(visitor.Visit(this));
 }
Exemplo n.º 18
0
 /// <summary>
 /// Returns items whose bounds intersect the given envelope.
 /// </summary>
 /// <param name="searchEnv"></param>
 /// <param name="visitor"></param>
 public new void Query(Envelope searchEnv, IItemVisitor <TItem> visitor)
 {
     //Yes this method does something. It specifies that the bounds is an
     //Envelope. super.query takes an Object, not an Envelope. [Jon Aquino 10/24/2003]
     base.Query(searchEnv, visitor);
 }
Exemplo n.º 19
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="searchEnv"></param>
        /// <param name="visitor"></param>
        public virtual void Visit(IEnvelope searchEnv, IItemVisitor visitor)
        {
            if (!IsSearchMatch(searchEnv))
                return;

            // this node may have items as well as subnodes (since items may not
            // be wholely contained in any single subnode
            VisitItems(searchEnv, visitor);

            for (int i = 0; i < 4; i++)
                if (_subnode[i] != null)
                    _subnode[i].Visit(searchEnv, visitor);
        }
 public abstract decimal Accept(IItemVisitor visitor);
Exemplo n.º 21
0
 private void Query(object searchBounds, AbstractNode node, IItemVisitor visitor)
 {
     foreach (var obj in node.ChildBoundables)
     {
         var childBoundable = (IBoundable)obj;
         if (!IntersectsOp.Intersects(childBoundable.Bounds, searchBounds))
             continue;
         if (childBoundable is AbstractNode)
             Query(searchBounds, (AbstractNode)childBoundable, visitor);
         else if (childBoundable is ItemBoundable)
             visitor.VisitItem(((ItemBoundable)childBoundable).Item);
         else Assert.ShouldNeverReachHere();
     }
 }
Exemplo n.º 22
0
        protected void Query(Object searchBounds, IItemVisitor visitor)
        {
            if (!built)
                Build();

            if (itemBoundables.Count == 0)
                Assert.IsTrue(root.Bounds == null);

            if (IntersectsOp.Intersects(root.Bounds, searchBounds))
                Query(searchBounds, root, visitor);
        }
Exemplo n.º 23
0
 //public virtual string GetView(IViewer viewer)
 //{
 //    return "base";
 //}
 public virtual string AcceptViewVisitor(IItemVisitor visitor)
 {
     return(visitor.Visit(this));
 }
Exemplo n.º 24
0
 public abstract void Query(double queryMin, double queryMax, IItemVisitor <T> visitor);
Exemplo n.º 25
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="searchEnv"></param>
 /// <param name="visitor"></param>
 private void VisitItems(IEnvelope searchEnv, IItemVisitor visitor)
 {
     // would be nice to filter items based on search envelope, but can't until they contain an envelope
     for (IEnumerator i = _items.GetEnumerator(); i.MoveNext(); )
         visitor.VisitItem(i.Current);
 }
Exemplo n.º 26
0
        ///<summary>
        /// Search for intervals in the index which intersect the given closed interval
        /// and apply the visitor to them.
        ///</summary>
        /// <param name="min">The lower bound of the query interval</param>
        /// <param name="max">The upper bound of the query interval</param>
        /// <param name="visitor">The visitor to pass any matched items to</param>
        public void Query(double min, double max, IItemVisitor <T> visitor)
        {
            Init();

            _root.Query(min, max, visitor);
        }
Exemplo n.º 27
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="searchEnv"></param>
 /// <param name="visitor"></param>
 public void Query(IEnvelope searchEnv, IItemVisitor visitor)
 {
     /*
     * the items that are matched are the items in quads which
     * overlap the search envelope
     */
     root.Visit(searchEnv, visitor);
 }
            /*
             * public IList Query(double min, double max)
             * {
             *  ArrayListVisitor visitor = new ArrayListVisitor();
             *  index.Query(min, max, visitor);
             *  return visitor.Items;
             * }
             */

            public void Query(double min, double max, IItemVisitor <LineSegment> visitor)
            {
                _index.Query(min, max, visitor);
            }
 public override decimal Accept(IItemVisitor visitor) => Math.Round(visitor.Visit(this), 2);
Exemplo n.º 30
0
 public virtual void Accept(IItemVisitor visitor) => visitor.Visit((dynamic)this);