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 String |
getFirstGeometryFieldName(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)
Return the sfs geometry type identifier of the provided field of the provided table.
|
static int |
getGeometryTypeFromGeometry(org.locationtech.jts.geom.Geometry geometry)
Return the sfs geometry type identifier of the provided Geometry
|
static String |
getGeometryTypeNameFromCode(int geometryTypeCode) |
static Map<String,Integer> |
getGeometryTypes(Connection connection,
TableLocation location)
Returns a map containing the field names as key and the SFS geometry type as value from the given table.
|
static org.locationtech.jts.geom.Envelope |
getResultSetEnvelope(ResultSet resultSet)
Compute the full extend of a ResultSet using the first geometry field.
|
static org.locationtech.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 org.locationtech.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(org.locationtech.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 Map<String,Integer> getGeometryTypes(Connection connection, TableLocation location) throws SQLException
connection - Active connectionlocation - Catalog, schema and table nameSQLExceptionGeometryTypeCodespublic 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 org.locationtech.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 - ResultSet to analyseSQLExceptionpublic static int getFirstGeometryFieldIndex(ResultSet resultSet) throws SQLException
resultSet - ResultSet to analyseSQLExceptionpublic static String getFirstGeometryFieldName(ResultSet resultSet) throws SQLException
resultSet - ResultSet to analyseSQLExceptionpublic static boolean hasGeometryField(ResultSet resultSet) throws SQLException
resultSet - ResultSet to analyseSQLExceptionpublic static org.locationtech.jts.geom.Envelope getResultSetEnvelope(ResultSet resultSet) throws SQLException
resultSet - ResultSet to analyseSQLExceptionpublic static org.locationtech.jts.geom.Envelope getResultSetEnvelope(ResultSet resultSet, String fieldName) throws SQLException
resultSet - ResultSet to analysefieldName - Field to analyseSQLExceptionpublic static int getSRID(Connection connection, TableLocation table) throws SQLException
connection - Active connectiontable - Table nameSQLExceptionpublic static int getSRID(Connection connection, TableLocation table, String fieldName) throws SQLException
connection - Active connectiontable - Table namefieldName - Field to analyseSQLExceptionpublic static String[] getAuthorityAndSRID(Connection connection, TableLocation table, String fieldName) throws SQLException
connection - Active connectiontable - Table namefieldName - Field to analyseSQLExceptionpublic static void addTableSRIDConstraint(Connection connection, TableLocation tableLocation, int srid) throws SQLException
connection - Active connectiontableLocation - TableLocation of the table to updatesrid - SRID to setSQLExceptionCopyright © 2019 CNRS. All rights reserved.