Class SpatialIndex


  • public class SpatialIndex
    extends java.lang.Object
    SpatialIndex for testing bounding box collisions between geometries within a Dataset.
    Queries must be performed using the same SRS URI as the SpatialIndex.
    The SpatialIndex is added to the Dataset Context when it is built.
    QueryRewriteIndex is also stored in the SpatialIndex as its content is Dataset specific.
    • Constructor Summary

      Constructors 
      Constructor Description
      SpatialIndex​(int capacity, java.lang.String srsURI)
      Unbuilt Spatial Index with provided capacity.
      SpatialIndex​(java.util.Collection<SpatialIndexItem> spatialIndexItems, java.lang.String srsURI)
      Built Spatial Index with provided capacity.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void build()
      Build the Spatial Index.
      static SpatialIndex buildSpatialIndex​(Dataset dataset)
      Build Spatial Index from all graphs in Dataset.
      Dataset contains SpatialIndex in Context.
      SRS URI based on most frequent found in Dataset.
      static SpatialIndex buildSpatialIndex​(Dataset dataset, java.io.File spatialIndexFile)
      Build Spatial Index from all graphs in Dataset.
      Dataset contains SpatialIndex in Context.
      SRS URI based on most frequent found in Dataset.
      Spatial Index written to file.
      static SpatialIndex buildSpatialIndex​(Dataset dataset, java.lang.String srsURI)
      Build Spatial Index from all graphs in Dataset.
      Dataset contains SpatialIndex in Context.
      static SpatialIndex buildSpatialIndex​(Dataset dataset, java.lang.String srsURI, java.io.File spatialIndexFile)
      Build Spatial Index from all graphs in Dataset.
      Dataset contains SpatialIndex in Context.
      Spatial Index written to file.
      static java.util.Collection<SpatialIndexItem> findSpatialIndexItems​(Dataset dataset, java.lang.String srsURI)
      Find Spatial Index Items from all graphs in Dataset.
      static java.util.Collection<SpatialIndexItem> getSpatialIndexItems​(Model model, java.lang.String srsURI)
      Find items from the Model transformed to the SRS URI.
      SRSInfo getSrsInfo()  
      void insertItem​(org.locationtech.jts.geom.Envelope envelope, Resource item)
      Item to add to an unbuilt Spatial Index.
      void insertItems​(java.util.Collection<SpatialIndexItem> indexItems)
      Items to add to an unbuilt Spatial Index.
      boolean isBuilt()  
      static boolean isDefined​(ExecutionContext execCxt)  
      boolean isEmpty()  
      static SpatialIndex load​(java.io.File spatialIndexFile)
      Load a SpatialIndex from file.
      Index will be built and empty if file does not exist or is null.
      java.util.HashSet<Resource> query​(org.locationtech.jts.geom.Envelope searchEnvelope)  
      static SpatialIndex retrieve​(ExecutionContext execCxt)
      Retrieve the SpatialIndex from the Context.
      static void save​(java.io.File spatialIndexFile, java.util.Collection<SpatialIndexItem> spatialIndexItems, java.lang.String srsURI)
      Save SpatialIndex contents to file.
      static void save​(java.lang.String spatialIndexFileURI, java.util.Collection<SpatialIndexItem> spatialIndexItems, java.lang.String srsURI)
      Save SpatialIndex contents to file.
      static void setSpatialIndex​(Dataset dataset, SpatialIndex spatialIndex)
      Set the SpatialIndex into the Context of the Dataset for later retrieval and use in spatial functions.
      java.lang.String toString()  
      static Dataset wrapModel​(Model model)
      Wrap Model in a Dataset and build SpatialIndex.
      static Dataset wrapModel​(Model model, java.lang.String srsURI)
      Wrap Model in a Dataset and build SpatialIndex.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • SPATIAL_INDEX_SYMBOL

        public static final Symbol SPATIAL_INDEX_SYMBOL
    • Constructor Detail

      • SpatialIndex

        public SpatialIndex​(int capacity,
                            java.lang.String srsURI)
        Unbuilt Spatial Index with provided capacity.
        Parameters:
        capacity -
        srsURI -
    • Method Detail

      • getSrsInfo

        public SRSInfo getSrsInfo()
        Returns:
        Information about the SRS used by the SpatialIndex.
      • isEmpty

        public boolean isEmpty()
        Returns:
        True if the SpatialIndex is empty.
      • isBuilt

        public boolean isBuilt()
        Returns:
        True if the SpatialIndex has been built.
      • build

        public void build()
        Build the Spatial Index. No more items can be added.
      • query

        public java.util.HashSet<Resource> query​(org.locationtech.jts.geom.Envelope searchEnvelope)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • isDefined

        public static final boolean isDefined​(ExecutionContext execCxt)
        Parameters:
        execCxt -
        Returns:
        True if a SpatialIndex is defined in the ExecutionContext.
      • setSpatialIndex

        public static final void setSpatialIndex​(Dataset dataset,
                                                 SpatialIndex spatialIndex)
        Set the SpatialIndex into the Context of the Dataset for later retrieval and use in spatial functions.
        Parameters:
        dataset -
        spatialIndex -
      • buildSpatialIndex

        public static SpatialIndex buildSpatialIndex​(Dataset dataset,
                                                     java.lang.String srsURI,
                                                     java.io.File spatialIndexFile)
                                              throws SpatialIndexException
        Build Spatial Index from all graphs in Dataset.
        Dataset contains SpatialIndex in Context.
        Spatial Index written to file.
        Parameters:
        dataset -
        srsURI -
        spatialIndexFile -
        Returns:
        SpatialIndex constructed.
        Throws:
        SpatialIndexException
      • buildSpatialIndex

        public static SpatialIndex buildSpatialIndex​(Dataset dataset,
                                                     java.io.File spatialIndexFile)
                                              throws SpatialIndexException
        Build Spatial Index from all graphs in Dataset.
        Dataset contains SpatialIndex in Context.
        SRS URI based on most frequent found in Dataset.
        Spatial Index written to file.
        Parameters:
        dataset -
        spatialIndexFile -
        Returns:
        SpatialIndex constructed.
        Throws:
        SpatialIndexException
      • buildSpatialIndex

        public static SpatialIndex buildSpatialIndex​(Dataset dataset,
                                                     java.lang.String srsURI)
                                              throws SpatialIndexException
        Build Spatial Index from all graphs in Dataset.
        Dataset contains SpatialIndex in Context.
        Parameters:
        dataset -
        srsURI -
        Returns:
        SpatialIndex constructed.
        Throws:
        SpatialIndexException
      • buildSpatialIndex

        public static SpatialIndex buildSpatialIndex​(Dataset dataset)
                                              throws SpatialIndexException
        Build Spatial Index from all graphs in Dataset.
        Dataset contains SpatialIndex in Context.
        SRS URI based on most frequent found in Dataset.
        Parameters:
        dataset -
        Returns:
        SpatialIndex constructed.
        Throws:
        SpatialIndexException
      • wrapModel

        public static final Dataset wrapModel​(Model model,
                                              java.lang.String srsURI)
                                       throws SpatialIndexException
        Wrap Model in a Dataset and build SpatialIndex.
        Parameters:
        model -
        srsURI -
        Returns:
        Dataset with default Model and SpatialIndex in Context.
        Throws:
        SpatialIndexException
      • getSpatialIndexItems

        public static final java.util.Collection<SpatialIndexItem> getSpatialIndexItems​(Model model,
                                                                                        java.lang.String srsURI)
                                                                                 throws SpatialIndexException
        Find items from the Model transformed to the SRS URI.
        Parameters:
        model -
        srsURI -
        Returns:
        Items found in the Model in the SRS URI.
        Throws:
        SpatialIndexException
      • load

        public static final SpatialIndex load​(java.io.File spatialIndexFile)
                                       throws SpatialIndexException
        Load a SpatialIndex from file.
        Index will be built and empty if file does not exist or is null.
        Parameters:
        spatialIndexFile -
        Returns:
        Built Spatial Index.
        Throws:
        SpatialIndexException
      • save

        public static final void save​(java.lang.String spatialIndexFileURI,
                                      java.util.Collection<SpatialIndexItem> spatialIndexItems,
                                      java.lang.String srsURI)
                               throws SpatialIndexException
        Save SpatialIndex contents to file.
        Parameters:
        spatialIndexFileURI -
        spatialIndexItems -
        srsURI -
        Throws:
        SpatialIndexException
      • save

        public static final void save​(java.io.File spatialIndexFile,
                                      java.util.Collection<SpatialIndexItem> spatialIndexItems,
                                      java.lang.String srsURI)
                               throws SpatialIndexException
        Save SpatialIndex contents to file.
        Parameters:
        spatialIndexFile -
        spatialIndexItems -
        srsURI -
        Throws:
        SpatialIndexException