Beispiel #1
0
        public static bool Drop(CKNode node, MKAnnotation annotation)
        {
            CKPoint cur  = node.Points;
            CKPoint prev = null;

            while (cur != null)
            {
                prev = cur;
                cur  = cur.Next;

                if (cur.Annotation == annotation)
                {
                    if (prev == null)
                    {
                        node.Points = cur.Next;
                    }
                    else
                    {
                        prev.Next = cur.Next;
                    }
                    node.Count--;
                    return(true);
                }
            }

            return(false);
        }
Beispiel #2
0
        public static void GetInRange(CKNode node, MKMapRect range, Action <IMKAnnotation> find)
        {
            if (node.Count != null)
            {
                if (MKMapRect.Intersects(node.Bound, range) == false)
                {
                    return;
                }

                CKPoint point = node.Points;
                while (point != null)
                {
                    if (range.Contains(point.Point))
                    {
                        find?.Invoke(point.Annotation);
                    }

                    point = point.Next;
                }
            }

            if (node.NW != null)
            {
                CKNode.GetInRange(node.NW, range, find);
                CKNode.GetInRange(node.NE, range, find);
                CKNode.GetInRange(node.SW, range, find);
                CKNode.GetInRange(node.SE, range, find);
            }
        }
Beispiel #3
0
 public static void PointFree(CKPoint point)
 {
     if (point != null)
     {
         PointFree(point.Next);
         point = null;
     }
 }
Beispiel #4
0
        public static bool Insert(CKNode node, MKAnnotation annotation)
        {
            var point = MKMapPoint.FromCoordinate(annotation.Coordinate);

            if (!node.Bound.Contains(point))
            {
                return(false);
            }

            if (node.Count < node.Capacity)
            {
                CKPoint tPoint = new CKPoint();
                tPoint.Annotation = annotation;
                tPoint.Point      = point;
                CKNode.Add(node, tPoint);
                return(true);
            }

            if (node.NW == null)
            {
                CKNode.Subdivide(node);
            }

            if (CKNode.Insert(node.NW, annotation))
            {
                return(true);
            }

            if (CKNode.Insert(node.NE, annotation))
            {
                return(true);
            }

            if (CKNode.Insert(node.SW, annotation))
            {
                return(true);
            }

            if (CKNode.Insert(node.SE, annotation))
            {
                return(true);
            }

            return(false);
        }
Beispiel #5
0
 public static void Add(CKNode node, CKPoint point)
 {
     point.Next  = node.Points;
     node.Points = point;
     node.Count++;
 }