public abstract class BitSetQuadTreeFilter
extends java.lang.Object
doOperation(int, int, double[], double[])
method is called for each leaf or
intermediate cell that intersects the item. That method typically stores the item's association with the intersecting
cell, either to populate a quadtree membership list or to mark it as a visible item.
The filter uses a bit-set to identify cells that intersect submitted items. This minimal memory eliminates the need
to retain cell information other than identity. Only cell identities are retained by this abstract class. Subclasses
provide the means to retain item information associated with intersecting cells.Modifier and Type | Class and Description |
---|---|
static class |
BitSetQuadTreeFilter.FindIntersectingBitsOp
A quadtree filter that determines the bit positions of cells associated with items and intersecting a specified
region.
|
Modifier and Type | Field and Description |
---|---|
protected java.util.BitSet |
bits |
protected int[] |
levelSizes |
protected int |
maxLevel |
protected int |
numLevels |
protected int[] |
path |
protected int[] |
powersOf4 |
protected boolean |
stopped |
Constructor and Description |
---|
BitSetQuadTreeFilter(int numLevels,
java.util.BitSet bitSet)
Constructs an instance of this class.
|
Modifier and Type | Method and Description |
---|---|
protected int |
computeBitPosition(int level,
int position)
Computes the bit position of a quadtree cell.
|
protected static int[] |
computeLevelSizes(int numLevels)
An internal method that computes the number of ancestor cells at each level.
|
protected abstract boolean |
doOperation(int level,
int position,
double[] cellRegion,
double[] itemCoords)
A method implemented by subclasses and called during tree traversal to perform an operation on an intersecting
item.
|
int |
getNumLevels()
Returns the number of levels in the filter.
|
protected int |
intersects(double[] cellRegion,
double[] itemCoords)
Determines whether an item intersects a cell.
|
boolean |
isStopped()
Indicates whether traversal has been stopped.
|
void |
start()
Re-initialize for traversal.
|
void |
stop()
Stop the current traversal of the quadtree.
|
protected void |
testAndDo(int level,
int position,
double[] cellRegion,
double[] itemCoords)
The main, recursive traversal method.
|
protected java.util.BitSet bits
protected int[] levelSizes
protected int maxLevel
protected int numLevels
protected int[] path
protected int[] powersOf4
protected boolean stopped
public BitSetQuadTreeFilter(int numLevels, java.util.BitSet bitSet)
numLevels
- the number of levels in the quadtree.bitSet
- a BitSet
to use as the quadtree index. If null, a new set is created. Depending on the
operation, the bit-set is modified or only read.java.lang.IllegalArgumentException
- if numLevels
is less than 1.protected int computeBitPosition(int level, int position)
level
- the quadtree level currently being traversed.position
- the position of the cell in its parent cell, either 0, 1, 2, or 3. Cell positions starts with 0
at the southwest corner of the parent cell and increment counter-clockwise: cell 1 is SE, cell 2
is NE and cell 3 is NW.protected static int[] computeLevelSizes(int numLevels)
numLevels
- the number of quadtree levels.numLevels + 1
elements containing the sums of ancestor-level cell counts for
each quadtree level. The last element in the array contains the total number of cells in the tree.protected abstract boolean doOperation(int level, int position, double[] cellRegion, double[] itemCoords)
BasicQuadTree
and BitSetQuadTreeFilter.FindIntersectingBitsOp
.level
- the quadtree level currently being traversed.position
- the position of the cell in its parent cell, either 0, 1, 2, or 3. Cell positions starts with 0
at the southwest corner of the parent cell and increment counter-clockwise: cell 1 is SE, cell
2 is NE and cell 3 is NW.cellRegion
- an array specifying the coordinates of the cell's region. The first two entries are the minimum
and maximum values on the Y axis (typically latitude). The last two entries are the minimum and
maximum values on the X axis, (typically longitude).itemCoords
- an array specifying the region or location of the intersecting item. If the array's length is 2
it represents a location in [latitude, longitude]. If its length is 4 it represents a region,
with the same layout as the nodeRegion
argument.public int getNumLevels()
protected int intersects(double[] cellRegion, double[] itemCoords)
cellRegion
- an array specifying the coordinates of the cell's region. The first two entries are the minimum
and maximum values on the Y axis (typically latitude). The last two entries are the minimum and
maximum values on the X axis, (typically longitude).itemCoords
- an array specifying the region or location of the item. If the array's length is 2 it
represents a location in [latitude, longitude]. If its length is 4 it represents a region, with
the same layout as the nodeRegion
argument.public boolean isStopped()
true
if traversal has been stopped, otherwise false.public void start()
stop()
.public void stop()
start()
must be called before attempting a subsequent
traversal.protected void testAndDo(int level, int position, double[] cellRegion, double[] itemCoords)
doOperation(int, int, double[], double[])
method returns false.level
- the quadtree level currently being traversed.position
- the position o f the cell in its parent cell, either 0, 1, 2, or 3. Cell positions starts with
0 at the southwest corner of the parent cell and increment counter-clockwise: cell 1 is SE,
cell 2 is NE and cell 3 is NW.cellRegion
- an array specifying the coordinates of the cell's region. The first two entries are the minimum
and maximum values on the Y axis (typically latitude). The last two entries are the minimum and
maximum values on the X axis, (typically longitude).itemCoords
- an array specifying the region or location of the item. If the array's length is 2 it
represents a location in [latitude, longitude]. If its length is 4 it represents a region, with
the same layout as the nodeRegion
argument.