Package ucar.nc2.dt.ugrid.rtree
Interface SpatialIndex
- All Known Implementing Classes:
RTree
public interface SpatialIndex
The
SpatialIndex interfaces is a contract for spacial indices. Implemented by RTree-
Method Summary
Modifier and TypeMethodDescriptionvoidadd(LatLonPolygon2D p, int id) Adds a new polygon to the spatial indexvoidFinds all polygons contained by the passed polygon.booleandelete(LatLonPolygon2D p, int id) Deletes a polygon from the spatial indexReturns the bounds of all the entries in the spatial index, or null if there are no entries.Returns a string identifying the type of spatial index, and the version number, eg "SimpleIndex-0.1"voidinit(Properties props) Initializes any implementation dependent properties of the spatial index.voidFinds all polygons that intersect the passed polygon.voidnearestNeighbors(LatLonPoint2D p, IntProcedure v, double searchRadius) Finds the polygon which is nearest to the passed point, and calls apply() on the passed IntProcedure for each one.intsize()Returns the number of entries in the spatial index
-
Method Details
-
init
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
Adds a new polygon to the spatial index- Parameters:
p- The polygon to add to the spatial index.id- The ID of the polygon to add to the spatial index. The result of adding more than one polygon with the same ID is undefined.
-
delete
Deletes a polygon from the spatial index- Parameters:
p- The polygon to delete from the spatial indexid- The ID of the polygon to delete from the spatial index- Returns:
trueif the polygon was deleted,falseif the polygon was not found, or the polygon was found but with a different ID
-
nearestNeighbors
Finds the polygon which is nearest to the passed point, and calls apply() on the passed IntProcedure for each one. If multiple nearest polygons are equadistant from the given point, apply() will be invoked for each of them.- Parameters:
p- The point for which this method finds the nearest neighbours.v- The IntProcedure whose apply() method which is called for each nearest neighbour.searchRadius- The furthest distance away from a polygon to search. Polygons further than this will not be found. This should be as small as possible to minimize the search time. Use Double.POSITIVE_INFINITY to guarantee that the nearest polygon is found, no matter how far away, although this will slow down the algorithm.
-
intersects
Finds all polygons that intersect the passed polygon.- Parameters:
r- The polygon for which this method finds intersecting polygons.ip- The IntProcedure whose execute() method is is called for each intersecting polygon.
-
contains
Finds all polygons contained by the passed polygon.- Parameters:
r- The polygon for which this method finds contained polygons.v- The visitor whose visit() method is is called for each contained polygon.
-
size
int size()Returns the number of entries in the spatial index -
getBounds
LatLonRectangle2D getBounds()Returns the bounds of all the entries in the spatial index, or null if there are no entries. -
getVersion
String getVersion()Returns a string identifying the type of spatial index, and the version number, eg "SimpleIndex-0.1"
-