/** * @param env * @return a list of objects intersecting the given boundingbox. */ @Override public LinkedList<T> query( float[] env ) { if ( root != null ) { // final float[] bbox = new float[] { env.getMin().get0(), env.getMin().get1(), // env.getMax().get0(), env.getMax().get1() }; if ( intersects( env, this.rootbbox, 2 ) ) { return query( env, root ); } } LOG.debug( "Querying either a null tree or with a envelope that does not intersect it... returning." ); return new LinkedList<T>(); }
private LinkedList<T> query( final float[] bbox, NodeEntry<T>[] node ) { LinkedList<T> list = new LinkedList<T>(); for ( NodeEntry<T> e : node ) { if ( e != null && intersects( bbox, e.bbox, 2 ) ) { if ( e.next == null ) { list.add( e.entryValue ); // rb: uncommented if ( ( list.size() >= bigM * 10 && outputWarning ) ) { outputWarning = false; // LOG.warn( // "Collecting features should stop because {} features were loaded, which was 10 times larger then the maxNumberOfObjects {} (which is currently hardcoded). Continue filling the list though.", // list.size(), this.maxNumberOfObjects ); // return list; } } else { list.addAll( query( bbox, e.next ) ); if ( ( list.size() >= bigM * 10 ) && outputWarning ) { outputWarning = false; // LOG.warn( // "Collecting features should stop because {} features were loaded, which was 10 times larger then the maxNumberOfObjects {} (which is currently hardcoded). Continue filling the list though.", // list.size(), this.maxNumberOfObjects ); // return list; } } } } return list; }
/** * Choose the index at which the entries shall be split when inserting insertBox. * * @param entries * @param insertBox * @param object */ private int split( NodeEntry<T>[] entries, float[] insertBox, T object ) { if ( entries[0].next == null ) { // leaf node splitAxis( entries ); } double minValue = Double.MAX_VALUE; int splitIndex = -1; for ( int i = smallm - 1; i < bigM + 1 - smallm; i++ ) { float[][] leftSide = copyBoxesFromRange( entries, 0, i + 1 ); float[][] rightSide = copyBoxesFromRange( entries, i + 1, bigM + 1 ); double currentVal; if ( !intersects( mbb( leftSide ), mbb( rightSide ), 2 ) ) { currentVal = wgFunction( leftSide, rightSide ) * wfFunction( i ); } else { currentVal = wgFunction( leftSide, rightSide ) / wfFunction( i ); } if ( currentVal < minValue ) { minValue = currentVal; splitIndex = i; } } return splitIndex; }