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; }
private Node CreateSubnode( int index ) { // create a new subquad in the appropriate quadrant double minx = 0.0; double maxx = 0.0; double miny = 0.0; double maxy = 0.0; switch (index) { case 0: minx = _env.MinX; maxx = _centre.X; miny = _env.MinY; maxy = _centre.Y; break; case 1: minx = _centre.X; maxx = _env.MaxX; miny = _env.MinY; maxy = _centre.Y; break; case 2: minx = _env.MinX; maxx = _centre.X; miny = _centre.Y; maxy = _env.MaxY; break; case 3: minx = _centre.X; maxx = _env.MaxX; miny = _centre.Y; maxy = _env.MaxY; break; } Envelope sqEnv = new Envelope( minx, maxx, miny, maxy ); Node node = new Node( sqEnv, _level - 1 ); return node; }
public static Node CreateNode( Envelope env ) { Key key = new Key( env ); Node node = new Node( key.Envelope, key.Level ); return node; }
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; } }