com.infomatiq.jsi
Interface SpatialIndex

All Known Implementing Classes:
RTree

public interface SpatialIndex

Defines methods that must be implemented by all spatial indexes. This includes the RTree and its variants.

Version:
1.0b1
Author:
aled.morris@infomatiq.co.uk

Method Summary
 void add(Rectangle r, int id)
          Adds a new rectangle to the spatial index
 void contains(Rectangle r, IntProcedure ip)
          Finds all rectangles contained by the passed rectangle.
 boolean delete(Rectangle r, int id)
          Deletes a rectangle from the spatial index
 java.lang.String getVersion()
          Returns a string identifying the type of spatial index, and the version number, eg "SimpleIndex-1.0b1"
 void init(java.util.Properties props)
          Initializes any implementation dependent properties of the spatial index.
 void intersects(Rectangle r, IntProcedure ip)
          Finds all rectangles that intersect the passed rectangle.
 void nearest(Point p, IntProcedure v, float distance)
          Finds all rectangles that are nearest to the passed rectangle, and calls execute() on the passed IntProcedure for each one.
 int size()
          Returns the number of entries in the spatial index
 

Method Detail

init

public void init(java.util.Properties props)
Initializes any implementation dependent properties of the spatial index. For example, RTree implementations will have a NodeSize property.

Parameters:
props - The set of properties used to initialize the spatial index.

add

public void add(Rectangle r,
                int id)
Adds a new rectangle to the spatial index

Parameters:
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.

delete

public boolean delete(Rectangle r,
                      int id)
Deletes a rectangle from the spatial index

Parameters:
r - The rectangle to delete from the spatial index
id - The ID of the rectangle to delete from the spatial index
Returns:
true if the rectangle was deleted false if the rectangle was not found, or the rectangle was found but with a different ID

nearest

public void nearest(Point p,
                    IntProcedure v,
                    float distance)
Finds all rectangles that are nearest to the passed rectangle, and calls execute() on the passed IntProcedure for each one.

Parameters:
p - The point for which this method finds the nearest neighbours.
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.

intersects

public void intersects(Rectangle r,
                       IntProcedure ip)
Finds all rectangles that intersect the passed rectangle.

Parameters:
r - The rectangle for which this method finds intersecting rectangles.
ip - The IntProcedure whose execute() method is is called for each intersecting rectangle.

contains

public void contains(Rectangle r,
                     IntProcedure ip)
Finds all rectangles contained by the passed rectangle.

Parameters:
r - The rectangle for which this method finds contained rectangles.

size

public int size()
Returns the number of entries in the spatial index


getVersion

public java.lang.String getVersion()
Returns a string identifying the type of spatial index, and the version number, eg "SimpleIndex-1.0b1"