Package com.complexible.stardog.spatial
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 transactionvoid
clear()
Clear all the features from the indexvoid
close()
Close the connection to the index.void
commit()
Commit the transactionCloseableIterator<Feature>
contain(org.locationtech.spatial4j.shape.Shape shape)
Return all features that contain the current shapelong
containSize(org.locationtech.spatial4j.shape.Shape shape)
Return the approximate number of features that contain the given shapedouble
distance(org.locationtech.spatial4j.shape.Point thePoint, org.locationtech.spatial4j.shape.Point theOther)
Calculate the distance between the pointsjava.util.Optional<Feature>
get(long theId)
Get the shape from the index that has the given idjava.util.Iterator<Feature>
iterator()
Return an iterator over all features in the spatial indexCloseableIterator<Feature>
nearby(org.locationtech.spatial4j.shape.Point theLocation, double theRadius)
Return all shapes within a radius of a given locationlong
nearbySize(org.locationtech.spatial4j.shape.Point theLocation, double theRadius)
Return the (approximate) number of shapes within a radius of a given locationvoid
prepare()
Prepare the transaction for commitvoid
remove(Feature theShape)
Remove the feature from the indexvoid
remove(java.lang.Iterable<Feature> theShape)
Remove all of the features from the indexvoid
rollback()
Rollback the current transactionlong
size()
Return the number of spatial structures stored within the indexvoid
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 shapelong
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 interfacejava.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 pointtheOther
- 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
-
contain
CloseableIterator<Feature> contain(org.locationtech.spatial4j.shape.Shape shape) throws GeoException
Return all features that contain the current shape- Parameters:
shape
- the contained shape- Returns:
- the indexed features that contain the shape
- Throws:
GeoException
- if there was an error querying the index
-
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
-
containSize
long containSize(org.locationtech.spatial4j.shape.Shape shape) throws GeoException
Return the approximate number of features that contain the given shape- Throws:
GeoException
-
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 locationtheRadius
- radius around the location in degrees- 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 locationtheRadius
- radius around the location in degrees- 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
-
-