Class DefaultView
- Object
-
- DefaultView
-
- All Implemented Interfaces:
FeatureSource<SimpleFeatureType,SimpleFeature>,SimpleFeatureSource
public class DefaultView extends Object implements SimpleFeatureSource
Wrapper for SimpleFeatureSource constrained by a Query.Support SimpleFeatureSource decorator that takes care of mapping a Query & SimpleFeatureSource with the schema and definition query configured for it.
Because GeoServer requires that attributes always be returned in the same order we need a way to smoothly inforce this. Could we use this class to do so?
WARNING: this class is a placeholder for ideas right now - it may not always impement FeatureSource.
- Author:
- Gabriel Rold�n
-
-
Field Summary
Fields Modifier and Type Field Description protected SimpleFeatureSourcesourceSimpleFeatureSource being served up
-
Constructor Summary
Constructors Constructor Description DefaultView(SimpleFeatureSource source, Query query)Creates a new GeoServerFeatureSource object.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddFeatureListener(FeatureListener listener)Implement addFeatureListener.static SimpleFeatureSourcecreate(SimpleFeatureSource source, Query query)Factory that make the correct decorator for the provided featureSource.ReferencedEnvelopegetBounds()Retrieves the total extent of this FeatureSource.ReferencedEnvelopegetBounds(Query query)Retrive the extent of the Query.intgetCount(Query query)Adjust query and forward to source.DataStoregetDataStore()Implement getDataStore.SimpleFeatureCollectiongetFeatures()Implement getFeatures.SimpleFeatureCollectiongetFeatures(Query query)Implement getFeatures.SimpleFeatureCollectiongetFeatures(Filter filter)Implement getFeatures.ResourceInfogetInfo()Returns information describing thisFeatureSourcewhich may include title, description and spatial parameters.NamegetName()Returns the name of the features (strictly, the name of theAttributeDescriptorfor the features) accessible through thisFeatureSource.QueryCapabilitiesgetQueryCapabilities()Enquire what what query capabilities thisFeatureSourcenatively supports.SimpleFeatureTypegetSchema()Implement getSchema.Set<RenderingHints.Key>getSupportedHints()Returns the set of hints that thisFeatureSourcesupports viaQueryrequests.protected FiltermakeDefinitionFilter(Filter filter)If a definition query has been configured for the FeatureTypeInfo, makes and return a new Filter that contains both the query's filter and the layer's definition one, by logic AND'ing them.protected QuerymakeDefinitionQuery(Query query)Takes a query and adapts it to match re definitionQuery filter configured for a feature type.voidremoveFeatureListener(FeatureListener listener)Implement removeFeatureListener.
-
-
-
Field Detail
-
source
protected SimpleFeatureSource source
SimpleFeatureSource being served up
-
-
Constructor Detail
-
DefaultView
public DefaultView(SimpleFeatureSource source, Query query) throws SchemaException
Creates a new GeoServerFeatureSource object.Grabs the following from query:
- typeName - only used if client does not supply
- cs - only used if client does not supply
- csForce - only used if client does not supply
- filter - combined with client filter
- propertyNames - combined with client filter (indicate property names that *must* be included)
- Parameters:
source- a FeatureSourcequery- Filter used to limit results- Throws:
SchemaException
-
-
Method Detail
-
getName
public Name getName()
Description copied from interface:FeatureSourceReturns the name of the features (strictly, the name of theAttributeDescriptorfor the features) accessible through thisFeatureSource.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 withSimpleFeatureandSimpleFeatureType, 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:
getNamein interfaceFeatureSource<SimpleFeatureType,SimpleFeature>- Returns:
- the name of the features accessible through this
FeatureSource - Since:
- 2.5
- See Also:
FeatureSource.getName()
-
create
public static SimpleFeatureSource create(SimpleFeatureSource source, Query query) throws SchemaException
Factory that make the correct decorator for the provided featureSource.This factory method is public and will be used to create all required subclasses. By comparison the constructors for this class have package visibiliy. TODO: revisit this - I am not sure I want write access to views (especially if they do reprojection).
- Throws:
SchemaException
-
makeDefinitionQuery
protected Query makeDefinitionQuery(Query query) throws IOException
Takes a query and adapts it to match re definitionQuery filter configured for a feature type. It won't handle coordinate system changesGrabs the following from query:
- typeName - only used if client does not supply
- filter - combined with client filter
- propertyNames - combined with client filter (indicate property names that *must* be included)
- Parameters:
query- Query against this DataStore- Returns:
- Query restricted to the limits of definitionQuery
- Throws:
IOException- See DataSourceExceptionDataSourceException- If query could not meet the restrictions of definitionQuery
-
makeDefinitionFilter
protected Filter makeDefinitionFilter(Filter filter) throws DataSourceException
If a definition query has been configured for the FeatureTypeInfo, makes and return a new Filter that contains both the query's filter and the layer's definition one, by logic AND'ing them.- Parameters:
filter- Origional user supplied Filter- Returns:
- Filter adjusted to the limitations of definitionQuery
- Throws:
DataSourceException- If the filter could not meet the limitations of definitionQuery
-
getDataStore
public DataStore getDataStore()
Implement getDataStore.Description ...
- Specified by:
getDataStorein interfaceFeatureSource<SimpleFeatureType,SimpleFeature>- Returns:
- See Also:
org.geotools.data.FeatureSource#getDataStore()
-
addFeatureListener
public void addFeatureListener(FeatureListener listener)
Implement addFeatureListener.Description ...
- Specified by:
addFeatureListenerin interfaceFeatureSource<SimpleFeatureType,SimpleFeature>- Parameters:
listener- the new listener- See Also:
org.geotools.data.FeatureSource#addFeatureListener(org.geotools.data.FeatureListener)
-
removeFeatureListener
public void removeFeatureListener(FeatureListener listener)
Implement removeFeatureListener.Description ...
- Specified by:
removeFeatureListenerin interfaceFeatureSource<SimpleFeatureType,SimpleFeature>- Parameters:
listener- the listener to remove- See Also:
org.geotools.data.FeatureSource#removeFeatureListener(org.geotools.data.FeatureListener)
-
getFeatures
public SimpleFeatureCollection getFeatures(Query query) throws IOException
Implement getFeatures.Description ...
- Specified by:
getFeaturesin interfaceFeatureSource<SimpleFeatureType,SimpleFeature>- Specified by:
getFeaturesin interfaceSimpleFeatureSource- 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:
org.geotools.data.FeatureSource#getFeatures(org.geotools.data.Query)
-
getFeatures
public SimpleFeatureCollection getFeatures(Filter filter) throws IOException
Implement getFeatures.Description ...
- Specified by:
getFeaturesin interfaceFeatureSource<SimpleFeatureType,SimpleFeature>- Specified by:
getFeaturesin interfaceSimpleFeatureSource- Parameters:
filter- the filter to select features; must not benull(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 SimpleFeatureCollection getFeatures() throws IOException
Implement getFeatures.Description ...
- Specified by:
getFeaturesin interfaceFeatureSource<SimpleFeatureType,SimpleFeature>- Specified by:
getFeaturesin interfaceSimpleFeatureSource- Returns:
- features retrieved by the
Query - Throws:
IOException- if the underlying data source cannot be accessed.- See Also:
org.geotools.data.FeatureSource#getFeatures()
-
getSchema
public SimpleFeatureType getSchema()
Implement getSchema.Description ...
- Specified by:
getSchemain interfaceFeatureSource<SimpleFeatureType,SimpleFeature>- Returns:
- See Also:
org.geotools.data.FeatureSource#getSchema()
-
getInfo
public ResourceInfo getInfo()
Description copied from interface:FeatureSourceReturns information describing thisFeatureSourcewhich may include title, description and spatial parameters. Note that in the returnedResourceInfoobject, the distinction between feature name and schema (feature type) name applies as discussed for FeatureSource.getName().- Specified by:
getInfoin interfaceFeatureSource<SimpleFeatureType,SimpleFeature>
-
getBounds
public ReferencedEnvelope getBounds() throws IOException
Retrieves the total extent of this FeatureSource.Please note this extent will reflect the provided definitionQuery.
- Specified by:
getBoundsin interfaceFeatureSource<SimpleFeatureType,SimpleFeature>- Returns:
- Extent of this FeatureSource, or
nullif no optimizations exist. - Throws:
IOException- If bounds of definitionQuery
-
getBounds
public ReferencedEnvelope getBounds(Query query) throws IOException
Retrive the extent of the Query.This method provides access to an optimized getBounds opperation. If no optimized opperation is available
nullwill be returned.You may still make use of getFeatures( Query ).getCount() which will return the correct answer (even if it has to itterate through all the results to do so.
- Specified by:
getBoundsin interfaceFeatureSource<SimpleFeatureType,SimpleFeature>- Parameters:
query- User's query- Returns:
- Extend of Query or
nullif no optimization is available - Throws:
IOException- If a problem is encountered with source
-
getCount
public int getCount(Query query)
Adjust query and forward to source.This method provides access to an optimized getCount opperation. If no optimized opperation is available
-1will be returned.You may still make use of getFeatures( Query ).getCount() which will return the correct answer (even if it has to itterate through all the results to do so).
- Specified by:
getCountin interfaceFeatureSource<SimpleFeatureType,SimpleFeature>- Parameters:
query- User's query.- Returns:
- Number of Features for Query, or -1 if no optimization is available.
-
getSupportedHints
public Set<RenderingHints.Key> getSupportedHints()
Description copied from interface:FeatureSourceReturns the set of hints that thisFeatureSourcesupports viaQueryrequests.Note: the existence of a specific hint does not guarantee that it will always be honored by the implementing class.
- Specified by:
getSupportedHintsin interfaceFeatureSource<SimpleFeatureType,SimpleFeature>- Returns:
- a set of
RenderingHints#Keyobjects; may be empty but nevernull - See Also:
Hints.FEATURE_DETACHED,Hints.JTS_GEOMETRY_FACTORY,Hints.JTS_COORDINATE_SEQUENCE_FACTORY,Hints.JTS_PRECISION_MODEL,Hints.JTS_SRID,Hints.GEOMETRY_DISTANCE,Hints.FEATURE_2D
-
getQueryCapabilities
public QueryCapabilities getQueryCapabilities()
Description copied from interface:FeatureSourceEnquire what what query capabilities thisFeatureSourcenatively supports. For example, whether queries can return sorted results.- Specified by:
getQueryCapabilitiesin interfaceFeatureSource<SimpleFeatureType,SimpleFeature>- Returns:
- the native query capabilities of this
FeatureSource
-
-