public interface SpatialIndex
| Modifier and Type | Method and Description |
|---|---|
void |
add(Rectangle
Adds a new rectangle to the spatial index
|
void |
contains(Rectangle
Finds all rectangles contained by the passed rectangle.
|
boolean |
delete(Rectangle
Deletes a rectangle from the spatial index
|
Rectangle |
getBounds()
Returns the bounds of all the entries in the spatial index, or null if there are no entries.
|
void |
intersects(Rectangle
Finds all rectangles that intersect the passed rectangle.
|
void |
nearest(Point
Finds the nearest rectangles to the passed rectangle and calls v.execute(id) for each one.
|
void |
nearestN(Point
Finds the N nearest rectangles to the passed rectangle, and calls execute(id, distance) on each one, in order of increasing distance.
|
void |
nearestNUnsorted(Point
Same as nearestN, except the found rectangles are not returned in sorted order.
|
int |
size()
Returns the number of entries in the spatial index
|
void add(Rectangler, int id)
r - The rectangle to add to the spatial index.
id - The ID of the rectangle to add to the spatial index. The result of adding more than one rectangle with the same ID is undefined.
boolean delete(Rectangler, int id)
r - The rectangle to delete from the spatial index
id - The ID of the rectangle to delete from the spatial index
void nearest(Pointp, TIntProcedure v, float furthestDistance)
p - The point for which this method finds the nearest neighbours.
v - The IntProcedure whose execute() method is is called for each nearest neighbour.
furthestDistance - The furthest distance away from the rectangle to search. Rectangles further than this will not be found. This should be as small as possible to minimise the search time. Use Float.POSITIVE_INFINITY to guarantee that the nearest rectangle is found, no matter how far away, although this will slow down the algorithm.
void nearestN(Pointp, TIntProcedure v, int n, float distance)
p - The point for which this method finds the nearest neighbours.
v - The IntfloatProcedure whose execute() method is is called for each nearest neighbour.
n - The desired number of rectangles to find (but note that fewer or more may be returned)
distance - The furthest distance away from the rectangle to search. Rectangles further than this will not be found. This should be as small as possible to minimise the search time. Use Float.POSITIVE_INFINITY to guarantee that the nearest rectangle is found, no matter how far away, although this will slow down the algorithm.
void nearestNUnsorted(Pointp, TIntProcedure v, int n, float distance)
void intersects(Rectangler, TIntProcedure ip)
r - The rectangle for which this method finds intersecting rectangles.
ip - The IntProcedure whose execute() method is is called for each intersecting rectangle.
void contains(Rectangler, TIntProcedure ip)
r - The rectangle for which this method finds contained rectangles.
ip - The procedure whose visit() method is is called for each contained rectangle.
int size()
RectanglegetBounds()