Interface SpatialIndex

  • All Known Implementing Classes:
    RTree

    public interface SpatialIndex
    The SpatialIndex interfaces is a contract for spacial indices. Implemented by RTree
    • Method Detail

      • init

        void init​(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

        void add​(LatLonPolygon2D p,
                 int id)
        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

        boolean delete​(LatLonPolygon2D p,
                       int id)
        Deletes a polygon from the spatial index
        Parameters:
        p - The polygon to delete from the spatial index
        id - The ID of the polygon to delete from the spatial index
        Returns:
        true if the polygon was deleted, false if the polygon was not found, or the polygon was found but with a different ID
      • nearestNeighbors

        void nearestNeighbors​(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. 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

        void intersects​(LatLonPolygon2D r,
                        IntProcedure ip)
        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

        void contains​(LatLonPolygon2D r,
                      IntProcedure v)
        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"