Interface GeospatialIndexConnection

  • All Superinterfaces:
    java.lang.AutoCloseable

    public interface GeospatialIndexConnection
    extends java.lang.AutoCloseable

    All lengths and distances are given in DEGREES. Conversions to other uses of measurement can be performed using DistanceUnit.

    Since:
    4.0
    Version:
    4.0.1
    Author:
    Michael Grove
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void add​(Feature theShape)
      Add the shape to the spatial index.
      void add​(java.lang.Iterable<Feature> theShapes)
      Add the shapes to the spatial index.
      void begin()
      Start a transaction
      void clear()
      Clear all the features from the index
      void close()
      Close the connection to the index.
      void commit()
      Commit the transaction
      double distance​(org.locationtech.spatial4j.shape.Point thePoint, org.locationtech.spatial4j.shape.Point theOther)
      Calculate the distance between the points
      java.util.Optional<Feature> get​(long theId)
      Get the shape from the index that has the given id
      java.util.Iterator<Feature> iterator()
      Return an iterator over all features in the spatial index
      CloseableIterator<Feature> nearby​(org.locationtech.spatial4j.shape.Point theLocation, double theRadius)
      Return all shapes within a radius of a given location
      long nearbySize​(org.locationtech.spatial4j.shape.Point theLocation, double theRadius)
      Return the (approximate) number of shapes within a radius of a given location
      void prepare()
      Prepare the transaction for commit
      void remove​(Feature theShape)
      Remove the feature from the index
      void remove​(java.lang.Iterable<Feature> theShape)
      Remove all of the features from the index
      void rollback()
      Rollback the current transaction
      long size()
      Return the number of spatial structures stored within the index
      void update​(Feature theShape)
      Update the data about a shape with the same ID.
      CloseableIterator<Feature> within​(org.locationtech.spatial4j.shape.Shape theBox)
      Return all the features within the given shape
      long withinSize​(org.locationtech.spatial4j.shape.Shape theBox)
      Return the (approximate) number of features within the given shape
    • Method Detail

      • close

        void close()
            throws GeoException
        Close the connection to the index. Any pending transactions are automatically rolled back when closing the connection. Closing a connection multiple times has no effect.
        Specified by:
        close in interface java.lang.AutoCloseable
        Throws:
        GeoException - if there was an error closing the index
      • size

        long size()
           throws GeoException
        Return the number of spatial structures stored within the index
        Returns:
        the size
        Throws:
        GeoException - if there was an error while retrieving the size of the index
      • distance

        double distance​(org.locationtech.spatial4j.shape.Point thePoint,
                        org.locationtech.spatial4j.shape.Point theOther)
                 throws GeoException
        Calculate the distance between the points
        Parameters:
        thePoint - the point
        theOther - the other point
        Returns:
        the distance in degrees
        Throws:
        GeoException - if there was an error while calculating the distance
      • within

        CloseableIterator<Feature> within​(org.locationtech.spatial4j.shape.Shape theBox)
                                   throws GeoException
        Return all the features within the given shape
        Parameters:
        theBox - the containing shape
        Returns:
        all of the features within the shape
        Throws:
        GeoException - if there was an error while retrieving the child features
      • withinSize

        long withinSize​(org.locationtech.spatial4j.shape.Shape theBox)
                 throws GeoException
        Return the (approximate) number of features within the given shape
        Parameters:
        theBox - the containing shape
        Returns:
        the (approximate) number of features
        Throws:
        GeoException - if there was an error while retrieving the child features
      • nearby

        CloseableIterator<Feature> nearby​(org.locationtech.spatial4j.shape.Point theLocation,
                                          double theRadius)
                                   throws GeoException
        Return all shapes within a radius of a given location
        Parameters:
        theLocation - the location
        theRadius - radius around the location
        Returns:
        all shapes near the given location
        Throws:
        GeoException
      • nearbySize

        long nearbySize​(org.locationtech.spatial4j.shape.Point theLocation,
                        double theRadius)
                 throws GeoException
        Return the (approximate) number of shapes within a radius of a given location
        Parameters:
        theLocation - the location
        theRadius - radius around the location
        Returns:
        the (approximate) number of shapes
        Throws:
        GeoException
      • get

        java.util.Optional<Feature> get​(long theId)
                                 throws GeoException
        Get the shape from the index that has the given id
        Parameters:
        theId - the id of the shape to retrieve
        Returns:
        the shape, or an absent optional if a shape with the given id does not exist
        Throws:
        GeoException - if there is an error getting the shape
      • add

        void add​(Feature theShape)
          throws GeoException
        Add the shape to the spatial index. Must be called within a transaction
        Parameters:
        theShape - the shape to add
        Throws:
        GeoException - if there was an error while adding the shape to the index
      • add

        void add​(java.lang.Iterable<Feature> theShapes)
          throws GeoException
        Add the shapes to the spatial index. Must be called within a transaction.
        Parameters:
        theShapes - the shapes to add
        Throws:
        GeoException - if there was an error adding the shapes to the index
      • update

        void update​(Feature theShape)
             throws GeoException
        Update the data about a shape with the same ID. Must be called within a transaction
        Parameters:
        theShape - the shape to add
        Throws:
        GeoException - if there was an error while adding the shape to the index
      • clear

        void clear()
            throws GeoException
        Clear all the features from the index
        Throws:
        GeoException - if there was an error clearing the index
      • remove

        void remove​(Feature theShape)
             throws GeoException
        Remove the feature from the index
        Parameters:
        theShape - the feature to remove
        Throws:
        GeoException - if there was an error while removing
      • remove

        void remove​(java.lang.Iterable<Feature> theShape)
             throws GeoException
        Remove all of the features from the index
        Parameters:
        theShape - the features to remove
        Throws:
        GeoException - if there was an error during removal
      • begin

        void begin()
            throws GeoException
        Start a transaction
        Throws:
        GeoException - if there was an error while starting the transaction
      • prepare

        void prepare()
              throws GeoException
        Prepare the transaction for commit
        Throws:
        GeoException - if there was an error while preparing
      • commit

        void commit()
             throws GeoException
        Commit the transaction
        Throws:
        GeoException - if there is an error while committing
      • rollback

        void rollback()
               throws GeoException
        Rollback the current transaction
        Throws:
        GeoException - if there is an error while rolling back
      • iterator

        java.util.Iterator<Feature> iterator()
                                      throws GeoException
        Return an iterator over all features in the spatial index
        Returns:
        all features
        Throws:
        GeoException