deegree 2.5 (2011/06/29 09:44 build-8-official)

org.deegree.io.datastore.sql.postgis
Class PostGISDatastore

java.lang.Object
  extended by org.deegree.io.datastore.Datastore
      extended by org.deegree.io.datastore.sql.AbstractSQLDatastore
          extended by org.deegree.io.datastore.sql.postgis.PostGISDatastore

public class PostGISDatastore
extends AbstractSQLDatastore

Datastore implementation for PostGIS/PostgreSQL databases.

Version:
$Revision: 23694 $, $Date: 2010-04-20 14:47:40 +0200 (Di, 20 Apr 2010) $
Author:
Markus Schneider , Torsten Friebe , last edited by: $Author: mschneider $

Field Summary
 
Fields inherited from class org.deegree.io.datastore.sql.AbstractSQLDatastore
pool, SRS_UNDEFINED
 
Constructor Summary
PostGISDatastore()
           
 
Method Summary
protected  java.sql.Connection acquireConnection()
          Returns the database connection requested for.
 SQLFunctionCall buildSRSTransformCall(MappedGeometryPropertyType geoProperty, java.lang.String targetSRS)
          Returns an SQLFunctionCall that refers to the given MappingGeometryField in the specified target SRS using a database specific SQL function.
 java.lang.String buildSRSTransformCall(java.lang.String geomIdentifier, int nativeSRSCode)
          Builds an SQL fragment that converts the given geometry to the specified SRS.
protected  boolean canTransformTo(java.lang.String targetSRS)
          Returns whether the datastore is capable of performing a native coordinate transformation (using an SQL function call for example) into the given SRS.
 Geometry convertDBToDeegreeGeometry(java.lang.Object value, CoordinateSystem targetCS, java.sql.Connection conn)
          Converts a PostGIS specific geometry Object from the ResultSet to a deegree Geometry.
 org.postgis.PGgeometry convertDeegreeToDBGeometry(Geometry geometry, int targetSRS, java.sql.Connection conn)
          Converts a deegree Geometry to a PostGIS specific geometry object.
 int getNativeSRSCode(java.lang.String srsName)
          Returns the database specific code for the given SRS name.
 java.lang.Object getSequenceNextVal(java.sql.Connection conn, java.lang.String sequence)
          Returns the next value of the given SQL sequence.
 PostGISWhereBuilder getWhereBuilder(MappedFeatureType[] rootFts, java.lang.String[] aliases, Filter filter, SortProperty[] sortProperties, TableAliasGenerator aliasGenerator, VirtualContentProvider vcProvider)
          Returns a specific WhereBuilder implementation for PostGIS.
protected  Query transformQuery(Query query)
          Transforms the incoming Query so that the CoordinateSystem of all spatial arguments (BBOX, etc.)
 
Methods inherited from class org.deegree.io.datastore.sql.AbstractSQLDatastore
acquireTransaction, appendGeometryColumnGet, close, configure, convertFromDBType, createTransaction, determineFidsToLock, getAnnotationParser, getMaxValue, getSequenceCurrValPlusOffset, performQuery, performQuery, performQuery, prepareStatement, releaseConnection, releaseTransaction
 
Methods inherited from class org.deegree.io.datastore.Datastore
bindSchema, getConfiguration, getFeatureType, getSchemas, transformResult
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PostGISDatastore

public PostGISDatastore()
Method Detail

getWhereBuilder

public PostGISWhereBuilder getWhereBuilder(MappedFeatureType[] rootFts,
                                           java.lang.String[] aliases,
                                           Filter filter,
                                           SortProperty[] sortProperties,
                                           TableAliasGenerator aliasGenerator,
                                           VirtualContentProvider vcProvider)
                                    throws DatastoreException
Returns a specific WhereBuilder implementation for PostGIS.

Overrides:
getWhereBuilder in class AbstractSQLDatastore
Parameters:
rootFts - involved (requested) feature types
aliases - aliases for the feature types, may be null
filter - filter that restricts the matched features
sortProperties - sort criteria for the result, may be null or empty
aliasGenerator - used to generate unique table aliases
vcProvider -
Returns:
WhereBuilder implementation for PostGIS
Throws:
DatastoreException

convertDBToDeegreeGeometry

public Geometry convertDBToDeegreeGeometry(java.lang.Object value,
                                           CoordinateSystem targetCS,
                                           java.sql.Connection conn)
                                    throws java.sql.SQLException
Converts a PostGIS specific geometry Object from the ResultSet to a deegree Geometry.

Specified by:
convertDBToDeegreeGeometry in class AbstractSQLDatastore
Parameters:
value -
targetCS -
conn -
Returns:
corresponding deegree geometry
Throws:
java.sql.SQLException

convertDeegreeToDBGeometry

public org.postgis.PGgeometry convertDeegreeToDBGeometry(Geometry geometry,
                                                         int targetSRS,
                                                         java.sql.Connection conn)
                                                  throws DatastoreException
Converts a deegree Geometry to a PostGIS specific geometry object.

Specified by:
convertDeegreeToDBGeometry in class AbstractSQLDatastore
Parameters:
geometry -
targetSRS -
conn -
Returns:
corresponding PostGIS specific geometry object
Throws:
DatastoreException

acquireConnection

protected java.sql.Connection acquireConnection()
                                         throws DatastoreException
Description copied from class: AbstractSQLDatastore
Returns the database connection requested for.

Overrides:
acquireConnection in class AbstractSQLDatastore
Returns:
Connection
Throws:
DatastoreException

getSequenceNextVal

public java.lang.Object getSequenceNextVal(java.sql.Connection conn,
                                           java.lang.String sequence)
                                    throws DatastoreException
Returns the next value of the given SQL sequence.

Overrides:
getSequenceNextVal in class AbstractSQLDatastore
Parameters:
conn - JDBC connection to be used
sequence - name of the SQL sequence
Returns:
next value of the given SQL sequence
Throws:
DatastoreException - if the value could not be retrieved

transformQuery

protected Query transformQuery(Query query)
Transforms the incoming Query so that the CoordinateSystem of all spatial arguments (BBOX, etc.) in the Filter match the SRS of the targeted MappingGeometryFields.

NOTE: If this transformation can be performed by the backend (e.g. by Oracle Spatial), this method should be overwritten to return the original input Query.

Overrides:
transformQuery in class Datastore
Parameters:
query - query to be transformed
Returns:
query with spatial arguments transformed to target SRS

canTransformTo

protected boolean canTransformTo(java.lang.String targetSRS)
Returns whether the datastore is capable of performing a native coordinate transformation (using an SQL function call for example) into the given SRS.

Overrides:
canTransformTo in class Datastore
Parameters:
targetSRS - target spatial reference system (usually "EPSG:XYZ")
Returns:
true, if the datastore can perform the coordinate transformation, false otherwise

buildSRSTransformCall

public SQLFunctionCall buildSRSTransformCall(MappedGeometryPropertyType geoProperty,
                                             java.lang.String targetSRS)
                                      throws DatastoreException
Returns an SQLFunctionCall that refers to the given MappingGeometryField in the specified target SRS using a database specific SQL function.

Overrides:
buildSRSTransformCall in class AbstractSQLDatastore
Parameters:
geoProperty - geometry property
targetSRS - target spatial reference system (usually "EPSG:XYZ")
Returns:
an SQLFunctionCall that refers to the geometry in the specified srs
Throws:
DatastoreException

buildSRSTransformCall

public java.lang.String buildSRSTransformCall(java.lang.String geomIdentifier,
                                              int nativeSRSCode)
                                       throws DatastoreException
Description copied from class: AbstractSQLDatastore
Builds an SQL fragment that converts the given geometry to the specified SRS.

Overrides:
buildSRSTransformCall in class AbstractSQLDatastore
Returns:
an SQL fragment that converts the given geometry to the specified SRS
Throws:
DatastoreException

getNativeSRSCode

public int getNativeSRSCode(java.lang.String srsName)
Description copied from class: AbstractSQLDatastore
Returns the database specific code for the given SRS name.

Overrides:
getNativeSRSCode in class AbstractSQLDatastore
Parameters:
srsName - spatial reference system name (usually "EPSG:XYZ")
Returns:
the database specific SRS code, or -1 if no corresponding native code is known

deegree 2.5 (2011/06/29 09:44 build-8-official)

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