예제 #1
0
        void InsertNode(Node node)
        {
            //Assert.isTrue(env == null || env.contains(node.env));
            if (!(_env == null || _env.Contains(node.Envelope)))
            {
                throw new InvalidOperationException();
            }
            //System.out.println(env);
            //System.out.println(quad.env);
            int index = GetSubnodeIndex(node.Envelope, _centre);

            //System.out.println(index);
            if (node.Level == _level - 1)
            {
                _subnode[index] = node;
                //System.out.println("inserted");
            }
            else
            {
                // the quad is not a direct child, so make a new child quad to contain it
                // and recursively insert the quad
                Node childNode = CreateSubnode(index);
                childNode.InsertNode(node);
                _subnode[index] = childNode;
            }
        }
예제 #2
0
        public static Node CreateExpanded(Node node, Envelope addEnv)
        {
            Envelope expandEnv = new Envelope(addEnv);

            if (node != null)
            {
                expandEnv.ExpandToInclude(node.Envelope);
            }

            Node largerNode = CreateNode(expandEnv);

            if (node != null)
            {
                largerNode.InsertNode(node);
            }
            return(largerNode);
        }