Class SpatialIndex
java.lang.Object
org.apache.jena.geosparql.spatial.SpatialIndex
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.
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 -
Constructor Summary
ConstructorsConstructorDescriptionSpatialIndex
(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 TypeMethodDescriptionvoid
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, 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, String srsURI) Build Spatial Index from all graphs in Dataset.
Dataset contains SpatialIndex in Context.static SpatialIndex
buildSpatialIndex
(Dataset dataset, String srsURI, File spatialIndexFile) Build Spatial Index from all graphs in Dataset.
Dataset contains SpatialIndex in Context.
Spatial Index written to file.static Collection<SpatialIndexItem>
findSpatialIndexItems
(Dataset dataset, String srsURI) Find Spatial Index Items from all graphs in Dataset.static final Collection<SpatialIndexItem>
getSpatialIndexItems
(Model model, String srsURI) Find items from the Model transformed to the SRS URI.final void
insertItem
(org.locationtech.jts.geom.Envelope envelope, Resource item) Item to add to an unbuilt Spatial Index.final void
insertItems
(Collection<SpatialIndexItem> indexItems) Items to add to an unbuilt Spatial Index.boolean
isBuilt()
static final boolean
isDefined
(ExecutionContext execCxt) boolean
isEmpty()
static final SpatialIndex
Load a SpatialIndex from file.
Index will be built and empty if file does not exist or is null.query
(org.locationtech.jts.geom.Envelope searchEnvelope) static final SpatialIndex
retrieve
(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
(Dataset dataset, SpatialIndex spatialIndex) Set the SpatialIndex into the Context of the Dataset for later retrieval and use in spatial functions.toString()
static final Dataset
Wrap Model in a Dataset and build SpatialIndex.static final Dataset
Wrap Model in a Dataset and build SpatialIndex.
-
Field Details
-
SPATIAL_INDEX_SYMBOL
-
-
Constructor Details
-
SpatialIndex
Unbuilt Spatial Index with provided capacity.- Parameters:
capacity
-srsURI
-
-
SpatialIndex
public SpatialIndex(Collection<SpatialIndexItem> spatialIndexItems, String srsURI) throws SpatialIndexException Built Spatial Index with provided capacity.- Parameters:
spatialIndexItems
-srsURI
-- Throws:
SpatialIndexException
-
-
Method Details
-
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
Items to add to an unbuilt Spatial Index.- Parameters:
indexItems
-- Throws:
SpatialIndexException
-
insertItem
public final void insertItem(org.locationtech.jts.geom.Envelope envelope, Resource item) throws SpatialIndexException Item to add to an unbuilt Spatial Index.- Parameters:
envelope
-item
-- Throws:
SpatialIndexException
-
query
-
toString
-
retrieve
Retrieve the SpatialIndex from the Context.- Parameters:
execCxt
-- Returns:
- SpatialIndex contained in the Context.
- Throws:
SpatialIndexException
-
isDefined
- Parameters:
execCxt
-- Returns:
- True if a SpatialIndex is defined in the ExecutionContext.
-
setSpatialIndex
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, 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(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(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(Dataset dataset, String srsURI) throws SpatialIndexException Find Spatial Index Items from all graphs in Dataset.- Parameters:
dataset
-srsURI
-- Returns:
- SpatialIndexItems found.
- Throws:
SpatialIndexException
-
buildSpatialIndex
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
Wrap Model in a Dataset and build SpatialIndex.- Parameters:
model
-srsURI
-- Returns:
- Dataset with default Model and SpatialIndex in Context.
- Throws:
SpatialIndexException
-
wrapModel
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(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
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
-