org.geotools.data
Class DefaultFeatureResults

java.lang.Object
  extended by org.geotools.data.store.DataFeatureCollection
      extended by org.geotools.data.DefaultFeatureResults
All Implemented Interfaces:
FeatureCollection<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
Direct Known Subclasses:
JDBCFeatureCollection, WFSFeatureSource.WFSFeatureResults

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
protected  FeatureSource<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature> 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.
protected  Query query
          Query used to define this subset of features from the feature source
protected  org.opengis.referencing.operation.MathTransform transform
           
 
Fields inherited from class org.geotools.data.store.DataFeatureCollection
id, listeners, schema
 
Constructor Summary
DefaultFeatureResults(FeatureSource<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature> source, Query query)
          FeatureResults query against featureSource.
 
Method Summary
protected  FeatureReader<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature> boundsReader()
          Retrieve a FeatureReader for the geometry attributes only, designed for bounds computation
 FeatureCollection<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature> collection()
           
 ReferencedEnvelope getBounds()
          Returns the bounding box of this FeatureResults
 int getCount()
          Number of Features in this query.
 org.opengis.feature.simple.SimpleFeatureType getSchema()
          FeatureSchema for provided query.
protected  Transaction getTransaction()
          Returns transaction from FeatureSource (if it is a FeatureStore), or Transaction.AUTO_COMMIT if it is not.
 FeatureReader<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature> reader()
          Retrieve a FeatureReader for this Query
 
Methods inherited from class org.geotools.data.store.DataFeatureCollection
accepts, 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, sort, subCollection, toArray, toArray, writer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

query

protected Query query
Query used to define this subset of features from the feature source


featureSource

protected FeatureSource<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature> 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 org.opengis.referencing.operation.MathTransform transform
Constructor Detail

DefaultFeatureResults

public DefaultFeatureResults(FeatureSource<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature> source,
                             Query query)
                      throws java.io.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 FeatureSource using AUTO_COMMIT.

Parameters:
source -
query -
Throws:
java.io.IOException
Method Detail

getSchema

public org.opengis.feature.simple.SimpleFeatureType getSchema()
FeatureSchema for provided query.

If query.retrieveAllProperties() is true the 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:
getSchema in interface FeatureCollection<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
Overrides:
getSchema in class DataFeatureCollection
Returns:
DOCUMENT ME!
Throws:
java.io.IOException - DOCUMENT ME!
DataSourceException - DOCUMENT ME!

getTransaction

protected Transaction getTransaction()
Returns transaction from FeatureSource (if it is a FeatureStore), or Transaction.AUTO_COMMIT if it is not.

Returns:
Transacstion this FeatureResults opperates against

reader

public FeatureReader<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature> reader()
                                                                                                            throws java.io.IOException
Retrieve a FeatureReader for this Query

Overrides:
reader in class DataFeatureCollection
Returns:
FeatureReader for this Query
Throws:
java.io.IOException - If results could not be obtained

boundsReader

protected FeatureReader<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature> boundsReader()
                                                                                                                     throws java.io.IOException
Retrieve a FeatureReader for the geometry attributes only, designed for bounds computation

Throws:
java.io.IOException

getBounds

public ReferencedEnvelope getBounds()
Returns the bounding box of this FeatureResults

This implementation will generate the correct results from reader() if the provided FeatureSource does not provide an optimized result via FeatureSource.getBounds( Query ).

If the feature has no geometry, then an empty envelope is returned.

Specified by:
getBounds in interface FeatureCollection<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
Specified by:
getBounds in class DataFeatureCollection
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 java.io.IOException
Number of Features in this query.

This implementation will generate the correct results from reader() if the provided FeatureSource does not provide an optimized result via FeatureSource.getCount( Query ).

Specified by:
getCount in class DataFeatureCollection
Throws:
java.io.IOException - If feature could not be read
DataSourceException - See IOException
See Also:
org.geotools.data.FeatureResults#getCount()

collection

public FeatureCollection<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature> collection()
                                                                                                                    throws java.io.IOException
Throws:
java.io.IOException


Copyright © 1996-2010 Geotools. All Rights Reserved.