org.geotools.data.wfs.v1_1_0
Class WFS_1_1_0_DataStore

java.lang.Object
  extended by org.geotools.data.wfs.v1_1_0.WFS_1_1_0_DataStore
All Implemented Interfaces:
DataAccess<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>, DataStore, WFSDataStore

public final class WFS_1_1_0_DataStore
extends java.lang.Object
implements WFSDataStore

A WFS 1.1 DataStore implementation.

Note with the current design, this class is meant to be pulled up as the single WFS DataStore implementation regardless of the WFS version, since the protocol version specifics is meant to be handled by the WFSProtocol implementation provided to this class. For the time being, while there are no resources to spend on porting the WFS 1.0.0 datastore to the new design, this keeps here in this 1.1 specific package.

Since:
2.5.x
Version:
$Id: WFS_1_1_0_DataStore.java 34194 2009-10-22 12:50:00Z groldan $
Author:
Gabriel Roldan

Constructor Summary
WFS_1_1_0_DataStore(WFSProtocol wfs)
          The WFS capabilities document.
 
Method Summary
 void createSchema(org.opengis.feature.simple.SimpleFeatureType featureType)
          Creates storage for a new featureType.
 void dispose()
          Disposes of this data store and releases any resource that it is using.
 ReferencedEnvelope getBounds(Query query)
          Only returns the bounds of the query (ie, the bounds of the whole feature type) if the query has no filter set, otherwise the bounds may be too expensive to acquire.
 java.net.URL getCapabilitiesURL()
           
 int getCount(Query query)
          If the query is fully supported, makes a GetFeature request with resultType=hits and returns the counts returned by the server, otherwise returns -1 as the result is too expensive to calculate.
 java.net.URL getDescribeFeatureTypeURL(java.lang.String typeName)
           
 FeatureReader<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature> getFeatureReader(Query query, Transaction transaction)
          Access a FeatureReader providing access to Feature information.
 FeatureSource<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature> getFeatureSource(org.opengis.feature.type.Name typeName)
          Access to the named resource.
 WFSFeatureSource getFeatureSource(java.lang.String typeName)
          Access a FeatureSource for typeName providing a high-level API.
 java.lang.String getFeatureTypeAbstract(java.lang.String typeName)
           
 ReferencedEnvelope getFeatureTypeBounds(java.lang.String typeName)
           
 org.opengis.referencing.crs.CoordinateReferenceSystem getFeatureTypeCRS(java.lang.String typeName)
           
 java.util.Set<java.lang.String> getFeatureTypeKeywords(java.lang.String typeName)
           
 javax.xml.namespace.QName getFeatureTypeName(java.lang.String typeName)
           
 java.lang.String getFeatureTypeTitle(java.lang.String typeName)
           
 ReferencedEnvelope getFeatureTypeWGS84Bounds(java.lang.String typeName)
           
 FeatureWriter<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature> getFeatureWriter(java.lang.String typeName, org.opengis.filter.Filter filter, Transaction transaction)
          Not supported.
 FeatureWriter<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature> getFeatureWriter(java.lang.String typeName, Transaction transaction)
          Not supported.
 FeatureWriter<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature> getFeatureWriterAppend(java.lang.String typeName, Transaction transaction)
          Not supported.
 WFSServiceInfo getInfo()
          Overrides DataAccess.getInfo() so it type narrows to a WFSServiceInfo
 LockingManager getLockingManager()
          Retrieve a per featureID based locking service from this DataStore.
 java.lang.Integer getMaxFeatures()
           
protected  int getMaxFeatures(Query query)
           
 java.util.List<org.opengis.feature.type.Name> getNames()
          Names of the available Resources.
 org.opengis.feature.simple.SimpleFeatureType getSchema(org.opengis.feature.type.Name name)
          Description of the named resource.
 org.opengis.feature.simple.SimpleFeatureType getSchema(java.lang.String prefixedTypeName)
          Makes a DescribeFeatureType request for typeName feature type, parses the server response into a SimpleFeatureType and returns it.
 java.lang.String getServiceAbstract()
           
 java.util.Set<java.lang.String> getServiceKeywords()
           
 java.net.URI getServiceProviderUri()
           
 java.lang.String getServiceTitle()
           
 java.lang.String getServiceVersion()
           
 java.lang.String[] getTypeNames()
          Retrieves a list of of the available FeatureTypes.
 FeatureSource<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature> getView(Query query)
          Access a FeatureSource for Query providing a high-level API.
 boolean isPreferPostOverGet()
           
 void setMaxFeatures(java.lang.Integer maxFeatures)
           
 void setPreferPostOverGet(java.lang.Boolean booleanValue)
           
 java.lang.String toString()
           
 void updateSchema(org.opengis.feature.type.Name typeName, org.opengis.feature.simple.SimpleFeatureType featureType)
          Used to update a schema in place.
 void updateSchema(java.lang.String typeName, org.opengis.feature.simple.SimpleFeatureType featureType)
          Used to force namespace and CS info into a persistent change.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WFS_1_1_0_DataStore

public WFS_1_1_0_DataStore(WFSProtocol wfs)
The WFS capabilities document.

Parameters:
capabilities -
Method Detail

setMaxFeatures

public void setMaxFeatures(java.lang.Integer maxFeatures)
Specified by:
setMaxFeatures in interface WFSDataStore
See Also:
WFSDataStore.setMaxFeatures(Integer)

getMaxFeatures

public java.lang.Integer getMaxFeatures()
Specified by:
getMaxFeatures in interface WFSDataStore
See Also:
WFSDataStore.getMaxFeatures()

isPreferPostOverGet

public boolean isPreferPostOverGet()
Specified by:
isPreferPostOverGet in interface WFSDataStore
See Also:
WFSDataStore.isPreferPostOverGet()

setPreferPostOverGet

public void setPreferPostOverGet(java.lang.Boolean booleanValue)
Specified by:
setPreferPostOverGet in interface WFSDataStore
Parameters:
booleanValue - Boolean.TRUE to prefer POST over GET, Boolean.FALSE for the opposite, null for auto (let the implementation decide)
See Also:
WFSDataStore#setPreferPostOverGet(boolean)

getInfo

public WFSServiceInfo getInfo()
Description copied from interface: WFSDataStore
Overrides DataAccess.getInfo() so it type narrows to a WFSServiceInfo

Specified by:
getInfo in interface DataAccess<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
Specified by:
getInfo in interface WFSDataStore
Returns:
service information
See Also:
WFSDataStore.getInfo()

getSchema

public org.opengis.feature.simple.SimpleFeatureType getSchema(java.lang.String prefixedTypeName)
                                                       throws java.io.IOException
Makes a DescribeFeatureType request for typeName feature type, parses the server response into a SimpleFeatureType and returns it.

Due to a current limitation widely spread through the GeoTools library, the parsed FeatureType will be adapted to share the same name than the Features produced for it. For example, if the actual feature type name is Streams_Type and the features name (i.e. which is the FeatureType name as stated in the WFS capabilities document) is Stream, the returned feature type name will also be Stream.

Specified by:
getSchema in interface DataStore
Parameters:
prefixedTypeName - the type name as stated in the WFS capabilities document
Returns:
the GeoTools FeatureType for the typeName as stated on the capabilities document.
Throws:
java.io.IOException - If typeName cannot be found
See Also:
DataStore.getSchema(java.lang.String)

getSchema

public org.opengis.feature.simple.SimpleFeatureType getSchema(org.opengis.feature.type.Name name)
                                                       throws java.io.IOException
Description copied from interface: DataAccess
Description of the named resource.

The FeatureType returned describes the contents being published. For additional metadata please review getInfo( Name ).

Specified by:
getSchema in interface DataAccess<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
Parameters:
name - Type name a the resource from getNames()
Returns:
Description of the FeatureType being made avaialble
Throws:
java.io.IOException
See Also:
DataAccess.getSchema(Name), getSchema(String)

getNames

public java.util.List<org.opengis.feature.type.Name> getNames()
                                                       throws java.io.IOException
Description copied from interface: DataAccess
Names of the available Resources.

For additional information please see getInfo( Name ) and getSchema( Name ).

Specified by:
getNames in interface DataAccess<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
Returns:
Names of the available contents.
Throws:
java.io.IOException
See Also:
DataAccess.getNames()

getTypeNames

public java.lang.String[] getTypeNames()
                                throws java.io.IOException
Description copied from interface: DataStore
Retrieves a list of of the available FeatureTypes.

This is simply a list of the FeatureType names as aquiring the actual FeatureType schemas may be expensive.

Warning: this list may not be unique - the types may be in separate namespaces.

If you need to worry about such things please consider the use of the Catalog and CatalogEntry interface - many DataStores support this. getTypeNames is really a convience method for a Catalog.iterator() where the name of each entry is returned.

Specified by:
getTypeNames in interface DataStore
Returns:
typeNames for available FeatureTypes.
Throws:
java.io.IOException
See Also:
DataStore.getTypeNames()

dispose

public void dispose()
Description copied from interface: DataAccess
Disposes of this data store and releases any resource that it is using.

A DataStore cannot be used after dispose has been called, neither can any data access object it helped create, such as FeatureReader, FeatureSource or FeatureCollection.

This operation can be called more than once without side effects.

There is no thread safety assurance associated with this method. For example, client code will have to make sure this method is not called while retrieving/saving data from/to the storage, or be prepared for the consequences.

Specified by:
dispose in interface DataAccess<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
See Also:
DataAccess.dispose()

getFeatureReader

public FeatureReader<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature> getFeatureReader(Query query,
                                                                                                                             Transaction transaction)
                                                                                                                      throws java.io.IOException
Description copied from interface: DataStore
Access a FeatureReader providing access to Feature information.

Filter is used as a low-level indication of constraints. (Implementations may resort to using a FilteredFeatureReader, or provide their own optimizations)

FeatureType provides a template for the returned FeatureReader

Transaction to externalize DataStore state on a per Transaction basis. The most common example is a JDBC datastore saving a Connection for use across several FeatureReader requests. Similarly a Shapefile reader may wish to redirect FeatureReader requests to a alternate filename over the course of a Transaction.

Notes For Implementing DataStore

Subclasses may need to retrieve additional attributes, beyond those requested by featureType.getAttributeTypes(), in order to correctly apply the filter.
These Additional attribtues should be not be returned by FeatureReader. Subclasses may use ReTypeFeatureReader to aid in acomplishing this.

Helper classes for implementing a FeatureReader (in order):

Sample use (not optimized):


 if (filter == Filter.EXCLUDE) {
      return new EmptyFeatureReader(featureType);
  }

  String typeName = featureType.getTypeName();
  FeatureType schema = getSchema( typeName );
  FeatureReader reader = new DefaultFeatureReader( getAttributeReaders(), schema );

  if (filter != Filter.INCLUDE) {
      reader = new FilteringFeatureReader(reader, filter);
  }

  if (transaction != Transaction.AUTO_COMMIT) {
      Map diff = state(transaction).diff(typeName);
      reader = new DiffFeatureReader(reader, diff);
  }

  if (!featureType.equals(reader.getFeatureType())) {
      reader = new ReTypeFeatureReader(reader, featureType);
  }
 return reader
 

Locking support does not need to be provided for FeatureReaders.

Specified by:
getFeatureReader in interface DataStore
Parameters:
query - Requested form of the returned Features and the filter used to constraints the results
transaction - Transaction this query operates against
Returns:
FeatureReader Allows Sequential Processing of featureType
Throws:
java.io.IOException
See Also:
DataStore.getFeatureReader(org.geotools.data.Query, org.geotools.data.Transaction)

getFeatureSource

public WFSFeatureSource getFeatureSource(java.lang.String typeName)
                                  throws java.io.IOException
Description copied from interface: DataStore
Access a FeatureSource for typeName providing a high-level API.

The resulting FeatureSource may implment more functionality:



 FeatureSource fsource = dataStore.getFeatureSource( "roads" );
 FeatureStore fstore = null;
 if( fsource instanceof FeatureLocking ){
     fstore = (FeatureStore) fs;
 }
 else {
     System.out.println("We do not have write access to roads");
 }
 
 

Specified by:
getFeatureSource in interface DataStore
Returns:
FeatureSource (or subclass) providing operations for typeName
Throws:
java.io.IOException
See Also:
DataStore.getFeatureSource(java.lang.String)

getLockingManager

public LockingManager getLockingManager()
Description copied from interface: DataStore
Retrieve a per featureID based locking service from this DataStore.

It is common to return an instanceof InProcessLockingManager for DataStores that do not provide native locking.

AbstractFeatureLocking makes use of this service to provide locking support. You are not limitied by this implementation and may simply return null for this value.

Specified by:
getLockingManager in interface DataStore
Returns:
null, no lock support so far
See Also:
DataStore.getLockingManager()

getView

public FeatureSource<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature> getView(Query query)
                                                                                                             throws java.io.IOException,
                                                                                                                    SchemaException
Description copied from interface: DataStore
Access a FeatureSource for Query providing a high-level API.

The provided Query does not need to completely cover the existing schema for Query.getTypeName(). The result will mostly likely only be a FeatureSource and probably wont' allow write access by the FeatureStore method.

By using Query we allow support for reprojection, in addition to overriding the CoordinateSystem used by the native FeatureType.

We may wish to limit this method to only support Queries using Filter.EXCLUDE.

Update - GeoServer has an elegatent implementation of this functionality that we could steal. GeoServerFeatureSource, GeoServerFeatureStore and GeoServerFeatureLocking serve as a working prototype.

Specified by:
getView in interface DataStore
Parameters:
query - Query.getTypeName() locates FeatureType being viewed
Returns:
FeatureSource providing operations for featureType
Throws:
java.io.IOException - If FeatureSource is not available
SchemaException - If fetureType is not covered by existing schema
See Also:
DataStore.getView(org.geotools.data.Query), DefaultView

getFeatureWriter

public FeatureWriter<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature> getFeatureWriter(java.lang.String typeName,
                                                                                                                             org.opengis.filter.Filter filter,
                                                                                                                             Transaction transaction)
                                                                                                                      throws java.io.IOException
Not supported.

Specified by:
getFeatureWriter in interface DataStore
Parameters:
typeName - Indicates featureType to be modified
filter - constraints used to limit the modification
transaction - Transaction this query operates against
Returns:
FeatureWriter Allows Sequential Modification of featureType
Throws:
java.lang.UnsupportedOperationException - always since this operation does not apply to a WFS backend
java.io.IOException
See Also:
DataStore.getFeatureWriter(java.lang.String, org.opengis.filter.Filter, org.geotools.data.Transaction)

getFeatureWriter

public FeatureWriter<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature> getFeatureWriter(java.lang.String typeName,
                                                                                                                             Transaction transaction)
                                                                                                                      throws java.io.IOException
Not supported.

Specified by:
getFeatureWriter in interface DataStore
Parameters:
typeName - Indicates featureType to be modified
transaction - Transaction to operates against
Returns:
FeatureReader Allows Sequential Processing of featureType
Throws:
java.lang.UnsupportedOperationException - always since this operation does not apply to a WFS backend
java.io.IOException
See Also:
DataStore.getFeatureWriter(java.lang.String, org.geotools.data.Transaction)

getFeatureWriterAppend

public FeatureWriter<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature> getFeatureWriterAppend(java.lang.String typeName,
                                                                                                                                   Transaction transaction)
                                                                                                                            throws java.io.IOException
Not supported.

Specified by:
getFeatureWriterAppend in interface DataStore
Parameters:
typeName - Indicates featureType to be modified
transaction - Transaction to operates against
Returns:
FeatureWriter that may only be used to append new content
Throws:
java.lang.UnsupportedOperationException - always since this operation does not apply to a WFS backend
java.io.IOException
See Also:
DataStore.getFeatureWriterAppend(java.lang.String, org.geotools.data.Transaction)

getFeatureSource

public FeatureSource<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature> getFeatureSource(org.opengis.feature.type.Name typeName)
                                                                                                                      throws java.io.IOException
Description copied from interface: DataAccess
Access to the named resource.

The level of access is represented by the instance of the FeatureSource being returned.

Formally:


updateSchema

public void updateSchema(org.opengis.feature.type.Name typeName,
                         org.opengis.feature.simple.SimpleFeatureType featureType)
                  throws java.io.IOException
Description copied from interface: DataAccess
Used to update a schema in place.

This functionality is similar to an "alter table" statement in SQL. Implementation is optional; it may not be supported by all servers or files.

Specified by:
updateSchema in interface DataAccess<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
Throws:
java.lang.UnsupportedOperationException - always since this operation does not apply to a WFS backend
java.io.IOException - if the operation failed
See Also:
DataAccess.updateSchema(Name, org.opengis.feature.type.FeatureType)

updateSchema

public void updateSchema(java.lang.String typeName,
                         org.opengis.feature.simple.SimpleFeatureType featureType)
                  throws java.io.IOException
Description copied from interface: DataStore
Used to force namespace and CS info into a persistent change.

The provided featureType should completely cover the existing schema. All attributes should be accounted for and the typeName should match.

Suggestions:

Specified by:
updateSchema in interface DataStore
Throws:
java.lang.UnsupportedOperationException - always since this operation does not apply to a WFS backend
java.io.IOException
See Also:
DataStore.updateSchema(java.lang.String, org.opengis.feature.simple.SimpleFeatureType)

createSchema

public void createSchema(org.opengis.feature.simple.SimpleFeatureType featureType)
                  throws java.io.IOException
Description copied from interface: DataAccess
Creates storage for a new featureType.

The provided featureType we be accessable by the typeName provided by featureType.getTypeName().

Specified by:
createSchema in interface DataAccess<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
Parameters:
featureType - FetureType to add to DataStore
Throws:
java.lang.UnsupportedOperationException - always since this operation does not apply to a WFS backend
java.io.IOException - If featureType cannot be created
See Also:
org.geotools.data.DataStore#createSchema(org.opengis.feature.simple.SimpleFeatureType)

getFeatureTypeName

public javax.xml.namespace.QName getFeatureTypeName(java.lang.String typeName)
Specified by:
getFeatureTypeName in interface WFSDataStore
See Also:
WFSDataStore.getFeatureTypeName(java.lang.String)

getFeatureTypeTitle

public java.lang.String getFeatureTypeTitle(java.lang.String typeName)
Specified by:
getFeatureTypeTitle in interface WFSDataStore
See Also:
WFSDataStore.getFeatureTypeTitle(String)

getFeatureTypeAbstract

public java.lang.String getFeatureTypeAbstract(java.lang.String typeName)
Specified by:
getFeatureTypeAbstract in interface WFSDataStore
See Also:
WFSDataStore.getFeatureTypeAbstract(String)

getFeatureTypeWGS84Bounds

public ReferencedEnvelope getFeatureTypeWGS84Bounds(java.lang.String typeName)
Specified by:
getFeatureTypeWGS84Bounds in interface WFSDataStore
See Also:
WFSDataStore.getFeatureTypeWGS84Bounds(String)

getFeatureTypeBounds

public ReferencedEnvelope getFeatureTypeBounds(java.lang.String typeName)
Specified by:
getFeatureTypeBounds in interface WFSDataStore
See Also:
WFSDataStore.getFeatureTypeBounds(String)

getFeatureTypeCRS

public org.opengis.referencing.crs.CoordinateReferenceSystem getFeatureTypeCRS(java.lang.String typeName)
Specified by:
getFeatureTypeCRS in interface WFSDataStore
Returns:
a non null CRS for the feature type, if the actual CRS can't be determined, DefaultEngineeringCRS.GENERIC_2D is returned
See Also:
WFSDataStore.getFeatureTypeCRS(String)

getFeatureTypeKeywords

public java.util.Set<java.lang.String> getFeatureTypeKeywords(java.lang.String typeName)
Specified by:
getFeatureTypeKeywords in interface WFSDataStore
See Also:
WFSDataStore.getFeatureTypeKeywords(String)

getDescribeFeatureTypeURL

public java.net.URL getDescribeFeatureTypeURL(java.lang.String typeName)
Specified by:
getDescribeFeatureTypeURL in interface WFSDataStore
See Also:
WFSDataStore.getDescribeFeatureTypeURL(String)

getServiceAbstract

public java.lang.String getServiceAbstract()
Specified by:
getServiceAbstract in interface WFSDataStore
See Also:
WFSDataStore.getServiceAbstract()

getServiceKeywords

public java.util.Set<java.lang.String> getServiceKeywords()
Specified by:
getServiceKeywords in interface WFSDataStore
See Also:
WFSDataStore.getServiceKeywords()

getServiceProviderUri

public java.net.URI getServiceProviderUri()
Specified by:
getServiceProviderUri in interface WFSDataStore
See Also:
WFSDataStore.getServiceProviderUri()

getCapabilitiesURL

public java.net.URL getCapabilitiesURL()
Specified by:
getCapabilitiesURL in interface WFSDataStore
See Also:
WFSDataStore.getCapabilitiesURL()

getServiceTitle

public java.lang.String getServiceTitle()
Specified by:
getServiceTitle in interface WFSDataStore
See Also:
WFSDataStore#getserviceTitle()

getServiceVersion

public java.lang.String getServiceVersion()
Specified by:
getServiceVersion in interface WFSDataStore
See Also:
WFSDataStore.getServiceVersion()

getBounds

public ReferencedEnvelope getBounds(Query query)
                             throws java.io.IOException
Only returns the bounds of the query (ie, the bounds of the whole feature type) if the query has no filter set, otherwise the bounds may be too expensive to acquire.

Parameters:
query -
Returns:
The bounding box of the datasource in the CRS required by the query, or null if unknown and too expensive for the method to calculate or any errors occur.
Throws:
java.io.IOException

getCount

public int getCount(Query query)
             throws java.io.IOException
If the query is fully supported, makes a GetFeature request with resultType=hits and returns the counts returned by the server, otherwise returns -1 as the result is too expensive to calculate.

Parameters:
query -
Returns:
the number of features returned by a GetFeature?resultType=hits request, or -1 if not supported
Throws:
java.io.IOException

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getMaxFeatures

protected int getMaxFeatures(Query query)


Copyright © 1996-2010 Geotools. All Rights Reserved.