|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.infomatiq.jsi.rtree.RTree
public class RTree
This is a lightweight RTree implementation, specifically designed for the following features (in order of importance):
The main reason for the high speed of this RTree implementation is the avoidance of the creation of unnecessary objects, mainly achieved by using primitive collections from the trove4j library.
Constructor Summary | |
---|---|
RTree()
Constructor. |
Method Summary | |
---|---|
void |
add(Rectangle r,
int id)
Adds a new rectangle to the spatial index |
boolean |
checkConsistency()
Check the consistency of the tree. |
void |
contains(Rectangle r,
gnu.trove.TIntProcedure v)
Finds all rectangles contained by the passed rectangle. |
boolean |
delete(Rectangle r,
int id)
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. |
int |
getHighestUsedNodeId()
Get the highest used node ID |
Node |
getNode(int id)
Get a node object, given the ID of the node. |
int |
getRootNodeId()
Get the root node ID |
String |
getVersion()
Returns a string identifying the type of spatial index, and the version number, eg "SimpleIndex-0.1" |
void |
init(Properties props)
Initialize implementation dependent properties of the RTree. |
void |
intersects(Rectangle r,
gnu.trove.TIntProcedure v)
Finds all rectangles that intersect the passed rectangle. |
void |
nearest(Point p,
gnu.trove.TIntProcedure v,
float furthestDistance)
Finds the nearest rectangles to the passed rectangle and calls v.execute(id) for each one. |
void |
nearestN_orig(Point p,
gnu.trove.TIntProcedure v,
int count,
float furthestDistance)
Deprecated. Use new NearestN or NearestNUnsorted instead. This implementation of nearestN is only suitable for small values of N (ie less than 10). |
void |
nearestN(Point p,
gnu.trove.TIntProcedure v,
int count,
float furthestDistance)
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 p,
gnu.trove.TIntProcedure v,
int count,
float furthestDistance)
Same as nearestN, except the found rectangles are not returned in sorted order. |
int |
size()
Returns the number of entries in the spatial index |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public RTree()
Method Detail |
---|
public void init(Properties props)
Initialize implementation dependent properties of the RTree. Currently implemented properties are:
init
in interface SpatialIndex
props
- The set of properties used to initialize the spatial index.SpatialIndex.init(Properties)
public void add(Rectangle r, int id)
SpatialIndex
add
in interface SpatialIndex
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.SpatialIndex.add(Rectangle, int)
public boolean delete(Rectangle r, int id)
SpatialIndex
delete
in interface SpatialIndex
r
- The rectangle to delete from the spatial indexid
- The ID of the rectangle to delete from the spatial
index
SpatialIndex.delete(Rectangle, int)
public void nearest(Point p, gnu.trove.TIntProcedure v, float furthestDistance)
SpatialIndex
nearest
in interface SpatialIndex
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.SpatialIndex.nearest(Point, TIntProcedure, float)
public void nearestNUnsorted(Point p, gnu.trove.TIntProcedure v, int count, float furthestDistance)
SpatialIndex
nearestNUnsorted
in interface SpatialIndex
SpatialIndex.nearestNUnsorted(Point, TIntProcedure, int, float)
public void nearestN(Point p, gnu.trove.TIntProcedure v, int count, float furthestDistance)
SpatialIndex
nearestN
in interface SpatialIndex
p
- The point for which this method finds the
nearest neighbours.v
- The IntfloatProcedure whose execute() method is is called
for each nearest neighbour.count
- The desired number of rectangles to find (but note that
fewer or more may be returned)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.SpatialIndex.nearestN(Point, TIntProcedure, int, float)
public void nearestN_orig(Point p, gnu.trove.TIntProcedure v, int count, float furthestDistance)
SpatialIndex.nearestN(Point, TIntProcedure, int, float)
public void intersects(Rectangle r, gnu.trove.TIntProcedure v)
SpatialIndex
intersects
in interface SpatialIndex
r
- The rectangle for which this method finds
intersecting rectangles.v
- The IntProcedure whose execute() method is is called
for each intersecting rectangle.SpatialIndex.intersects(Rectangle, TIntProcedure)
public void contains(Rectangle r, gnu.trove.TIntProcedure v)
SpatialIndex
contains
in interface SpatialIndex
r
- The rectangle for which this method finds
contained rectangles.v
- The procedure whose visit() method is is called
for each contained rectangle.SpatialIndex.contains(Rectangle, TIntProcedure)
public int size()
SpatialIndex
size
in interface SpatialIndex
SpatialIndex.size()
public Rectangle getBounds()
SpatialIndex
getBounds
in interface SpatialIndex
SpatialIndex.getBounds()
public String getVersion()
SpatialIndex
getVersion
in interface SpatialIndex
SpatialIndex.getVersion()
public Node getNode(int id)
public int getHighestUsedNodeId()
public int getRootNodeId()
public boolean checkConsistency()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |