|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.bbn.openmap.util.quadtree.QuadTreeNode<T>
public class QuadTreeNode<T>
The QuadTreeNode is the part of the QuadTree that either holds children nodes, or objects as leaves. Currently, the nodes that have children do not hold items that span across children boundaries, since this was designed to handle point data.
Field Summary | |
---|---|
protected boolean |
allTheSamePoint
Added to avoid problems when a node is completely filled with a single point value. |
QuadTreeRect |
bounds
|
protected java.util.Collection<QuadTreeNode<T>> |
children
|
static float |
DEFAULT_MIN_SIZE
|
protected double |
firstLat
|
protected double |
firstLon
|
protected java.util.Collection<QuadTreeLeaf<T>> |
items
|
protected int |
maxItems
|
protected double |
minSize
|
static float |
NO_MIN_SIZE
|
Constructor Summary | |
---|---|
QuadTreeNode(double north,
double west,
double south,
double east,
int maximumItems)
Constructor to use if you are going to store the objects in lat/lon space, and there is really no smallest node size. |
|
QuadTreeNode(double north,
double west,
double south,
double east,
int maximumItems,
double minimumSize)
Constructor to use if you are going to store the objects in x/y space, and there is a smallest node size because you don't want the nodes to be smaller than a group of pixels. |
Method Summary | |
---|---|
void |
clear()
Clear the tree below this node. |
T |
get(double lat,
double lon)
Get an object closest to a lat/lon. |
T |
get(double lat,
double lon,
double withinDistance)
Get an object closest to a lat/lon. |
java.util.Collection<T> |
get(double north,
double west,
double south,
double east)
Get all the objects within a bounding box. |
java.util.Collection<T> |
get(double north,
double west,
double south,
double east,
java.util.Collection<T> collection)
Get all the objects within a bounding box. |
T |
get(double lat,
double lon,
MutableDistance bestDistance)
Get an object closest to a lat/lon. |
java.util.Collection<T> |
get(QuadTreeRect rect,
java.util.Collection<T> collection)
Get all the objects within a bounding box. |
protected QuadTreeNode<T> |
getChild(double lat,
double lon)
Get the node that covers a certain lat/lon pair. |
boolean |
hasChildren()
Return true if the node has children. |
boolean |
put(double lat,
double lon,
T obj)
Add a object into the tree at a location. |
boolean |
put(QuadTreeLeaf<T> leaf)
Add a QuadTreeLeaf into the tree at a location. |
T |
remove(double lat,
double lon,
T obj)
Remove a object out of the tree at a location. |
T |
remove(QuadTreeLeaf<T> leaf)
Remove a QuadTreeLeaf out of the tree at a location. |
protected void |
split()
This method splits the node into four children, and disperses the items into the children. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final float NO_MIN_SIZE
public static final float DEFAULT_MIN_SIZE
protected java.util.Collection<QuadTreeLeaf<T>> items
protected java.util.Collection<QuadTreeNode<T>> children
protected int maxItems
protected double minSize
public QuadTreeRect bounds
protected boolean allTheSamePoint
protected double firstLat
protected double firstLon
Constructor Detail |
---|
public QuadTreeNode(double north, double west, double south, double east, int maximumItems)
north
- northern border of node coverage.west
- western border of node coverage.south
- southern border of node coverage.east
- eastern border of node coverage.maximumItems
- number of items to hold in a node before splitting
itself into four children and redispensing the items into them.public QuadTreeNode(double north, double west, double south, double east, int maximumItems, double minimumSize)
north
- northern border of node coverage.west
- western border of node coverage.south
- southern border of node coverage.east
- eastern border of node coverage.maximumItems
- number of items to hold in a node before splitting
itself into four children and redispensing the items into them.minimumSize
- the minimum difference between the boundaries of the
node.Method Detail |
---|
public boolean hasChildren()
protected void split()
protected QuadTreeNode<T> getChild(double lat, double lon)
lat
- up-down location in QuadTree Grid (latitude, y)lon
- left-right location in QuadTree Grid (longitude, x)
public boolean put(double lat, double lon, T obj)
lat
- up-down location in QuadTree Grid (latitude, y)lon
- left-right location in QuadTree Grid (longitude, x)obj
- object to add to the tree.
public boolean put(QuadTreeLeaf<T> leaf)
leaf
- object-location composite
public T remove(double lat, double lon, T obj)
lat
- up-down location in QuadTree Grid (latitude, y)lon
- left-right location in QuadTree Grid (longitude, x)obj
- the object to be removed.
public T remove(QuadTreeLeaf<T> leaf)
leaf
- object-location composite
public void clear()
public T get(double lat, double lon)
lat
- up-down location in QuadTree Grid (latitude, y)lon
- left-right location in QuadTree Grid (longitude, x)
public T get(double lat, double lon, double withinDistance)
lat
- up-down location in QuadTree Grid (latitude, y)lon
- left-right location in QuadTree Grid (longitude, x)withinDistance
- maximum get distance.
public T get(double lat, double lon, MutableDistance bestDistance)
lat
- up-down location in QuadTree Grid (latitude, y)lon
- left-right location in QuadTree Grid (longitude, x)bestDistance
- the closest distance of the object found so far.
public java.util.Collection<T> get(double north, double west, double south, double east)
north
- top location in QuadTree Grid (latitude, y)west
- left location in QuadTree Grid (longitude, x)south
- lower location in QuadTree Grid (latitude, y)east
- right location in QuadTree Grid (longitude, x)
public java.util.Collection<T> get(double north, double west, double south, double east, java.util.Collection<T> collection)
north
- top location in QuadTree Grid (latitude, y)west
- left location in QuadTree Grid (longitude, x)south
- lower location in QuadTree Grid (latitude, y)east
- right location in QuadTree Grid (longitude, x)collection
- current Collection of objects.
public java.util.Collection<T> get(QuadTreeRect rect, java.util.Collection<T> collection)
rect
- boundary of area to fill.collection
- current Collection of objects.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |