deegree-core-3.0-pre-nightly (2010/03/05 00:01) - official

org.deegree.feature.persistence.postgis
Class PostGISFeatureStore

java.lang.Object
  extended by org.deegree.feature.persistence.postgis.PostGISFeatureStore
All Implemented Interfaces:
FeatureStore

public class PostGISFeatureStore
extends Object
implements FeatureStore

FeatureStore implementation that uses a PostGIS/PostgreSQL database as backend.

Version:
$Revision: 22312 $, $Date: 2010-01-29 17:20:41 +0100 (Fr, 29 Jan 2010) $
Author:
Markus Schneider, last edited by: $Author: mschneider $
See Also:
FeatureStore

Field Summary
(package private)  Map<QName,Envelope> ftNameToBBox
           
(package private)  CRS storageSRS
           
 
Constructor Summary
PostGISFeatureStore(ApplicationSchema schema, String jdbcConnId, String dbSchema, CRS storageSRS, Map<QName,FeatureTypeMapping> relMapping)
          Creates a new PostGISFeatureStore for the given ApplicationSchema.
 
Method Summary
 FeatureStoreTransaction acquireTransaction()
          Acquires transactional access to the feature store.
 PostGISFeatureStoreTransaction acquireTransaction(Connection conn)
           
 void destroy()
          Called by the container to indicate that this FeatureStore instance is being taken out of service.
(package private)  Geometry getCompatibleGeometry(Geometry literal)
          Returns a transformed version of the given Geometry in the storage CRS.
(package private)  Geometry getCompatibleGeometry(Geometry literal, CRS crs)
          Returns a transformed version of the given Geometry in the specified CRS.
 Envelope getEnvelope(QName ftName)
          Returns the envelope for all stored features of the given type.
(package private)  short getFtId(QName ftName)
           
 LockManager getLockManager()
          Returns the associated LockManager.
(package private)  FeatureTypeMapping getMapping(QName ftName)
          Returns the relational mapping for the given feature type name.
 GMLObject getObjectById(String id)
          Retrieves the stored object with a certain id.
 ApplicationSchema getSchema()
          Returns the application schema that this FeatureStore serves.
 CRS getStorageSRS()
          Returns the native CRS used for storing geometries.
 void init()
          Called by the container to indicate that this FeatureStore instance is being placed into service.
 boolean isAvailable()
          Returns whether the store is currently able to perform operations.
(package private)  String qualifyTableName(String tableName)
          Returns the given table name qualified with the db schema.
 FeatureResultSet query(Query query)
          Performs the given query and returns the matching features as a FeatureResultSet.
 FeatureResultSet query(Query[] queries)
          Performs the given queries and returns the matching features as a FeatureResultSet.
 int queryHits(Query query)
          Returns the number of features that are matched by the given query.
 int queryHits(Query[] queries)
          Returns the number of features that are matched by the given queries.
(package private)  void releaseTransaction(PostGISFeatureStoreTransaction ta)
          Returns the transaction to the datastore.
(package private)  void setEnvelope(FeatureType ft, Envelope ftEnv)
          Sets the envelope for the given feature type.
(package private)  org.postgis.PGgeometry toPGPolygon(Envelope envelope, int srid)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ftNameToBBox

final Map<QName,Envelope> ftNameToBBox

storageSRS

final CRS storageSRS
Constructor Detail

PostGISFeatureStore

public PostGISFeatureStore(ApplicationSchema schema,
                           String jdbcConnId,
                           String dbSchema,
                           CRS storageSRS,
                           Map<QName,FeatureTypeMapping> relMapping)
Creates a new PostGISFeatureStore for the given ApplicationSchema.

Parameters:
schema - schema information, must not be null
jdbcConnId - id of the deegree DB connection pool, must not be null
dbSchema - name of the database schema, can be null (-> public schema)
storageSRS - srs used for stored geometries, must not be null
relMapping - key: feature type name, value: relational mapping information for feature type, may be null
Method Detail

getMapping

FeatureTypeMapping getMapping(QName ftName)
Returns the relational mapping for the given feature type name.

Parameters:
ftName - name of the feature type
Returns:
relational mapping for the feature type, may be null (no relational mapping)

acquireTransaction

public PostGISFeatureStoreTransaction acquireTransaction(Connection conn)
                                                  throws FeatureStoreException
Throws:
FeatureStoreException

acquireTransaction

public FeatureStoreTransaction acquireTransaction()
                                           throws FeatureStoreException
Description copied from interface: FeatureStore
Acquires transactional access to the feature store.

Specified by:
acquireTransaction in interface FeatureStore
Returns:
transaction object that allows to perform transactions operations on the datastore, never null
Throws:
FeatureStoreException - if the transactional access could not be acquired or is not implemented for this FeatureStore

destroy

public void destroy()
Description copied from interface: FeatureStore
Called by the container to indicate that this FeatureStore instance is being taken out of service.

Specified by:
destroy in interface FeatureStore

getEnvelope

public Envelope getEnvelope(QName ftName)
Description copied from interface: FeatureStore
Returns the envelope for all stored features of the given type.

Specified by:
getEnvelope in interface FeatureStore
Parameters:
ftName - name of the feature type, must not be null and must be served by this store
Returns:
the envelope (using the native CRS), or null if the feature type is not known

setEnvelope

void setEnvelope(FeatureType ft,
                 Envelope ftEnv)
Sets the envelope for the given feature type.

Parameters:
ft - feature type, must not be null
ftEnv - envelope, must not be null and use EPSG:4326

getLockManager

public LockManager getLockManager()
                           throws FeatureStoreException
Description copied from interface: FeatureStore
Returns the associated LockManager.

Specified by:
getLockManager in interface FeatureStore
Returns:
the associated LockManager instance, never null
Throws:
FeatureStoreException - if the FeatureStore does not implement locking

getObjectById

public GMLObject getObjectById(String id)
                        throws FeatureStoreException
Description copied from interface: FeatureStore
Retrieves the stored object with a certain id. TODO check if a common interface for returned objects should be used here (instead of Object)

Specified by:
getObjectById in interface FeatureStore
Parameters:
id - identifier of the object to be retrieved
Returns:
the stored object (either a Feature or a Geometry) or null if no object with the given id is known
Throws:
FeatureStoreException - if the query could not be performed

getSchema

public ApplicationSchema getSchema()
Description copied from interface: FeatureStore
Returns the application schema that this FeatureStore serves.

Specified by:
getSchema in interface FeatureStore
Returns:
the served application schema, never null

getStorageSRS

public CRS getStorageSRS()
Description copied from interface: FeatureStore
Returns the native CRS used for storing geometries.

Specified by:
getStorageSRS in interface FeatureStore
Returns:
the native CRS used for storing geometries, can be null

init

public void init()
          throws FeatureStoreException
Description copied from interface: FeatureStore
Called by the container to indicate that this FeatureStore instance is being placed into service.

Specified by:
init in interface FeatureStore
Throws:
FeatureStoreException - if the initialization fails

qualifyTableName

String qualifyTableName(String tableName)
Returns the given table name qualified with the db schema.

Parameters:
tableName - name of the table to be qualified
Returns:
dbSchema + "." + tableName, or tableName if dbSchema is null

isAvailable

public boolean isAvailable()
Description copied from interface: FeatureStore
Returns whether the store is currently able to perform operations.

Specified by:
isAvailable in interface FeatureStore
Returns:
true, if the store is functional, false otherwise

query

public FeatureResultSet query(Query query)
                       throws FeatureStoreException,
                              FilterEvaluationException
Description copied from interface: FeatureStore
Performs the given query and returns the matching features as a FeatureResultSet.

Specified by:
query in interface FeatureStore
Parameters:
query - query to be performed, must not be null
Returns:
matching features, never null
Throws:
FeatureStoreException - if the query could not be performed
FilterEvaluationException - if the filter contained in the query could not be evaluated

query

public FeatureResultSet query(Query[] queries)
                       throws FeatureStoreException,
                              FilterEvaluationException
Description copied from interface: FeatureStore
Performs the given queries and returns the matching features as a FeatureResultSet.

Specified by:
query in interface FeatureStore
Parameters:
queries - queries to be performed, must not be null and contain at least one entry
Returns:
matching features, never null
Throws:
FeatureStoreException - if the query could not be performed
FilterEvaluationException - if the filter contained in the query could not be evaluated

queryHits

public int queryHits(Query query)
              throws FeatureStoreException,
                     FilterEvaluationException
Description copied from interface: FeatureStore
Returns the number of features that are matched by the given query.

Specified by:
queryHits in interface FeatureStore
Parameters:
query - query to be performed, must not be null
Returns:
number of matching featuress
Throws:
FeatureStoreException - if the query could not be performed
FilterEvaluationException - if the filter contained in the query could not be evaluated

queryHits

public int queryHits(Query[] queries)
              throws FeatureStoreException,
                     FilterEvaluationException
Description copied from interface: FeatureStore
Returns the number of features that are matched by the given queries.

Specified by:
queryHits in interface FeatureStore
Parameters:
queries - queries to be performed, must not be null and contain at least one entry
Returns:
number of matching features
Throws:
FeatureStoreException - if the query could not be performed
FilterEvaluationException - if the filter contained in the query could not be evaluated

getCompatibleGeometry

Geometry getCompatibleGeometry(Geometry literal)
                         throws FilterEvaluationException
Returns a transformed version of the given Geometry in the storage CRS.

Parameters:
literal -
Returns:
transformed version of the geometry, never null
Throws:
FilterEvaluationException

getCompatibleGeometry

Geometry getCompatibleGeometry(Geometry literal,
                               CRS crs)
                         throws FilterEvaluationException
Returns a transformed version of the given Geometry in the specified CRS.

Parameters:
literal -
crs -
Returns:
transformed version of the geometry, never null
Throws:
FilterEvaluationException

releaseTransaction

void releaseTransaction(PostGISFeatureStoreTransaction ta)
                  throws FeatureStoreException
Returns the transaction to the datastore. This makes the transaction available to other clients again (via acquireTransaction().

The transaction should be terminated, i.e. commit() or rollback() must have been called before.

Parameters:
ta - the PostGISFeatureStoreTransaction to be returned
Throws:
FeatureStoreException

getFtId

short getFtId(QName ftName)

toPGPolygon

org.postgis.PGgeometry toPGPolygon(Envelope envelope,
                                   int srid)

deegree-core-3.0-pre-nightly (2010/03/05 00:01) - official

an open source project founded by lat/lon, Bonn, Germany.
For more information visit: http://www.deegree.org

]]>