org.geotools.data.postgis
Class PostgisFeatureStore

Object
  extended by JDBCFeatureSource
      extended by JDBCFeatureStore
          extended by PostgisFeatureStore
All Implemented Interfaces:
FeatureSource<SimpleFeatureType,SimpleFeature>, FeatureStore<SimpleFeatureType,SimpleFeature>
Direct Known Subclasses:
PostgisFeatureLocking

public class PostgisFeatureStore
extends JDBCFeatureStore

Implementation of a Postgis specific FeatureStore.

This mostly just rips off code from PostgisDataSource It could definitely use some nice code reuse with PostgisDataStore, as they have a number of similar if not identical methods right now.

Approaching deadlines, however, mean that we're sticking with the code that works, instead of getting all kinds of nice reuse. This'll hopefully change. This bypasses the writers used in JDBCFeatureStore, as I'm just not yet confident in them. We also should do some solid tests to see which is actually faster.

Author:
Chris Holmes, TOPP
Module:
modules/plugin/postgis (gt-postgis.jar)
TODO:
HACK: too little code reuse with PostgisDataStore., TODO: make individual operations truly atomic. If the transaction is an auto-commit one, then it should make a a new jdbc transaction that rollsback if there are errors while performing its action.

Nested Class Summary
 
Nested classes/interfaces inherited from class JDBCFeatureSource
JDBCFeatureSource.JDBCQueryCapabilities
 
Field Summary
protected static String CONN_ERROR
          Error message prefix for sql connection errors
protected  FIDMapper fidMapper
          the name of the column to use for the featureId
protected static GeometryFactory geometryFactory
          Factory for producing geometries (from JTS).
protected static WKTReader geometryReader
          Well Known Text reader (from JTS).
protected static WKTWriter geometryWriter
          Well Known Text writer (from JTS).
protected  PostgisSQLBuilder sqlBuilder
          To create the sql where statement
protected  String tableName
           
 
Fields inherited from class JDBCFeatureStore
transaction
 
Fields inherited from class JDBCFeatureSource
queryCapabilities
 
Constructor Summary
PostgisFeatureStore(PostgisDataStore postgisDataStore, SimpleFeatureType featureType)
           
 
Method Summary
protected  ReferencedEnvelope bounds(Query query)
           
 ReferencedEnvelope getBounds()
          Retrieve Bounds of all Features.
 ReferencedEnvelope getBounds(Query query)
          Retrieve Bounds of Query results.
protected  ReferencedEnvelope getEnvelope(Connection conn, String geomName, SQLBuilder sqlBuilder, Filter filter)
           
protected  PostgisDataStore getPostgisDataStore()
          Performs the setFeautres operation by removing all and then adding the full collection.
protected  int getSRID(String geomName)
           
 String makeSql(SQLUnpacker unpacker, Query query)
          Deprecated. please use makeSql(query)
 void modifyFeatures(AttributeDescriptor[] type, Object[] value, Filter filter)
          Modifies the passed attribute types with the passed objects in all features that correspond to the passed OGS filter.
 void modifyFeatures(AttributeDescriptor type, Object value, Filter filter)
          Modifies the passed attribute types with the passed objects in all features that correspond to the passed OGS filter.
 void removeFeatures(Filter filter)
          Removes the features specified by the passed filter from the PostGIS database.
 
Methods inherited from class JDBCFeatureStore
addFeatures, addFeatures, assertFids, assertFilter, fids, getInProcessLockingManager, getTransaction, modifyFeatures, setFeatures, setTransaction
 
Methods inherited from class JDBCFeatureSource
addFeatureListener, close, close, close, count, getConnection, getCount, getDataStore, getFeatures, getFeatures, getFeatures, getInfo, getJDBCDataStore, getName, getQueryCapabilities, getSchema, getSupportedHints, removeFeatureListener
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface FeatureSource
addFeatureListener, getCount, getDataStore, getFeatures, getFeatures, getFeatures, getInfo, getName, getQueryCapabilities, getSchema, getSupportedHints, removeFeatureListener
 

Field Detail

geometryWriter

protected static WKTWriter geometryWriter
Well Known Text writer (from JTS).


geometryFactory

protected static GeometryFactory geometryFactory
Factory for producing geometries (from JTS).


geometryReader

protected static WKTReader geometryReader
Well Known Text reader (from JTS).


CONN_ERROR

protected static final String CONN_ERROR
Error message prefix for sql connection errors

See Also:
Constant Field Values

sqlBuilder

protected PostgisSQLBuilder sqlBuilder
To create the sql where statement


tableName

protected String tableName

fidMapper

protected FIDMapper fidMapper
the name of the column to use for the featureId

Constructor Detail

PostgisFeatureStore

public PostgisFeatureStore(PostgisDataStore postgisDataStore,
                           SimpleFeatureType featureType)
                    throws IOException
Throws:
IOException
Method Detail

getSRID

protected int getSRID(String geomName)
               throws IOException
Throws:
IOException

removeFeatures

public void removeFeatures(Filter filter)
                    throws IOException
Removes the features specified by the passed filter from the PostGIS database.

Specified by:
removeFeatures in interface FeatureStore<SimpleFeatureType,SimpleFeature>
Overrides:
removeFeatures in class JDBCFeatureStore
Parameters:
filter - An OpenGIS filter; specifies which features to remove.
Throws:
IOException - If anything goes wrong or if deleting is not supported.
DataSourceException - DOCUMENT ME!

modifyFeatures

public void modifyFeatures(AttributeDescriptor[] type,
                           Object[] value,
                           Filter filter)
                    throws IOException
Modifies the passed attribute types with the passed objects in all features that correspond to the passed OGS filter.

Specified by:
modifyFeatures in interface FeatureStore<SimpleFeatureType,SimpleFeature>
Overrides:
modifyFeatures in class JDBCFeatureStore
Parameters:
type - The attributes to modify.
value - The values to put in the attribute types.
filter - An OGC filter to note which attributes to modify.
Throws:
IOException - If modificaton is not supported, if the attribute and object arrays are not eqaul length, or if the object types do not match the attribute types.
DataSourceException - DOCUMENT ME!
TODO:
REVISIT: validate values with types. Database does this a bit now, but should be more fully implemented., REVISIT: do some nice prepared statement stuff like oracle.

modifyFeatures

public void modifyFeatures(AttributeDescriptor type,
                           Object value,
                           Filter filter)
                    throws IOException
Modifies the passed attribute types with the passed objects in all features that correspond to the passed OGS filter. A convenience method for single attribute modifications.

Specified by:
modifyFeatures in interface FeatureStore<SimpleFeatureType,SimpleFeature>
Overrides:
modifyFeatures in class JDBCFeatureStore
Parameters:
type - The attributes to modify.
value - The values to put in the attribute types.
filter - An OGC filter to note which attributes to modify.
Throws:
IOException - If modificaton is not supported, if the object type do not match the attribute type.

getPostgisDataStore

protected PostgisDataStore getPostgisDataStore()
Performs the setFeautres operation by removing all and then adding the full collection. This is not efficient, the add, modify and remove operations should be used instead, this is just to follow the interface.

Returns:
DOCUMENT ME!
TODO:
REVISIT: to abstract class, same as oracle.

makeSql

public String makeSql(SQLUnpacker unpacker,
                      Query query)
               throws IOException
Deprecated. please use makeSql(query)

Creates a SQL statement for the PostGIS database.

Parameters:
unpacker - the object to get the encodable filter.
query - the getFeature query - for the tableName, properties and maxFeatures.
Throws:
IOException - if there are problems encoding the sql.

getBounds

public ReferencedEnvelope getBounds()
                             throws IOException
Description copied from class: JDBCFeatureSource
Retrieve Bounds of all Features.

Currently returns null, consider getFeatures().getBounds() instead.

Subclasses may override this method to perform the appropriate optimization for this result.

Specified by:
getBounds in interface FeatureSource<SimpleFeatureType,SimpleFeature>
Overrides:
getBounds in class JDBCFeatureSource
Returns:
null representing the lack of an optimization
Throws:
IOException - DOCUMENT ME!

getBounds

public ReferencedEnvelope getBounds(Query query)
                             throws IOException
Retrieve Bounds of Query results.

Currently returns null, consider getFeatures( query ).getBounds() instead.

Subclasses may override this method to perform the appropriate optimization for this result.

Specified by:
getBounds in interface FeatureSource<SimpleFeatureType,SimpleFeature>
Overrides:
getBounds in class JDBCFeatureSource
Parameters:
query - Query we are requesting the bounds of
Returns:
null representing the lack of an optimization
Throws:
IOException - DOCUMENT ME!

bounds

protected ReferencedEnvelope bounds(Query query)
                             throws IOException
Throws:
IOException

getEnvelope

protected ReferencedEnvelope getEnvelope(Connection conn,
                                         String geomName,
                                         SQLBuilder sqlBuilder,
                                         Filter filter)
                                  throws SQLException,
                                         SQLEncoderException,
                                         IOException,
                                         ParseException
Throws:
SQLException
SQLEncoderException
IOException
ParseException


Copyright © 1996-2010 Geotools. All Rights Reserved.