public class SFSUtilities extends Object
| Constructor and Description |
|---|
SFSUtilities() |
| Modifier and Type | Method and Description |
|---|---|
static void |
addTableSRIDConstraint(Connection connection,
TableLocation tableLocation,
int srid)
Alter a table to add a SRID constraint.
|
static String[] |
getAuthorityAndSRID(Connection connection,
TableLocation table,
String fieldName)
Return an array of two string that correspond to the authority name
and its SRID code.
|
static int |
getFirstGeometryFieldIndex(ResultSet resultSet)
Find the first geometry field name of a resultSet.
|
static List<String> |
getGeometryFields(Connection connection,
String catalog,
String schema,
String table)
Find geometry fields name of a table.
|
static List<String> |
getGeometryFields(Connection connection,
TableLocation location)
Find geometry fields name of a table.
|
static List<String> |
getGeometryFields(ResultSet resultSet)
Find geometry fields name of a resultSet.
|
static int |
getGeometryType(Connection connection,
TableLocation location,
String fieldName) |
static int |
getGeometryTypeFromGeometry(com.vividsolutions.jts.geom.Geometry geometry) |
static String |
getGeometryTypeNameFromCode(int geometryTypeCode) |
static com.vividsolutions.jts.geom.Envelope |
getResultSetEnvelope(ResultSet resultSet)
Compute the full extend of a resultset using the first geometry field.
|
static com.vividsolutions.jts.geom.Envelope |
getResultSetEnvelope(ResultSet resultSet,
String fieldName)
Compute the full extend of a resultset using a specified geometry field.
|
static int |
getSRID(Connection connection,
TableLocation table)
Return the srid of the first geometry column of the input table
|
static int |
getSRID(Connection connection,
TableLocation table,
String fieldName)
Return the srid of a table for a given field name.
|
static com.vividsolutions.jts.geom.Envelope |
getTableEnvelope(Connection connection,
TableLocation location,
String geometryField)
Merge the bounding box of all geometries inside the provided table.
|
static boolean |
hasGeometryField(ResultSet resultSet)
Check if the resultset contains a geometry field
|
static PreparedStatement |
prepareInformationSchemaStatement(Connection connection,
String catalog,
String schema,
String table,
String informationSchemaTable,
String endQuery)
For table containing catalog, schema and table name, this function create a prepared statement with a filter on
this combination.
|
static PreparedStatement |
prepareInformationSchemaStatement(Connection connection,
String catalog,
String schema,
String table,
String informationSchemaTable,
String endQuery,
String catalog_field,
String schema_field,
String table_field)
For table containing catalog, schema and table name, this function create a prepared statement with a filter
on this combination.
|
static Connection |
wrapConnection(Connection connection)
Use this only if DataSource is not available.
|
static DataSource |
wrapSpatialDataSource(DataSource dataSource)
In order to be able to use
Wrapper.unwrap(Class) and
Wrapper.unwrap(Class) to get SpatialResultSet and
SpatialResultSetMetaData this method wrap the provided dataSource. |
public static String getGeometryTypeNameFromCode(int geometryTypeCode)
public static int getGeometryTypeFromGeometry(com.vividsolutions.jts.geom.Geometry geometry)
geometry - Geometry instancepublic static int getGeometryType(Connection connection, TableLocation location, String fieldName) throws SQLException
connection - Active connectionlocation - Catalog, schema and table namefieldName - Geometry field name or empty (take the first one)SQLExceptionGeometryTypeCodespublic static DataSource wrapSpatialDataSource(DataSource dataSource)
Wrapper.unwrap(Class) and
Wrapper.unwrap(Class) to get SpatialResultSet and
SpatialResultSetMetaData this method wrap the provided dataSource.dataSource - H2 or PostGIS DataSourcepublic static Connection wrapConnection(Connection connection)
Wrapper.unwrap(Class) and
Wrapper.unwrap(Class) to get SpatialResultSet and
SpatialResultSetMetaData this method wrap the provided connection.connection - H2 or PostGIS Connectionpublic static com.vividsolutions.jts.geom.Envelope getTableEnvelope(Connection connection, TableLocation location, String geometryField) throws SQLException
connection - Active connection (not closed by this function)location - Location of the tablegeometryField - Geometry field or empty string (take the first geometry field)SQLException - If the table not exists, empty or does not contain a geometry field.public static List<String> getGeometryFields(Connection connection, TableLocation location) throws SQLException
connection - Active connectionlocation - Table locationSQLExceptionpublic static PreparedStatement prepareInformationSchemaStatement(Connection connection, String catalog, String schema, String table, String informationSchemaTable, String endQuery, String catalog_field, String schema_field, String table_field) throws SQLException
connection - Active connectioncatalog - Table catalog, may be emptyschema - Table schema, may be emptytable - Table nameinformationSchemaTable - Information table locationendQuery - Additional where statementcatalog_field - Catalog field nameschema_field - Schema field nametable_field - Table field nameSQLExceptionpublic static PreparedStatement prepareInformationSchemaStatement(Connection connection, String catalog, String schema, String table, String informationSchemaTable, String endQuery) throws SQLException
connection - Active connectioncatalog - Table catalog, may be emptyschema - Table schema, may be emptytable - Table nameinformationSchemaTable - Information table locationendQuery - Additional where statementSQLExceptionpublic static List<String> getGeometryFields(Connection connection, String catalog, String schema, String table) throws SQLException
connection - Active connectioncatalog - Catalog that contain schema (empty for default catalog)schema - Schema that contain table (empty for default schema)table - Table name (case insensitive)SQLExceptionpublic static List<String> getGeometryFields(ResultSet resultSet) throws SQLException
resultSet - SQLExceptionpublic static int getFirstGeometryFieldIndex(ResultSet resultSet) throws SQLException
resultSet - SQLExceptionpublic static boolean hasGeometryField(ResultSet resultSet) throws SQLException
resultSet - SQLExceptionpublic static com.vividsolutions.jts.geom.Envelope getResultSetEnvelope(ResultSet resultSet) throws SQLException
resultSet - SQLExceptionpublic static com.vividsolutions.jts.geom.Envelope getResultSetEnvelope(ResultSet resultSet, String fieldName) throws SQLException
resultSet - fieldName - SQLExceptionpublic static int getSRID(Connection connection, TableLocation table) throws SQLException
connection - table - SQLExceptionpublic static int getSRID(Connection connection, TableLocation table, String fieldName) throws SQLException
connection - table - fieldName - SQLExceptionpublic static String[] getAuthorityAndSRID(Connection connection, TableLocation table, String fieldName) throws SQLException
connection - table - fieldName - SQLExceptionpublic static void addTableSRIDConstraint(Connection connection, TableLocation tableLocation, int srid) throws SQLException
connection - tableLocation - srid - SQLExceptionCopyright © 2016 CNRS. All rights reserved.