Class DefaultFeatureResults
- Object
-
- DataFeatureCollection
-
- DefaultFeatureResults
-
- All Implemented Interfaces:
SimpleFeatureCollection,FeatureCollection<SimpleFeatureType,SimpleFeature>
public class DefaultFeatureResults extends DataFeatureCollection
Generic "results" of a query, class.Please optimize this class when use with your own content. For example a "ResultSet" make a great cache for a JDBCDataStore, a temporary copy of an original file may work for shapefile etc.
- Author:
- Jody Garnett, Refractions Research
-
-
Field Summary
Fields Modifier and Type Field Description protected SimpleFeatureSourcefeatureSourceFeature source used to aquire features, note we are only a "view" of this FeatureSource, its contents, transaction and events need to be forwarded through this collection api to simplier code such as renderers.protected QueryqueryQuery used to define this subset of features from the feature sourceprotected MathTransformtransform-
Fields inherited from class DataFeatureCollection
id, listeners, schema
-
-
Constructor Summary
Constructors Constructor Description DefaultFeatureResults(SimpleFeatureSource source, Query query)FeatureResults query against featureSource.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected FeatureReader<SimpleFeatureType,SimpleFeature>boundsReader()Retrieve a FeatureReaderfor the geometry attributes only, designed for bounds computation SimpleFeatureCollectioncollection()ReferencedEnvelopegetBounds()Returns the bounding box of this FeatureResultsintgetCount()Number of Features in this query.SimpleFeatureTypegetSchema()FeatureSchema for provided query.protected TransactiongetTransaction()Returns transaction from SimpleFeatureSource (if it is a FeatureStore), or Transaction.AUTO_COMMIT if it is not.FeatureReader<SimpleFeatureType,SimpleFeature>reader()Retrieve a FeatureReaderfor this Query -
Methods inherited from class DataFeatureCollection
accepts, add, addAll, addAll, addListener, clear, close, close, closeIterator, contains, containsAll, features, fireChange, fireChange, fireChange, getID, isEmpty, iterator, openIterator, purge, remove, removeAll, removeListener, retainAll, size, sort, subCollection, toArray, toArray, writer
-
-
-
-
Field Detail
-
query
protected Query query
Query used to define this subset of features from the feature source
-
featureSource
protected SimpleFeatureSource featureSource
Feature source used to aquire features, note we are only a "view" of this FeatureSource, its contents, transaction and events need to be forwarded through this collection api to simplier code such as renderers.
-
transform
protected MathTransform transform
-
-
Constructor Detail
-
DefaultFeatureResults
public DefaultFeatureResults(SimpleFeatureSource source, Query query) throws IOException
FeatureResults query against featureSource.Please note that is object will not be valid after the transaction has closed.
Really? I think it would be, it would just reflect the same query against the SimpleFeatureSource using AUTO_COMMIT.
- Throws:
IOException
-
-
Method Detail
-
getSchema
public SimpleFeatureType getSchema()
FeatureSchema for provided query.If query.retrieveAllProperties() is
truethe FeatureSource getSchema() will be returned.If query.getPropertyNames() is used to limit the result of the Query a sub type will be returned based on FeatureSource.getSchema().
- Specified by:
getSchemain interfaceFeatureCollection<SimpleFeatureType,SimpleFeature>- Overrides:
getSchemain classDataFeatureCollection- Returns:
- FeatureType describing the "common" schema to all child features of this collection
-
getTransaction
protected Transaction getTransaction()
Returns transaction from SimpleFeatureSource (if it is a FeatureStore), or Transaction.AUTO_COMMIT if it is not.- Returns:
- Transacstion this FeatureResults opperates against
-
reader
public FeatureReader<SimpleFeatureType,SimpleFeature> reader() throws IOException
Retrieve a FeatureReaderfor this Query - Overrides:
readerin classDataFeatureCollection- Returns:
- FeatureReader
for this Query - Throws:
IOException- If results could not be obtained
-
boundsReader
protected FeatureReader<SimpleFeatureType,SimpleFeature> boundsReader() throws IOException
Retrieve a FeatureReaderfor the geometry attributes only, designed for bounds computation - Throws:
IOException
-
getBounds
public ReferencedEnvelope getBounds()
Returns the bounding box of this FeatureResultsThis implementation will generate the correct results from reader() if the provided SimpleFeatureSource does not provide an optimized result via FeatureSource.getBounds( Query ). If the feature has no geometry, then an empty envelope is returned.
- Specified by:
getBoundsin interfaceFeatureCollection<SimpleFeatureType,SimpleFeature>- Specified by:
getBoundsin classDataFeatureCollection- Returns:
- An Envelope containing the total bounds of this collection.
- Throws:
DataSourceException- See IOException- See Also:
org.geotools.data.FeatureResults#getBounds()
-
getCount
public int getCount() throws IOExceptionNumber of Features in this query.This implementation will generate the correct results from reader() if the provided SimpleFeatureSource does not provide an optimized result via FeatureSource.getCount( Query ).
- Specified by:
getCountin classDataFeatureCollection- Throws:
IOException- If feature could not be readDataSourceException- See IOException- See Also:
org.geotools.data.FeatureResults#getCount()
-
collection
public SimpleFeatureCollection collection() throws IOException
- Throws:
IOException
-
-