org.geotools.data.gen
Class PreGeneralizedDataStore

Object
  extended by PreGeneralizedDataStore
All Implemented Interfaces:
DataAccess<SimpleFeatureType,SimpleFeature>, DataStore

public class PreGeneralizedDataStore
extends Object
implements DataStore

Author:
Christian Mueller Datastore for multiple feature types with pregeneralized geometries The data store is read only, all modifying methods throw an UnsupportedOperationException This data store does business as usual with the following exception: If a method has a Query parameter and Query.getHints() includes Hints.GEOMETRY_DISTANCE with a given distance, the datastore looks for the best fit pregeneralized geometries and returns these geometries instead of the original ones. This process results in a lower memory usage, lower cpu usage for further processing and will decrease response time for the user.

Constructor Summary
PreGeneralizedDataStore(GeneralizationInfos infos, Repository repository)
           
PreGeneralizedDataStore(GeneralizationInfos infos, Repository repository, URI namespace)
           
 
Method Summary
 void createSchema(SimpleFeatureType featureType)
          Creates storage for a new featureType.
 void dispose()
          Disposes of this data store and releases any resource that it is using.
 FeatureReader<SimpleFeatureType,SimpleFeature> getFeatureReader(Query query, Transaction transaction)
          Access a FeatureReader providing access to Feature information.
 FeatureSource<SimpleFeatureType,SimpleFeature> getFeatureSource(Name typeName)
          Access to the named resource.
 FeatureSource<SimpleFeatureType,SimpleFeature> getFeatureSource(String typeName)
          Access a FeatureSource for typeName providing a high-level API.
 FeatureWriter<SimpleFeatureType,SimpleFeature> getFeatureWriter(String typeName, Filter filter, Transaction transaction)
          Access FeatureWriter for modification of existing DataStore contents.
 FeatureWriter<SimpleFeatureType,SimpleFeature> getFeatureWriter(String typeName, Transaction transaction)
          Access FeatureWriter for modification of the DataStore typeName.
 FeatureWriter<SimpleFeatureType,SimpleFeature> getFeatureWriterAppend(String typeName, Transaction transaction)
          Aquire a FeatureWriter for adding new content to a FeatureType.
 ServiceInfo getInfo()
          Information about this service.
 LockingManager getLockingManager()
          Retrieve a per featureID based locking service from this DataStore.
 List<Name> getNames()
          Names of the available Resources.
 URI getNamespace()
           
 SimpleFeatureType getSchema(Name name)
          Description of the named resource.
 SimpleFeatureType getSchema(String typeName)
          Retrieve FeatureType metadata by typeName.
 String[] getTypeNames()
          Retrieves a list of of the available FeatureTypes.
 FeatureSource<SimpleFeatureType,SimpleFeature> getView(Query query)
          Access a FeatureSource for Query providing a high-level API.
 void updateSchema(Name typeName, SimpleFeatureType featureType)
          Used to update a schema in place.
 void updateSchema(String typeName, SimpleFeatureType featureType)
          Used to force namespace and CS info into a persistent change.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PreGeneralizedDataStore

public PreGeneralizedDataStore(GeneralizationInfos infos,
                               Repository repository)
Parameters:
infos -
repository -

PreGeneralizedDataStore

public PreGeneralizedDataStore(GeneralizationInfos infos,
                               Repository repository,
                               URI namespace)
Parameters:
infos -
repository -
namespace -
Method Detail

getNamespace

public URI getNamespace()

getFeatureReader

public FeatureReader<SimpleFeatureType,SimpleFeature> getFeatureReader(Query query,
                                                                       Transaction transaction)
                                                                throws 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:
IOException

getFeatureSource

public FeatureSource<SimpleFeatureType,SimpleFeature> getFeatureSource(String typeName)
                                                                throws 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:
IOException

getFeatureWriter

public FeatureWriter<SimpleFeatureType,SimpleFeature> getFeatureWriter(String typeName,
                                                                       Transaction transaction)
                                                                throws IOException
Description copied from interface: DataStore
Access FeatureWriter for modification of the DataStore typeName.

FeatureWriters will need to be limited to the FeatureTypes defined by the DataStore, the easiest way to express this limitation is to the FeatureType by a provided typeName.

The returned FeatureWriter will return false for getNext() when it reaches the end of the Query.

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:
IOException

getFeatureWriter

public FeatureWriter<SimpleFeatureType,SimpleFeature> getFeatureWriter(String typeName,
                                                                       Filter filter,
                                                                       Transaction transaction)
                                                                throws IOException
Description copied from interface: DataStore
Access FeatureWriter for modification of existing DataStore contents.

To limit FeatureWriter to the FeatureTypes defined by this DataStore, typeName is used to indicate FeatureType. The resulting feature writer will allow modifications against the same FeatureType provided by getSchema( typeName )

The FeatureWriter will provide access to the existing contents of the FeatureType referenced by typeName. The provided filter will be used to skip over Features as required.

Notes For Implementing DataStore

The returned FeatureWriter does not support the addition of new Features to FeatureType (it would need to police your modifications to agree with filer). As such it will return false for getNext() when it reaches the end of the Query and NoSuchElementException when next() is called.

Helper classes for implementing a FeatureWriter (in order):

  • InProcessLockingManager.checkedWriter( writer ) - provides a check against locks before allowing modification
  • FilteringFeatureWriter - filtering support for FeatureWriter (does not allow new content)
  • DiffFeatureWriter - In-Process Transaction Support (see TransactionStateDiff)
  • EmptyFeatureWriter - provides no content for Filter.EXCLUDE optimizations
  • 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:
    IOException

    getFeatureWriterAppend

    public FeatureWriter<SimpleFeatureType,SimpleFeature> getFeatureWriterAppend(String typeName,
                                                                                 Transaction transaction)
                                                                          throws IOException
    Description copied from interface: DataStore
    Aquire a FeatureWriter for adding new content to a FeatureType.

    This FeatureWriter will return false for hasNext(), however next() may be used to aquire new Features that may be writen out to add new content.

    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:
    IOException

    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:
    DataStores may return null, if the handling locking in another fashion.

    getSchema

    public SimpleFeatureType getSchema(String typeName)
                                throws IOException
    Description copied from interface: DataStore
    Retrieve FeatureType metadata by typeName.

    Retrieves the Schema information as a FeatureType object.

    Specified by:
    getSchema in interface DataStore
    Parameters:
    typeName - typeName of requested FeatureType
    Returns:
    FeatureType for the provided typeName
    Throws:
    IOException - If typeName cannot be found

    getTypeNames

    public String[] getTypeNames()
                          throws 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:
    IOException

    getView

    public FeatureSource<SimpleFeatureType,SimpleFeature> getView(Query query)
                                                           throws 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:
    IOException - If FeatureSource is not available
    SchemaException - If fetureType is not covered by existing schema

    updateSchema

    public void updateSchema(String typeName,
                             SimpleFeatureType featureType)
                      throws 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:
    IOException

    createSchema

    public void createSchema(SimpleFeatureType featureType)
                      throws 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<SimpleFeatureType,SimpleFeature>
    Parameters:
    featureType - FetureType to add to DataStore
    Throws:
    IOException - If featureType cannot be created

    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<SimpleFeatureType,SimpleFeature>

    getFeatureSource

    public FeatureSource<SimpleFeatureType,SimpleFeature> getFeatureSource(Name typeName)
                                                                    throws 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:


    getInfo

    public ServiceInfo getInfo()
    Description copied from interface: DataAccess
    Information about this service.

    This method offers access to a summary of header or metadata information describing the service.

    Subclasses may return a specific ServiceInfo instance that has additional information (such as FilterCapabilities).

    Specified by:
    getInfo in interface DataAccess<SimpleFeatureType,SimpleFeature>
    Returns:
    SeviceInfo

    getNames

    public List<Name> getNames()
                        throws 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<SimpleFeatureType,SimpleFeature>
    Returns:
    Names of the available contents.
    Throws:
    IOException

    getSchema

    public SimpleFeatureType getSchema(Name name)
                                throws 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<SimpleFeatureType,SimpleFeature>
    Parameters:
    name - Type name a the resource from getNames()
    Returns:
    Description of the FeatureType being made avaialble
    Throws:
    IOException

    updateSchema

    public void updateSchema(Name typeName,
                             SimpleFeatureType featureType)
                      throws 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<SimpleFeatureType,SimpleFeature>
    Throws:
    IOException - if the operation failed


    Copyright © 1996-2009 Geotools. All Rights Reserved.