Пример #1
0
        public bool RemoveAnnotation(IMKAnnotation annotation, FBQuadTreeNode fromNode)
        {
            if (!FBUtils.FBBoundingBoxContainsCoordinate(fromNode.BoundingBox, annotation.Coordinate))
            {
                return(false);
            }

            if (fromNode.Annotations.Contains(annotation))
            {
                fromNode.Annotations.Remove(annotation);
                fromNode.Count--;
                return(true);
            }

            if (RemoveAnnotation(annotation, fromNode.NorthEast))
            {
                return(true);
            }
            if (RemoveAnnotation(annotation, fromNode.NorthWest))
            {
                return(true);
            }
            if (RemoveAnnotation(annotation, fromNode.SouthEast))
            {
                return(true);
            }
            if (RemoveAnnotation(annotation, fromNode.SouthWest))
            {
                return(true);
            }

            return(false);
        }
Пример #2
0
        public void EnumerateAnnotationsInBox(FBBoundingBox box, FBQuadTreeNode withNode, AnnotationEnumDelegate enumFunc)
        {
            if (!FBUtils.FBBoundingBoxIntersectsBoundingBox(withNode.BoundingBox, box))
            {
                return;
            }

            List <IMKAnnotation> tempArray = new List <IMKAnnotation>(withNode.Annotations);

            foreach (IMKAnnotation annotation in tempArray)
            {
                if (FBUtils.FBBoundingBoxContainsCoordinate(box, annotation.Coordinate))
                {
                    enumFunc(annotation);
                }
            }

            if (withNode.IsLeaf())
            {
                return;
            }

            EnumerateAnnotationsInBox(box, withNode.NorthEast, enumFunc);
            EnumerateAnnotationsInBox(box, withNode.NorthWest, enumFunc);
            EnumerateAnnotationsInBox(box, withNode.SouthEast, enumFunc);
            EnumerateAnnotationsInBox(box, withNode.SouthWest, enumFunc);
        }
Пример #3
0
        public bool InsertAnnotation(IMKAnnotation annotation, FBQuadTreeNode toNode)
        {
            if (!FBUtils.FBBoundingBoxContainsCoordinate(toNode.BoundingBox, annotation.Coordinate))
            {
                return(false);
            }

            if (toNode.Count < FBConsts.kNodeCapacity)
            {
                toNode.Annotations.Add(annotation);
                toNode.Count++;
                return(true);
            }

            if (toNode.IsLeaf())
            {
                toNode.Subdivide();
            }

            if (InsertAnnotation(annotation, toNode.NorthEast))
            {
                return(true);
            }
            if (InsertAnnotation(annotation, toNode.NorthWest))
            {
                return(true);
            }
            if (InsertAnnotation(annotation, toNode.SouthEast))
            {
                return(true);
            }
            if (InsertAnnotation(annotation, toNode.SouthWest))
            {
                return(true);
            }

            return(false);
        }