Envelope2D getExtent ( int quad_handle ) { Envelope2D quad_extent = new Envelope2D ( ) ; quad_extent . setCoords ( m_extent ) ; if ( quad_handle == m_root ) return quad_extent ; AttributeStreamOfInt32 quadrants = new AttributeStreamOfInt32 ( 0 ) ; int q = quad_handle ; do { quadrants . add ( get_quadrant_ ( q ) ) ; q = get_parent_ ( q ) ; } while ( q != m_root ) ; int sz = quadrants . size ( ) ; assert ( sz == getHeight ( quad_handle ) ) ; for ( int i = 0 ; i < sz ; i ++ ) { int child = quadrants . getLast ( ) ; quadrants . removeLast ( ) ; if ( child == 0 ) { //northeast quad_extent . xmin = 0.5 * ( quad_extent . xmin + quad_extent . xmax ) ; quad_extent . ymin = 0.5 * ( quad_extent . ymin + quad_extent . ymax ) ; } else if ( child == 1 ) { //northwest quad_extent . xmax = 0.5 * ( quad_extent . xmin + quad_extent . xmax ) ; quad_extent . ymin = 0.5 * ( quad_extent . ymin + quad_extent . ymax ) ; } else if ( child == 2 ) { //southwest quad_extent . xmax = 0.5 * ( quad_extent . xmin + quad_extent . xmax ) ; quad_extent . ymax = 0.5 * ( quad_extent . ymin + quad_extent . ymax ) ; } else { //southeast quad_extent . xmin = 0.5 * ( quad_extent . xmin + quad_extent . xmax ) ; quad_extent . ymax = 0.5 * ( quad_extent . ymin + quad_extent . ymax ) ; } } return quad_extent ; }
Returns the extent of the quad at the given quad_handle . \ param quad_handle The handle corresponding to the quad .