/** * @param env * to get the leafObjects for. * @return the leafObjects which intersect with this node and or it's children, or the empty list. */ @Override public List<T> query( float[] env ) { Set<Entry<T>> r = new HashSet<Entry<T>>(); getObjects( env, r ); return getEntrySetAsResult( r ); }
/** * Convenience method to retrieve the objects intersecting with the given envelope. * * @param envelope * @return a List with all objects intersecting with the given envelope. */ protected List<T> getObjects( float[] envelope ) { Set<Entry<T>> r = new HashSet<Entry<T>>(); getObjects( envelope, r ); return getEntrySetAsResult( r ); }
/** * @return the leafObjects which intersect with this node and or it's children, or the empty list. */ public List<T> getObjects() { Set<Entry<T>> r = new HashSet<Entry<T>>(); getObjects( envelope, r ); return getEntrySetAsResult( r ); }
private Set<Entry<T>> validateChildrenSize() { boolean possibleMerge = true; Set<Entry<T>> childrenInLeaf = new HashSet<Entry<T>>(); if ( !isLeaf() ) { for ( int i = 0; i < children.length; ++i ) { QTree<T> n = children[i]; if ( n != null ) { if ( n.isLeaf() ) { // if one of the other children wasn't a leaf, don't bother getting the objects if ( possibleMerge ) { n.getObjects( n.envelope, childrenInLeaf ); } // the child is a leaf but does not contain any leafObjects, no need to keep it in memory. if ( n.leafObjects == null && n.objectsCoveringEnv == null ) { children[i] = null; } } else { // no merging, but check other children if they can be deleted. possibleMerge = false; } } } } return possibleMerge ? childrenInLeaf : null; }
private final void getObjects( float[] envelope, Set<Entry<T>> result ) { if ( intersects( this.envelope, envelope, maxOffset ) ) { if ( hasCoveringObjects() ) { result.addAll( objectsCoveringEnv ); } if ( isLeaf() ) { if ( leafObjects != null ) { for ( Entry<T> e : leafObjects ) { if ( intersects( envelope, e.entryEnv, maxOffset ) && !result.contains( e.entryValue ) ) { result.add( e ); } } } } else { for ( QTree<T> n : children ) { if ( n != null ) { n.getObjects( envelope, result ); } } } } }