deegree 2.3 (2010/04/09 10:10 build-4-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: 18195 $, $Date: 2009-06-18 17:55:39 +0200 (Do, 18. Jun 2009) $
Author:
Markus Schneider , Torsten Friebe , last edited by: $Author: mschneider $

Field Summary
 
Fields inherited from class org.deegree.io.datastore.sql.AbstractSQLDatastore
pool
 
Constructor Summary
PostGISDatastore()
           
 
Method Summary
protected  Connection acquireConnection()
          Returns the database connection requested for.
 SQLFunctionCall buildSRSTransformCall(MappedGeometryPropertyType geoProperty, String targetSRS)
          Returns an SQLFunctionCall that refers to the given MappingGeometryField in the specified target SRS using a database specific SQL function.
 String buildSRSTransformCall(String geomIdentifier, int nativeSRSCode)
          Builds an SQL fragment that converts the given geometry to the specified SRS.
protected  boolean canTransformTo(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(Object value, CoordinateSystem targetCS, Connection conn)
          Converts a PostGIS specific geometry Object from the ResultSet to a deegree Geometry.
 org.postgis.PGgeometry convertDeegreeToDBGeometry(Geometry geometry, int targetSRS, Connection conn)
          Converts a deegree Geometry to a PostGIS specific geometry object.
 int getNativeSRSCode(String srsName)
          Returns the database specific code for the given SRS name.
 Object getSequenceNextVal(Connection conn, String sequence)
          Returns the next value of the given SQL sequence.
 PostGISWhereBuilder getWhereBuilder(MappedFeatureType[] rootFts, 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.)
protected  FeatureCollection transformResult(FeatureCollection fc, String targetSRS)
          Transforms the FeatureCollection so that the geometries of all contained geometry properties use the requested SRS.
 
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
 
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,
                                           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(Object value,
                                           CoordinateSystem targetCS,
                                           Connection conn)
                                    throws 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:
SQLException

convertDeegreeToDBGeometry

public org.postgis.PGgeometry convertDeegreeToDBGeometry(Geometry geometry,
                                                         int targetSRS,
                                                         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 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 Object getSequenceNextVal(Connection conn,
                                 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

transformResult

protected FeatureCollection transformResult(FeatureCollection fc,
                                            String targetSRS)
Transforms the FeatureCollection so that the geometries of all contained geometry properties use the requested SRS.

Overrides:
transformResult in class Datastore
Parameters:
fc - feature collection to be transformed
targetSRS - requested SRS
Returns:
transformed FeatureCollection

canTransformTo

protected boolean canTransformTo(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,
                                             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 String buildSRSTransformCall(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(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.3 (2010/04/09 10:10 build-4-official)

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