Interface FeatureSource<T extends FeatureType,F extends Feature>
-
- All Known Subinterfaces:
FeatureLocking<T,F>
,FeatureStore<T,F>
,SimpleFeatureLocking
,SimpleFeatureSource
,SimpleFeatureStore
,XmlFeatureSource
- All Known Implementing Classes:
CollectionFeatureSource
,ContentFeatureSource
,ContentFeatureStore
,CSVFeatureSource
,CSVFeatureStore
,DefaultView
,DirectoryFeatureLocking
,DirectoryFeatureSource
,DirectoryFeatureStore
,GeoJSONFeatureSource
,GeoJSONFeatureStore
,GraticuleFeatureSource
,JDBCFeatureSource
,JDBCFeatureStore
,JoiningJDBCFeatureSource
,MappingFeatureSource
,MemoryFeatureSource
,MemoryFeatureStore
,MongoFeatureSource
,MongoFeatureStore
,OracleTransformFeatureStore
,PostgisTransformFeatureStore
,PreGeneralizedFeatureSource
,PropertyFeatureSource
,PropertyFeatureStore
,SampleDataAccessFeatureSource
,SpatialIndexFeatureSource
,SQLServerTransformFeatureStore
,STACFeatureSource
,TransformFeatureLocking
,TransformFeatureSource
,TransformFeatureStore
,VectorMosaicFeatureSource
,VPFCovFeatureSource
,VPFFeatureSource
,VPFFileFeatureSource
,VPFLibFeatureSource
,WFSContentComplexFeatureSource
,WFSStoredQueryFeatureSource
public interface FeatureSource<T extends FeatureType,F extends Feature>
This class provides a high-level API for operations on feature data. Typically, when working with a data source such as a shapefile or database table you will initially create aDataStore
object to connect to the physical source and then retrieve aFeatureSource
to work with the feature data, as in this excerpt from the GeoTools Quickstart example (http://geotools.org/quickstart.html)File file = ... FileDataStore store = FileDataStoreFinder.getDataStore(file); FeatureSource featureSource = store.getFeatureSource();
- Author:
- Jody Garnett, Ray Gallagher, Rob Hranac, TOPP, Chris Holmes, TOPP
- See Also:
DataStore
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addFeatureListener(FeatureListener listener)
Registers a listening object that will be notified of changes to thisFeatureSource
.ReferencedEnvelope
getBounds()
Get the spatial bounds of the feature data.ReferencedEnvelope
getBounds(Query query)
Get the spatial bounds of the features that would be returned by the givenQuery
.int
getCount(Query query)
Gets the number of the features that would be returned by the givenQuery
, taking into account any settings for max features and start index set on theQuery
.DataAccess<T,F>
getDataStore()
Returns the data source, as aDataAccess
object, providing thisFeatureSource
.FeatureCollection<T,F>
getFeatures()
Retrieves all features in the form of aFeatureCollection
.FeatureCollection<T,F>
getFeatures(Query query)
Retrieves features, in the form of aFeatureCollection
, based on aQuery
.FeatureCollection<T,F>
getFeatures(Filter filter)
Retrieves features, in the form of aFeatureCollection
, based on an OGCFilter
.ResourceInfo
getInfo()
Returns information describing thisFeatureSource
which may include title, description and spatial parameters.Name
getName()
Returns the name of the features (strictly, the name of theAttributeDescriptor
for the features) accessible through thisFeatureSource
.QueryCapabilities
getQueryCapabilities()
Enquire what what query capabilities thisFeatureSource
natively supports.T
getSchema()
Retrieves the schema (feature type) that will apply to features retrieved from thisFeatureSource
.Set<RenderingHints.Key>
getSupportedHints()
Returns the set of hints that thisFeatureSource
supports viaQuery
requests.void
removeFeatureListener(FeatureListener listener)
Removes an object from thisFeatureSource's
listeners.
-
-
-
Method Detail
-
getName
Name getName()
Returns the name of the features (strictly, the name of theAttributeDescriptor
for the features) accessible through thisFeatureSource
.The value returned by this method can be different to that returned by
featureSource.getSchema().getType().getName()
. This is because there is a distinction between the name applied to features and the name of a feature type. When working withSimpleFeature
andSimpleFeatureType
, for example with a shapefile data source, it is common practice for feature and feature type names to be the same. However, this is not the case more generally. For instance, a database can contain two tables with the same structure. The feature name will refer to the table while the feature type name refers to the schema (table structure).- Returns:
- the name of the features accessible through this
FeatureSource
- Since:
- 2.5
-
getInfo
ResourceInfo getInfo()
Returns information describing thisFeatureSource
which may include title, description and spatial parameters. Note that in the returnedResourceInfo
object, the distinction between feature name and schema (feature type) name applies as discussed for getName().
-
getDataStore
DataAccess<T,F> getDataStore()
Returns the data source, as aDataAccess
object, providing thisFeatureSource
.- Returns:
- the data source providing this
FeatureSource
-
getQueryCapabilities
QueryCapabilities getQueryCapabilities()
Enquire what what query capabilities thisFeatureSource
natively supports. For example, whether queries can return sorted results.- Returns:
- the native query capabilities of this
FeatureSource
- Since:
- 2.5
-
addFeatureListener
void addFeatureListener(FeatureListener listener)
Registers a listening object that will be notified of changes to thisFeatureSource
.- Parameters:
listener
- the new listener
-
removeFeatureListener
void removeFeatureListener(FeatureListener listener)
Removes an object from thisFeatureSource's
listeners.- Parameters:
listener
- the listener to remove
-
getFeatures
FeatureCollection<T,F> getFeatures(Filter filter) throws IOException
Retrieves features, in the form of aFeatureCollection
, based on an OGCFilter
.- Parameters:
filter
- the filter to select features; must not benull
(use Filter.INCLUDE instead)- Returns:
- features retrieved by the
Filter
- Throws:
IOException
- if the underlying data source cannot be accessed.- See Also:
Filter
-
getFeatures
FeatureCollection<T,F> getFeatures(Query query) throws IOException
Retrieves features, in the form of aFeatureCollection
, based on aQuery
.- Parameters:
query
- DataAccess query for requested information, such as typeName, maxFeatures and filter.- Returns:
- features retrieved by the
Query
- Throws:
IOException
- if the underlying data source cannot be accessed.- See Also:
Query
-
getFeatures
FeatureCollection<T,F> getFeatures() throws IOException
Retrieves all features in the form of aFeatureCollection
.The following statements are equivalent:
featureSource.getFeatures(); featureSource.getFeatures(Filter.INCLUDE); featureSource.getFeatures(Query.ALL);
- Returns:
- features retrieved by the
Query
- Throws:
IOException
- if the underlying data source cannot be accessed.
-
getSchema
T getSchema()
Retrieves the schema (feature type) that will apply to features retrieved from thisFeatureSource
.For a homogeneous data source such as a shapefile or a database table, this schema be that of all features. For a heterogeneous data source, e.g. a GML document, the schema returned is the lowest common denominator across all features.
- Returns:
- the schema that will apply to features retrieved from this
FeatureSource
-
getBounds
ReferencedEnvelope getBounds() throws IOException
Get the spatial bounds of the feature data. This is equivalent to callinggetBounds(Query.ALL)
.It is possible that this method will return null if the calculation of bounds is judged to be too costly by the implementing class. In this case, you might call
getFeatures().getBounds()
instead.- Returns:
- The bounding envelope of the feature data; or
null
if the bounds are unknown or too costly to calculate. - Throws:
IOException
- on any errors calculating the bounds
-
getBounds
ReferencedEnvelope getBounds(Query query) throws IOException
Get the spatial bounds of the features that would be returned by the givenQuery
.It is possible that this method will return null if the calculation of bounds is judged to be too costly by the implementing class. In this case, you might call
getFeatures(query).getBounds()
instead.- Parameters:
query
- the query to select features- Returns:
- The bounding envelope of the feature data; or
null
if the bounds are unknown or too costly to calculate. - Throws:
IOException
- on any errors calculating the bounds
-
getCount
int getCount(Query query) throws IOException
Gets the number of the features that would be returned by the givenQuery
, taking into account any settings for max features and start index set on theQuery
.It is possible that this method will return
-1
if the calculation of number of features is judged to be too costly by the implementing class. In this case, you might callgetFeatures(query).size()
instead.Example use:
int count = featureSource.getCount(); if( count == -1 ){ count = featureSource.getFeatures( "typeName", count ).size(); }
- Parameters:
query
- the query to select features- Returns:
- the numer of features that would be returned by the
Query
; or-1
if this cannot be calculated. - Throws:
IOException
- if there are errors getting the count
-
getSupportedHints
Set<RenderingHints.Key> getSupportedHints()
Returns the set of hints that thisFeatureSource
supports viaQuery
requests.Note: the existence of a specific hint does not guarantee that it will always be honored by the implementing class.
- Returns:
- a set of
RenderingHints#Key
objects; may be empty but nevernull
- See Also:
Hints.FEATURE_DETACHED
,Hints.JTS_GEOMETRY_FACTORY
,Hints.JTS_COORDINATE_SEQUENCE_FACTORY
,Hints.JTS_PRECISION_MODEL
,Hints.JTS_SRID
,Hints.GEOMETRY_DISTANCE
,Hints.FEATURE_2D
-
-