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 Details

    • 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 Details

    • 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 Details

    • getSchema

      public 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<SimpleFeatureType,SimpleFeature>
      Overrides:
      getSchema in class DataFeatureCollection
      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

      Retrieve a FeatureReader<SimpleFeatureType, SimpleFeature> for this Query
      Overrides:
      reader in class DataFeatureCollection
      Returns:
      FeatureReader<SimpleFeatureType, SimpleFeature> for this Query
      Throws:
      IOException - If results could not be obtained
    • boundsReader

      protected FeatureReader<SimpleFeatureType,SimpleFeature> boundsReader() throws IOException
      Retrieve a FeatureReader<SimpleFeatureType, SimpleFeature> for the geometry attributes only, designed for bounds computation
      Throws:
      IOException
    • getBounds

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

      This 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:
      getBounds in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
      Specified by:
      getBounds in class DataFeatureCollection
      Returns:
      An Envelope containing the total bounds of this collection.
      See Also:
      • org.geotools.data.FeatureResults#getBounds()
    • getCount

      public int getCount() throws IOException
      Number 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:
      getCount in class DataFeatureCollection
      Throws:
      IOException - If feature could not be read
      DataSourceException - See IOException
      See Also:
      • org.geotools.data.FeatureResults#getCount()
    • collection

      public SimpleFeatureCollection collection() throws IOException
      Throws:
      IOException