org.geotools.data.complex
Class MappingFeatureSource

Object
  extended by MappingFeatureSource
All Implemented Interfaces:
FeatureSource<FeatureType,Feature>

public class MappingFeatureSource
extends Object
implements FeatureSource<FeatureType,Feature>

A FeatureSource that uses a FeatureTypeMapping to perform Feature fetching.

Note that the number of Features available from a MappingFeatureReader may not match the number of features that resulted of executing the incoming query over the surrogate FeatureSource. This will be the case when grouping attributes has configured on the FeatureTypeMapping this reader is based on.

When a MappingFeatureReader is created, a delegated FeatureIterator will be created based on the information provided by the FeatureTypeMapping object. That delegate reader will be specialized in applying the appropiate mapping stratagy based on wether grouping has to be performed or not.

Since:
2.4
Author:
Gabriel Roldan (Axios Engineering), Ben Caradoc-Davies (CSIRO Earth Science and Resource Engineering)

Constructor Summary
MappingFeatureSource(AppSchemaDataAccess store, FeatureTypeMapping mapping)
           
 
Method Summary
 void addFeatureListener(FeatureListener listener)
          Registers a listening object that will be notified of changes to this FeatureSource.
 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 given Query.
 int getCount(Query query)
          Gets the number of the features that would be returned by the given Query, taking into account any settings for max features and start index set on the Query.
 DataAccess<FeatureType,Feature> getDataStore()
          Returns the data source, as a DataAccess object, providing this FeatureSource.
 FeatureCollection<FeatureType,Feature> getFeatures()
          Retrieves all features in the form of a FeatureCollection.
 FeatureCollection<FeatureType,Feature> getFeatures(Filter filter)
          Retrieves features, in the form of a FeatureCollection, based on an OGC Filter.
 FeatureCollection<FeatureType,Feature> getFeatures(Filter filter, Hints hints)
           
 FeatureCollection<FeatureType,Feature> getFeatures(Query query)
          Retrieves features, in the form of a FeatureCollection, based on a Query.
 ResourceInfo getInfo()
          Returns information describing this FeatureSource which may include title, description and spatial parameters.
 FeatureTypeMapping getMapping()
           
 Name getName()
          Returns the name of the features (strictly, the name of the AttributeDescriptor for the features) accessible through this FeatureSource.
 QueryCapabilities getQueryCapabilities()
          Enquire what what query capabilities this FeatureSource natively supports.
 FeatureType getSchema()
          Retrieves the schema (feature type) that will apply to features retrieved from this FeatureSource.
 Set<RenderingHints.Key> getSupportedHints()
          Not a supported operation.
 AttributeDescriptor getTargetFeature()
           
 void removeFeatureListener(FeatureListener listener)
          Removes an object from this FeatureSource's listeners.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MappingFeatureSource

public MappingFeatureSource(AppSchemaDataAccess store,
                            FeatureTypeMapping mapping)
Method Detail

addFeatureListener

public void addFeatureListener(FeatureListener listener)
Description copied from interface: FeatureSource
Registers a listening object that will be notified of changes to this FeatureSource.

Specified by:
addFeatureListener in interface FeatureSource<FeatureType,Feature>
Parameters:
listener - the new listener

getBounds

public ReferencedEnvelope getBounds()
                             throws IOException
Description copied from interface: FeatureSource
Get the spatial bounds of the feature data. This is equivalent to calling getBounds(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.

Specified by:
getBounds in interface FeatureSource<FeatureType,Feature>
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

public ReferencedEnvelope getBounds(Query query)
                             throws IOException
Description copied from interface: FeatureSource
Get the spatial bounds of the features that would be returned by the given Query.

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.

Specified by:
getBounds in interface FeatureSource<FeatureType,Feature>
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

public int getCount(Query query)
             throws IOException
Description copied from interface: FeatureSource
Gets the number of the features that would be returned by the given Query, taking into account any settings for max features and start index set on the Query.

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 call getFeatures(query).size() instead.

Example use:

 int count = featureSource.getCount();
 if( count == -1 ){
    count = featureSource.getFeatures( "typeName", count ).size();
 }

Specified by:
getCount in interface FeatureSource<FeatureType,Feature>
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

getDataStore

public DataAccess<FeatureType,Feature> getDataStore()
Description copied from interface: FeatureSource
Returns the data source, as a DataAccess object, providing this FeatureSource.

Specified by:
getDataStore in interface FeatureSource<FeatureType,Feature>
Returns:
the data source providing this FeatureSource

getSchema

public FeatureType getSchema()
Description copied from interface: FeatureSource
Retrieves the schema (feature type) that will apply to features retrieved from this FeatureSource.

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.

Specified by:
getSchema in interface FeatureSource<FeatureType,Feature>
Returns:
the schema that will apply to features retrieved from this FeatureSource

getTargetFeature

public AttributeDescriptor getTargetFeature()

getMapping

public FeatureTypeMapping getMapping()

getFeatures

public FeatureCollection<FeatureType,Feature> getFeatures(Query query)
                                                   throws IOException
Description copied from interface: FeatureSource
Retrieves features, in the form of a FeatureCollection, based on a Query.

Specified by:
getFeatures in interface FeatureSource<FeatureType,Feature>
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

public FeatureCollection<FeatureType,Feature> getFeatures(Filter filter)
                                                   throws IOException
Description copied from interface: FeatureSource
Retrieves features, in the form of a FeatureCollection, based on an OGC Filter.

Specified by:
getFeatures in interface FeatureSource<FeatureType,Feature>
Parameters:
filter - the filter to select features; must not be null (use Filter.INCLUDE instead)
Returns:
features retrieved by the Filter
Throws:
IOException - if the underlying data source cannot be accessed.
See Also:
Filter

getFeatures

public FeatureCollection<FeatureType,Feature> getFeatures(Filter filter,
                                                          Hints hints)
                                                   throws IOException
Throws:
IOException

getFeatures

public FeatureCollection<FeatureType,Feature> getFeatures()
                                                   throws IOException
Description copied from interface: FeatureSource
Retrieves all features in the form of a FeatureCollection.

The following statements are equivalent:


     featureSource.getFeatures();
     featureSource.getFeatures(Filter.INCLUDE);
     featureSource.getFeatures(Query.ALL);
 

Specified by:
getFeatures in interface FeatureSource<FeatureType,Feature>
Returns:
features retrieved by the Query
Throws:
IOException - if the underlying data source cannot be accessed.

removeFeatureListener

public void removeFeatureListener(FeatureListener listener)
Description copied from interface: FeatureSource
Removes an object from this FeatureSource's listeners.

Specified by:
removeFeatureListener in interface FeatureSource<FeatureType,Feature>
Parameters:
listener - the listener to remove

getInfo

public ResourceInfo getInfo()
Description copied from interface: FeatureSource
Returns information describing this FeatureSource which may include title, description and spatial parameters. Note that in the returned ResourceInfo object, the distinction between feature name and schema (feature type) name applies as discussed for FeatureSource.getName().

Specified by:
getInfo in interface FeatureSource<FeatureType,Feature>

getName

public Name getName()
Description copied from interface: FeatureSource
Returns the name of the features (strictly, the name of the AttributeDescriptor for the features) accessible through this FeatureSource.

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 with SimpleFeature and SimpleFeatureType, 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).

Specified by:
getName in interface FeatureSource<FeatureType,Feature>
Returns:
the name of the features accessible through this FeatureSource

getSupportedHints

public Set<RenderingHints.Key> getSupportedHints()
Not a supported operation.

Specified by:
getSupportedHints in interface FeatureSource<FeatureType,Feature>
Returns:
a set of RenderingHints#Key objects; may be empty but never null
See Also:
FeatureSource.getSupportedHints()

getQueryCapabilities

public QueryCapabilities getQueryCapabilities()
Description copied from interface: FeatureSource
Enquire what what query capabilities this FeatureSource natively supports. For example, whether queries can return sorted results.

Specified by:
getQueryCapabilities in interface FeatureSource<FeatureType,Feature>
Returns:
the native query capabilities of this FeatureSource
See Also:
FeatureSource.getQueryCapabilities()


Copyright © 1996-2014 Geotools. All Rights Reserved.