|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ObjectJDBC1DataStore
JDBC2DataStore
JDBCDataStore
PostgisDataStore
public class PostgisDataStore
Postgis DataStore implementation.
This datastore by default will read/write geometries in WKT format.
Optionally use of WKB can be turned on, in which case you may want to turn
on also the use of the bytea function, that fasten the data trasfer, but
that it's available only from version 0.7.2 onwards.
Field Summary | |
---|---|
protected boolean |
byteaEnabled
If true, the bytea function will be used to optimize even further data loading when using WKB format |
protected boolean |
byteaWKB
postgis 1.0 changed the way WKB is handled, this needs to be set if version >1. |
protected PostgisDBInfo |
dbInfo
PostGIS version information (persisted here so we don't have to keep asking the database what version it is, in perpituity. |
protected boolean |
estimatedExtent
set to true if the bounds for a table should be computed using the estimated_extent' function, but beware that this function is less accurate and in some cases *far* less accurate if the data within the actual bounds does not follow a uniform distribution. |
protected static GeometryFactory |
geometryFactory
Factory for producing geometries (from JTS). |
protected static WKTReader |
geometryReader
Well Known Text reader (from JTS). |
protected static Logger |
LOGGER
The logger for the postgis module. |
protected boolean |
looseBbox
If true then the bounding box filters will use the && postgis operator, which uses the spatial index and performs against the envelope of the geom, leading to greater speed and slightly less accuracy. |
int |
OPTIMIZE_MODE
Deprecated. Dot not use this directly, use getOptimizeMode() . |
static int |
OPTIMIZE_SAFE
OPTIMIZE_MODE constants |
static int |
OPTIMIZE_SQL
|
protected boolean |
schemaEnabled
Flag indicating whether schema support |
protected boolean |
useGeos
Enables the use of geos operators |
protected boolean |
WKBEnabled
If true, WKB format is used instead of WKT |
Fields inherited from class JDBC2DataStore |
---|
dataSource |
Fields inherited from class JDBC1DataStore |
---|
allowWriteOnVolatileFIDs, config, listenerManager, sqlNameEscape, transactionIsolation, TYPE_MAPPINGS, typeHandler |
Constructor Summary | |
---|---|
protected |
PostgisDataStore(DataSource dataSource)
|
|
PostgisDataStore(DataSource dataSource,
JDBCDataStoreConfig config,
int optimizeMode)
|
protected |
PostgisDataStore(DataSource dataSource,
String namespace)
|
protected |
PostgisDataStore(DataSource dataSource,
String schema,
String namespace)
|
protected |
PostgisDataStore(DataSource dataSource,
String schema,
String namespace,
int optimizeMode)
|
Method Summary | |
---|---|
protected boolean |
allowTable(String tablename)
Provides a hook for sub classes to filter out specific tables in the data store that are not to be used as geospatial tables. |
protected String[] |
attributeNames(SimpleFeatureType featureType,
Filter filter)
Gets the list of attribute names required for both featureType and filter |
protected AttributeDescriptor |
buildAttributeType(ResultSet metadataRs)
Constructs an AttributeDescriptor from a row in a ResultSet. |
protected FIDMapper |
buildFIDMapper(String typeName,
FIDMapperFactory factory)
Builds the appropriate FID mapper given a table name and a FID mapper factory |
protected FIDMapperFactory |
buildFIDMapperFactory(JDBCDataStoreConfig config)
|
protected SimpleFeatureType |
buildSchema(String typeName,
FIDMapper mapper)
Override this method to perform a few permission checks before the super class has a chance to do its thing. |
PostgisFeatureLocking |
createFeatureLockingInternal(PostgisDataStore ds,
SimpleFeatureType type)
|
protected JDBCFeatureWriter |
createFeatureWriter(FeatureReader<SimpleFeatureType,SimpleFeature> fReader,
QueryData queryData)
DOCUMENT ME! |
protected LockingManager |
createLockingManager()
Allows subclass to create LockingManager to support their needs. |
void |
createSchema(SimpleFeatureType featureType)
Creates a FeatureType in this instance of the PostgisDataStore. |
protected PostgisSQLBuilder |
createSQLBuilder()
Creates a new sql builder for encoding raw sql statements; |
protected int |
determineSRID(String tableName,
String geometryColumnName)
DOCUMENT ME! |
protected int |
getConcurrency(boolean forWrite)
|
DataSource |
getDataSource()
Obtains the postgis datastore connection pool. |
PostgisDBInfo |
getDBInfo()
Obtains database specific information, such as version, supported functions, etc. |
Envelope |
getEnvelope(String typeName)
Retrieve approx bounds of all Features. |
FeatureReader<SimpleFeatureType,SimpleFeature> |
getFeatureReader(SimpleFeatureType requestType,
Filter filter,
Transaction transaction)
This is a public entry point to the DataStore. |
FeatureSource<SimpleFeatureType,SimpleFeature> |
getFeatureSource(String typeName)
Default implementation based on getFeatureReader and getFeatureWriter. |
FeatureWriter<SimpleFeatureType,SimpleFeature> |
getFeatureWriter(String typeName,
Transaction transaction)
Retrieve a FeatureWriter over entire dataset. |
FeatureWriter<SimpleFeatureType,SimpleFeature> |
getFeatureWriterAppend(String typeName,
Transaction transaction)
Retrieve a FeatureWriter for creating new content. |
protected AttributeIO |
getGeometryAttributeIO(AttributeDescriptor type,
QueryData queryData)
Hook to create the geometry attribute IO for a vendor specific data source. |
Integer |
getJdbcType(Class attributeTypeBinding)
Returns the JDBC type constant (as in Types ) that maps to the given
Java class binding when constructing attribute types, or null if no such mapping exist. |
int |
getOptimizeMode()
|
protected int |
getResultSetType(boolean forWrite)
|
SimpleFeatureType |
getSchema(String arg0)
Retrieve FeatureType metadata by typeName . |
SQLBuilder |
getSqlBuilder(String typeName)
DOCUMENT ME! |
Set |
getSupportedHints()
|
String[] |
getTypeNames()
Retrieves a list of of the available FeatureTypes. |
protected void |
guessDataStoreOptions()
Attempts to figure out some optimization options, based on some postgis metadata. |
protected void |
initBuilder(PostgisSQLBuilder builder)
|
boolean |
isByteaEnabled()
Returns true if the data store is using the bytea function to fasten WKB data transfer, false otherwise |
boolean |
isByteaWKB()
|
boolean |
isEstimatedExtent()
|
boolean |
isLooseBbox()
Whether the bounding boxes issued against this postgis datastore are on the envelope of the geometry or the actual geometry. |
boolean |
isWKBEnabled()
Returns true if the WKB format is used to transfer geometries, false otherwise |
protected static String |
schema(String schema)
Simple helper method to ensure that a schema is always set. |
void |
setByteaEnabled(boolean byteaEnabled)
Enables the use of bytea function for WKB data transfer (will improve performance). |
void |
setByteaWKB(boolean byteaWKB)
|
void |
setEstimatedExtent(boolean estimatedExtent)
Enables the use of the 'estimated_extent' function for bounds computation. |
void |
setLooseBbox(boolean isLooseBbox)
Sets this postgis instance to use a less strict but faster bounding box query. |
void |
setOptimizeMode(int mode)
Sets the optimization mode for the datastore. |
void |
setWKBEnabled(boolean enabled)
If turned on, WKB will be used to transfer geometry data instead of WKT |
void |
updateSchema(String typeName,
SimpleFeatureType featureType)
Used to provide support for changing the DataStore Schema. |
Methods inherited from class JDBC2DataStore |
---|
createConnection, dispose, finalize |
Methods inherited from class Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface DataStore |
---|
getFeatureReader, getFeatureWriter, getLockingManager, getView |
Methods inherited from interface DataAccess |
---|
dispose, getFeatureSource, getInfo, getNames, getSchema, updateSchema |
Field Detail |
---|
protected static final Logger LOGGER
protected static GeometryFactory geometryFactory
protected static WKTReader geometryReader
public static final int OPTIMIZE_SAFE
public static final int OPTIMIZE_SQL
protected PostgisDBInfo dbInfo
protected boolean useGeos
public int OPTIMIZE_MODE
getOptimizeMode()
.
protected boolean WKBEnabled
protected boolean byteaEnabled
protected boolean byteaWKB
protected boolean looseBbox
protected boolean estimatedExtent
protected boolean schemaEnabled
Constructor Detail |
---|
protected PostgisDataStore(DataSource dataSource) throws IOException
IOException
protected PostgisDataStore(DataSource dataSource, String namespace) throws IOException
IOException
protected PostgisDataStore(DataSource dataSource, String schema, String namespace) throws IOException
IOException
protected PostgisDataStore(DataSource dataSource, String schema, String namespace, int optimizeMode) throws IOException
IOException
public PostgisDataStore(DataSource dataSource, JDBCDataStoreConfig config, int optimizeMode) throws IOException
IOException
Method Detail |
---|
protected static String schema(String schema)
protected LockingManager createLockingManager()
createLockingManager
in class JDBC1DataStore
protected PostgisSQLBuilder createSQLBuilder()
protected void guessDataStoreOptions() throws IOException
IOException
public String[] getTypeNames() throws IOException
DataStore
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.
getTypeNames
in interface DataStore
getTypeNames
in class JDBC1DataStore
IOException
org.geotools.data.DataStore#getFeatureTypes()
public Envelope getEnvelope(String typeName)
This result is suitable for a quick map display, illustrating the data. This value is often stored as metadata in databases such as oraclespatial.
getEnvelope
in class JDBC1DataStore
protected boolean allowTable(String tablename)
JDBC1DataStore
allowTable
in class JDBC1DataStore
tablename
- A table name to check.
protected SimpleFeatureType buildSchema(String typeName, FIDMapper mapper) throws IOException
buildSchema
in class JDBC1DataStore
typeName
- The name of the table to construct a feature type for.mapper
- The name of the column holding the fid.
IOException
DataSourceException
- This can occur if there is an SQL error or an error
constructing the FeatureType.JDBC1DataStore.buildAttributeType(ResultSet)
public FeatureReader<SimpleFeatureType,SimpleFeature> getFeatureReader(SimpleFeatureType requestType, Filter filter, Transaction transaction) throws IOException
We have given some though to changing this api to be based on query.
Currently this is the only way to retype your features to different name spaces.
(non-Javadoc)
getFeatureReader
in class JDBC1DataStore
IOException
org.geotools.data.DataStore#getFeatureReader(org.geotools.feature.FeatureType,
org.geotools.filter.Filter, org.geotools.data.Transaction)
protected String[] attributeNames(SimpleFeatureType featureType, Filter filter) throws IOException
attributeNames
in class JDBC1DataStore
featureType
- The FeatureType to get attribute names for.filter
- The filter which needs attributes to filter.
IOException
- If we can't get the schema.public SQLBuilder getSqlBuilder(String typeName) throws IOException
getSqlBuilder
in class JDBC1DataStore
typeName
-
IOException
- DOCUMENT ME!protected void initBuilder(PostgisSQLBuilder builder)
protected int determineSRID(String tableName, String geometryColumnName) throws IOException
determineSRID
in class JDBC1DataStore
tableName
- geometryColumnName
-
IOException
- DOCUMENT ME!
DataSourceException
- DOCUMENT ME!protected AttributeDescriptor buildAttributeType(ResultSet metadataRs) throws IOException
This implementation construct an AttributeDescriptor using the default JDBC type mappings defined in JDBCDataStore. These type mappings only handle native Java classes and SQL standard column types. If a geometry type is found then getGeometryAttribute is called.
Note: Overriding methods must never move the current row pointer in the result set.
buildAttributeType
in class JDBC1DataStore
metadataRs
- The ResultSet containing the result of a
DatabaseMetaData.getColumns call.
IOException
- If an error occurs processing the ResultSet.protected FIDMapperFactory buildFIDMapperFactory(JDBCDataStoreConfig config)
buildFIDMapperFactory
in class JDBC1DataStore
JDBC1DataStore.buildFIDMapperFactory(org.geotools.data.jdbc.JDBCDataStoreConfig)
protected FIDMapper buildFIDMapper(String typeName, FIDMapperFactory factory) throws IOException
JDBC1DataStore
buildFIDMapper
in class JDBC1DataStore
IOException
public void createSchema(SimpleFeatureType featureType) throws IOException
createSchema
in interface DataAccess<SimpleFeatureType,SimpleFeature>
createSchema
in class JDBC1DataStore
featureType
- FetureType to add to DataStore
IOException
- if something goes horribly wrong or the table already existsorg.geotools.data.DataStore#createSchema(org.geotools.feature.FeatureType)
public void updateSchema(String typeName, SimpleFeatureType featureType) throws IOException
JDBC1DataStore
Specifically this is intended to address updating the metadata Coordinate System information.
If we can figure out the Catalog API for metadata we will not have to use such a heavy handed approach.
Subclasses are free to implement various levels of support:
updateSchema
in interface DataStore
updateSchema
in class JDBC1DataStore
IOException
org.geotools.data.DataStore#updateSchema(java.lang.String,
org.geotools.feature.FeatureType)
public FeatureSource<SimpleFeatureType,SimpleFeature> getFeatureSource(String typeName) throws IOException
We should be able to optimize this to only get the RowSet once
getFeatureSource
in interface DataStore
getFeatureSource
in class JDBC1DataStore
IOException
DataStore.getFeatureSource(java.lang.String)
public PostgisFeatureLocking createFeatureLockingInternal(PostgisDataStore ds, SimpleFeatureType type) throws IOException
IOException
protected JDBCFeatureWriter createFeatureWriter(FeatureReader<SimpleFeatureType,SimpleFeature> fReader, QueryData queryData) throws IOException
createFeatureWriter
in class JDBC1DataStore
fReader
- queryData
-
IOException
- DOCUMENT ME!public FeatureWriter<SimpleFeatureType,SimpleFeature> getFeatureWriter(String typeName, Transaction transaction) throws IOException
Quick notes: This FeatureWriter is often used to add new content, or perform summary calculations over the entire dataset.
Subclass may wish to implement an optimized featureWriter for these operations.
It should provide Feature for next() even when hasNext() is
false
.
Subclasses are responsible for checking with the lockingManger unless they are providing their own locking support.
getFeatureWriter
in interface DataStore
getFeatureWriter
in class JDBC1DataStore
typeName
- transaction
-
IOException
org.geotools.data.DataStore#getFeatureWriter(java.lang.String,
boolean, org.geotools.data.Transaction)
public FeatureWriter<SimpleFeatureType,SimpleFeature> getFeatureWriterAppend(String typeName, Transaction transaction) throws IOException
Subclass may wish to implement an optimized featureWriter for this operation. One based on prepared statements is a possibility, as we do not require a ResultSet.
To allow new content the FeatureWriter should provide Feature for next()
even when hasNext() is false
.
Subclasses are responsible for checking with the lockingManger unless they are providing their own locking support.
getFeatureWriterAppend
in interface DataStore
getFeatureWriterAppend
in class JDBC1DataStore
typeName
- transaction
-
IOException
org.geotools.data.DataStore#getFeatureWriter(java.lang.String,
boolean, org.geotools.data.Transaction)
protected AttributeIO getGeometryAttributeIO(AttributeDescriptor type, QueryData queryData)
JDBC1DataStore
getGeometryAttributeIO
in class JDBC1DataStore
type
- The AttributeDescriptor to read.queryData
- The connection holder
org.geotools.data.jdbc.JDBCDataStore#getGeometryAttributeIO(org.geotools.feature.AttributeDescriptor)
protected int getResultSetType(boolean forWrite)
getResultSetType
in class JDBC1DataStore
protected int getConcurrency(boolean forWrite)
getConcurrency
in class JDBC1DataStore
public boolean isWKBEnabled()
public void setWKBEnabled(boolean enabled)
enabled
- public void setLooseBbox(boolean isLooseBbox)
isLooseBbox
- true if this should have a loose Bbox.public boolean isLooseBbox()
public boolean isByteaEnabled()
public void setByteaWKB(boolean byteaWKB)
public boolean isByteaWKB()
public void setByteaEnabled(boolean byteaEnabled)
byteaEnabled
- public void setEstimatedExtent(boolean estimatedExtent)
Beware that this function is an approximation and is dependent on the degree to with the data in the actual bounds follows a uniform distribution.
public boolean isEstimatedExtent()
#setEstimatedExtent(boolean)}.
public void setOptimizeMode(int mode)
mode
- One of OPTIMIZE_SAFE
,OPTIMIZE_SQL
.public int getOptimizeMode()
public SimpleFeatureType getSchema(String arg0) throws IOException
DataStore
typeName
.
Retrieves the Schema information as a FeatureType object.
getSchema
in interface DataStore
getSchema
in class JDBC1DataStore
arg0
- typeName of requested FeatureType
IOException
- If typeName cannot be foundDataStore.getSchema(java.lang.String)
public DataSource getDataSource()
public PostgisDBInfo getDBInfo()
public Integer getJdbcType(Class attributeTypeBinding)
Types
) that maps to the given
Java class binding when constructing attribute types, or null if no such mapping exist.
attributeTypeBinding
-
public Set getSupportedHints()
getSupportedHints
in class JDBC1DataStore
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |