org.geotools.data
Interface FeatureSource

All Known Subinterfaces:
FeatureLocking, FeatureStore
All Known Implementing Classes:
AbstractFeatureLocking, AbstractFeatureSource, AbstractFeatureStore, DefaultView, JDBCFeatureLocking, JDBCFeatureSource, JDBCFeatureStore, PostgisFeatureLocking, WFSFeatureStore

public interface FeatureSource

Highlevel API for Features from a specific location.

Individual Shapefiles, databases tables , etc. are referenced through this interface. Compare and constrast with DataStore.

Differences from DataStore:

Version:
$Id: FeatureSource.java 17702 2006-01-23 00:08:55Z desruisseaux $
Author:
Jody Garnett, Ray Gallagher, Rob Hranac, TOPP, Chris Holmes, TOPP

Method Summary
 void addFeatureListener(FeatureListener listener)
          Adds a listener to the list that's notified each time a change to the FeatureStore occurs.
 com.vividsolutions.jts.geom.Envelope getBounds()
          Gets the bounding box of this datasource.
 com.vividsolutions.jts.geom.Envelope getBounds(Query query)
          Gets the bounding box of the features that would be returned by this query.
 int getCount(Query query)
          Gets the number of the features that would be returned by this query.
 DataStore getDataStore()
          Access to the DataStore implementing this FeatureStore.
 FeatureCollection getFeatures()
          Loads all features from the datasource into the return FeatureResults.
 FeatureCollection getFeatures(Filter filter)
          Loads features from the datasource into the returned FeatureResults, based on the passed filter.
 FeatureCollection getFeatures(Query query)
          Loads features from the datasource into the returned FeatureResults, based on the passed query.
 FeatureType getSchema()
          Retrieves the featureType that features extracted from this datasource will be created with.
 void removeFeatureListener(FeatureListener listener)
          Removes a listener from the list that's notified each time a change to the FeatureStore occurs.
 

Method Detail

getDataStore

public DataStore getDataStore()
Access to the DataStore implementing this FeatureStore.

You may use this to access such as namespace provided by DataStore.

Returns:
DataStore implementing this FeatureStore

addFeatureListener

public void addFeatureListener(FeatureListener listener)
Adds a listener to the list that's notified each time a change to the FeatureStore occurs.

Parameters:
listener - FeatureListener

removeFeatureListener

public void removeFeatureListener(FeatureListener listener)
Removes a listener from the list that's notified each time a change to the FeatureStore occurs.

Parameters:
listener - FeatureListener

getFeatures

public FeatureCollection getFeatures(Query query)
                              throws java.io.IOException
Loads features from the datasource into the returned FeatureResults, based on the passed query.

Parameters:
query - a datasource query object. It encapsulates requested information, such as typeName, maxFeatures and filter.
Returns:
Collection The collection to put the features into.
Throws:
java.io.IOException - For all data source errors.
See Also:
Query

getFeatures

public FeatureCollection getFeatures(Filter filter)
                              throws java.io.IOException
Loads features from the datasource into the returned FeatureResults, based on the passed filter.

Parameters:
filter - An OpenGIS filter; specifies which features to retrieve. null is not allowed, use Filter.NONE instead.
Returns:
Collection The collection to put the features into.
Throws:
java.io.IOException - For all data source errors.

getFeatures

public FeatureCollection getFeatures()
                              throws java.io.IOException
Loads all features from the datasource into the return FeatureResults.

Filter.NONE can also be used to get all features. Calling this function is equivalent to using Query.ALL

Returns:
Collection The collection to put the features into.
Throws:
java.io.IOException - For all data source errors.

getSchema

public FeatureType getSchema()
Retrieves the featureType that features extracted from this datasource will be created with.

The schema returned is the LCD supported by all available Features. In the common case of shapfiles and database table this schema will match that of every feature available. In the degenerate GML case this will simply reflect the gml:AbstractFeatureType.

Returns:
the schema of features created by this datasource.
Task:
REVISIT: Our current FeatureType model is not yet advanced enough to handle multiple featureTypes. Should getSchema take a typeName now that a query takes a typeName, and thus DataSources can now support multiple types? Or just wait until we can programmatically make powerful enough schemas?, REVISIT: we could also just use DataStore to capture multi FeatureTypes?

getBounds

public com.vividsolutions.jts.geom.Envelope getBounds()
                                               throws java.io.IOException
Gets the bounding box of this datasource.

With getBounds(Query) this becomes a convenience method for getBounds(Query.ALL), that is the bounds for all features contained here.

If getBounds() returns null due to expense consider using getFeatures().getBounds() as a an alternative.

Returns:
The bounding box of the datasource or null if unknown and too expensive for the method to calculate.
Throws:
java.io.IOException - if there are errors getting the bounding box.
Task:
REVISIT: Do we need this or can we use getBounds( Query.ALL )?

getBounds

public com.vividsolutions.jts.geom.Envelope getBounds(Query query)
                                               throws java.io.IOException
Gets the bounding box of the features that would be returned by this query.

To retrieve the bounds of the DataSource please use getBounds( Query.ALL ).

This method is needed if we are to stream features to a gml out, since a FeatureCollection must have a boundedBy element.

If getBounds(Query) returns null due to expense consider using getFeatures(Query).getBounds() as a an alternative.

Parameters:
query - Contains the Filter and MaxFeatures to find the bounds for.
Returns:
The bounding box of the datasource or null if unknown and too expensive for the method to calculate or any errors occur.
Throws:
java.io.IOException - DOCUMENT ME!

getCount

public int getCount(Query query)
             throws java.io.IOException
Gets the number of the features that would be returned by this query.

If getBounds(Query) returns -1 due to expense consider using getFeatures(Query).getCount() as a an alternative.

Parameters:
query - Contains the Filter and MaxFeatures to find the bounds for.
Returns:
The number of Features provided by the Query or -1 if count is too expensive to calculate or any errors or occur.
Throws:
java.io.IOException - if there are errors getting the count


Copyright © GeoTools. All Rights Reserved.