private static void checkGeometryType(Connection connection, TableLocation tableName, int spatialFieldIndex) throws SQLException { final String fieldName = JDBCUtilities.getFieldName(connection.getMetaData(), tableName.getTable(), spatialFieldIndex); int geomType = SFSUtilities.getGeometryType(connection, tableName, fieldName); if (geomType != GeometryTypeCodes.LINESTRING) { throw new IllegalArgumentException(TYPE_ERROR + SFSUtilities.getGeometryTypeNameFromCode(geomType)); } }
@Override protected Object doInBackground() throws Exception { try (Connection connection = dataSource.getConnection()) { fetchingTableIcons.set(false); for (String tableName : tableGeomType.keySet()) { // Fetch icons where type is -1 int currentType = tableGeomType.get(tableName); if(currentType < 0) { int newType = SFSUtilities.getGeometryType(connection, TableLocation.parse(tableName), ""); if(newType != currentType) { tableGeomType.put(tableName, newType); fetchedTableIcons.add(tableName); } } } } return null; } }
try(Connection connection = ds.getConnection()) { TableLocation tableLocation = TableLocation.parse(layer.getTableReference()); geomType = SFSUtilities.getGeometryType(connection, tableLocation, ""); geometryColumnsCount = SFSUtilities.getGeometryFields(connection, tableLocation).size(); } catch (SQLException e) {
private static void checkGeometryType(Connection connection, TableLocation tableName, int spatialFieldIndex) throws SQLException { final String fieldName = JDBCUtilities.getFieldName(connection.getMetaData(), tableName.getTable(), spatialFieldIndex); int geomType = SFSUtilities.getGeometryType(connection, tableName, fieldName); if (geomType != GeometryTypeCodes.LINESTRING) { throw new IllegalArgumentException(TYPE_ERROR + SFSUtilities.getGeometryTypeNameFromCode(geomType)); } }
/** * Builds the WizardPanel. The objects it will create will be linked to {@code l}. * @param l The parent layer. * @param m Needed for LegendContext implementation. */ public ThematicMapWizard(ILayer l, MapTransform m){ layer = l; try(Connection connection = l.getDataManager().getDataSource().getConnection()) { TableLocation tableLocation = TableLocation.parse(l.getTableReference()); int type = SFSUtilities.getGeometryType(connection, tableLocation, SFSUtilities.getGeometryFields(connection, tableLocation).get(0)); this.geometryType = SimpleGeometryType.getSimpleType(type); mt = m; } catch (SQLException e) { LOGGER.error("Error while reading the data source"); } }
private static void checkGeometryType(Connection connection, TableLocation tableName, int spatialFieldIndex) throws SQLException { final String fieldName = JDBCUtilities.getFieldName(connection.getMetaData(), tableName.getTable(), spatialFieldIndex); int geomType = SFSUtilities.getGeometryType(connection, tableName, fieldName); if (geomType != GeometryTypeCodes.LINESTRING) { throw new IllegalArgumentException(TYPE_ERROR + SFSUtilities.getGeometryTypeNameFromCode(geomType)); } }
/** * Check that the geometry of the active layer can contain one of the list of geometry types. * of geometry types. * @param vc * @param geometryTypes * The OGC geometry type codes we are testing. They are listed in {@link org.h2gis.utilities.GeometryTypeCodes}. * @return */ public static boolean geometryTypeIs(Connection connection, MapContext vc, int... geometryTypes) { ILayer activeLayer = vc.getActiveLayer(); if (activeLayer != null && geometryTypes.length > 0) { try { String table = activeLayer.getTableReference(); if(!table.isEmpty()) { TableLocation tableLocation = TableLocation.parse(activeLayer.getTableReference()); int tableGeoType = SFSUtilities.getGeometryType(connection, tableLocation,""); return tableGeoType == geometryTypes[0] || tableGeoType == GeometryTypeCodes.GEOMETRY; } } catch (SQLException ex) { LOGGER.error(ex.getLocalizedMessage(), ex); } } return false; }
@Override public int getGeometryType(int column) throws SQLException { return SFSUtilities.getGeometryType(statement.getConnection(), new TableLocation(getCatalogName(column), getSchemaName(column), getTableName(column)), getColumnName(column)); }
@Override public int getGeometryType(int column) throws SQLException { return SFSUtilities.getGeometryType(statement.getConnection(), new TableLocation(getCatalogName(column), getSchemaName(column), getTableName(column)), getColumnName(column)); }
@Override public int getGeometryType(int column) throws SQLException { return SFSUtilities.getGeometryType(statement.getConnection(), new TableLocation(getCatalogName(column), getSchemaName(column), getTableName(column)), getColumnName(column)); }
geomFieldName = TableLocation.quoteIdentifier(geoms.get(0)); int typeCode = SFSUtilities.getGeometryType(connection,location,""); if(typeCode== GeometryTypeCodes.GEOMETRY || typeCode==GeometryTypeCodes.GEOMCOLLECTION) {
TableLocation tableLocation = TableLocation.parse(layer.getTableReference()); try(Connection connection = mapContext.getDataManager().getDataSource().getConnection()) { geometryType = SFSUtilities.getGeometryType(connection, tableLocation, "");
try (Connection connection = layer.getDataManager().getDataSource().getConnection()) { int type = SFSUtilities.getGeometryType(connection, TableLocation.parse(layer.getTableReference()), ""); if (type >= 0) { switch (type) {