Example #1
0
        public static CKTree New(MKMapRect rect, int capacity)
        {
            CKTree tree = new CKTree();

            tree.Root = CKNode.New(rect, capacity);
            return(tree);
        }
Example #2
0
        public static void Cleart(CKTree tree)
        {
            var bound    = tree.Root.Bound;
            var capacity = tree.Root.Capacity;

            CKNode.NodeFree(tree.Root);
            tree.Root = CKNode.New(bound, capacity);
        }
Example #3
0
        public static void Subdivide(CKNode node)
        {
            MKMapRect bd = node.Bound;
            MKMapRect nw;
            MKMapRect ne;
            MKMapRect sw;
            MKMapRect se;

            nw = bd.Divide(bd.Width / 2, CoreGraphics.CGRectEdge.MaxXEdge, out ne);
            nw = nw.Divide(nw.Height / 2, CoreGraphics.CGRectEdge.MaxYEdge, out sw);
            ne = ne.Divide(ne.Height / 2, CoreGraphics.CGRectEdge.MaxYEdge, out se);

            node.NW = CKNode.New(nw, node.Capacity);
            node.NE = CKNode.New(ne, node.Capacity);
            node.SW = CKNode.New(sw, node.Capacity);
            node.SE = CKNode.New(se, node.Capacity);
        }