Class SpatialIndex

java.lang.Object
org.apache.jena.geosparql.spatial.SpatialIndex

public class SpatialIndex extends 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.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final org.apache.jena.sparql.util.Symbol
     
  • Constructor Summary

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

    Modifier and Type
    Method
    Description
    void
    Build the Spatial Index.
    buildSpatialIndex(org.apache.jena.query.Dataset dataset)
    Build Spatial Index from all graphs in Dataset.
    Dataset contains SpatialIndex in Context.
    SRS URI based on most frequent found in Dataset.
    buildSpatialIndex(org.apache.jena.query.Dataset dataset, 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.
    buildSpatialIndex(org.apache.jena.query.Dataset dataset, String srsURI)
    Build Spatial Index from all graphs in Dataset.
    Dataset contains SpatialIndex in Context.
    buildSpatialIndex(org.apache.jena.query.Dataset dataset, String srsURI, File spatialIndexFile)
    Build Spatial Index from all graphs in Dataset.
    Dataset contains SpatialIndex in Context.
    Spatial Index written to file.
    findSpatialIndexItems(org.apache.jena.query.Dataset dataset, String srsURI)
    Find Spatial Index Items from all graphs in Dataset.
    getSpatialIndexItems(org.apache.jena.rdf.model.Model model, String srsURI)
    Find items from the Model transformed to the SRS URI.
     
    final void
    insertItem(org.locationtech.jts.geom.Envelope envelope, org.apache.jena.rdf.model.Resource item)
    Item to add to an unbuilt Spatial Index.
    final void
    Items to add to an unbuilt Spatial Index.
    boolean
     
    static final boolean
    isDefined(org.apache.jena.sparql.engine.ExecutionContext execCxt)
     
    boolean
     
    static final SpatialIndex
    load(File spatialIndexFile)
    Load a SpatialIndex from file.
    Index will be built and empty if file does not exist or is null.
    HashSet<org.apache.jena.rdf.model.Resource>
    query(org.locationtech.jts.geom.Envelope searchEnvelope)
     
    static final SpatialIndex
    retrieve(org.apache.jena.sparql.engine.ExecutionContext execCxt)
    Retrieve the SpatialIndex from the Context.
    static final void
    save(File spatialIndexFile, Collection<SpatialIndexItem> spatialIndexItems, String srsURI)
    Save SpatialIndex contents to file.
    static final void
    save(String spatialIndexFileURI, Collection<SpatialIndexItem> spatialIndexItems, String srsURI)
    Save SpatialIndex contents to file.
    static final void
    setSpatialIndex(org.apache.jena.query.Dataset dataset, SpatialIndex spatialIndex)
    Set the SpatialIndex into the Context of the Dataset for later retrieval and use in spatial functions.
     
    static final org.apache.jena.query.Dataset
    wrapModel(org.apache.jena.rdf.model.Model model)
    Wrap Model in a Dataset and build SpatialIndex.
    static final org.apache.jena.query.Dataset
    wrapModel(org.apache.jena.rdf.model.Model model, 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 Details

    • SPATIAL_INDEX_SYMBOL

      public static final org.apache.jena.sparql.util.Symbol SPATIAL_INDEX_SYMBOL
  • Constructor Details

  • Method Details

    • 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.
    • insertItems

      public final void insertItems(Collection<SpatialIndexItem> indexItems) throws SpatialIndexException
      Items to add to an unbuilt Spatial Index.
      Parameters:
      indexItems -
      Throws:
      SpatialIndexException
    • insertItem

      public final void insertItem(org.locationtech.jts.geom.Envelope envelope, org.apache.jena.rdf.model.Resource item) throws SpatialIndexException
      Item to add to an unbuilt Spatial Index.
      Parameters:
      envelope -
      item -
      Throws:
      SpatialIndexException
    • query

      public HashSet<org.apache.jena.rdf.model.Resource> query(org.locationtech.jts.geom.Envelope searchEnvelope)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • retrieve

      public static final SpatialIndex retrieve(org.apache.jena.sparql.engine.ExecutionContext execCxt) throws SpatialIndexException
      Retrieve the SpatialIndex from the Context.
      Parameters:
      execCxt -
      Returns:
      SpatialIndex contained in the Context.
      Throws:
      SpatialIndexException
    • isDefined

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

      public static final void setSpatialIndex(org.apache.jena.query.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(org.apache.jena.query.Dataset dataset, String srsURI, 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(org.apache.jena.query.Dataset dataset, 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(org.apache.jena.query.Dataset dataset, 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
    • findSpatialIndexItems

      public static Collection<SpatialIndexItem> findSpatialIndexItems(org.apache.jena.query.Dataset dataset, String srsURI) throws SpatialIndexException
      Find Spatial Index Items from all graphs in Dataset.
      Parameters:
      dataset -
      srsURI -
      Returns:
      SpatialIndexItems found.
      Throws:
      SpatialIndexException
    • buildSpatialIndex

      public static SpatialIndex buildSpatialIndex(org.apache.jena.query.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 org.apache.jena.query.Dataset wrapModel(org.apache.jena.rdf.model.Model model, 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
    • wrapModel

      public static final org.apache.jena.query.Dataset wrapModel(org.apache.jena.rdf.model.Model model) throws SpatialIndexException
      Wrap Model in a Dataset and build SpatialIndex.
      Parameters:
      model -
      Returns:
      Dataset with default Model and SpatialIndex in Context.
      Throws:
      SpatialIndexException
    • getSpatialIndexItems

      public static final Collection<SpatialIndexItem> getSpatialIndexItems(org.apache.jena.rdf.model.Model model, 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(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(String spatialIndexFileURI, Collection<SpatialIndexItem> spatialIndexItems, String srsURI) throws SpatialIndexException
      Save SpatialIndex contents to file.
      Parameters:
      spatialIndexFileURI -
      spatialIndexItems -
      srsURI -
      Throws:
      SpatialIndexException
    • save

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