Search in sources :

Example 1 with SpatiaLiteSupport

use of eu.esdihumboldt.hale.io.jdbc.spatialite.internal.SpatiaLiteSupport in project hale by halestudio.

the class SpatiaLiteGeometries method configureGeometryColumnType.

@Override
public Class<? extends Geometry> configureGeometryColumnType(SQLiteConnection connection, BaseColumn<?> column, DefaultTypeDefinition type) {
    String colName = column.getName();
    String tabName = column.getParent().getName();
    SpatiaLiteSupport slSupport = SpatiaLiteSupportFactory.getInstance().createSpatiaLiteSupport(connection);
    // warn if SpatiaLite is not available
    SpatiaLiteHelper.isSpatialLiteLoadedReport(connection, false);
    GeometryTypeMetadata geomTypeMeta = slSupport.getGeometryTypeMetadata(connection, tabName, colName);
    if (geomTypeMeta != null) {
        SrsMetadata srsMeta = slSupport.getSrsMetadata(connection, geomTypeMeta.getSrid());
        GeometryMetadata columnTypeConstraint;
        if (srsMeta != null) {
            // Create constraint to save the informations
            columnTypeConstraint = new GeometryMetadata(Integer.toString(srsMeta.getAuthSrid()), geomTypeMeta.getCoordDimension(), srsMeta.getSrText(), srsMeta.getAuthName());
        } else {
            // no SRS information, just dimension
            columnTypeConstraint = new GeometryMetadata(geomTypeMeta.getCoordDimension());
        }
        type.setConstraint(columnTypeConstraint);
        return geomTypeMeta.getGeomType();
    } else {
        // no geometry column could be found
        return null;
    }
}
Also used : SrsMetadata(eu.esdihumboldt.hale.io.jdbc.spatialite.internal.SrsMetadata) GeometryMetadata(eu.esdihumboldt.hale.common.schema.model.constraint.type.GeometryMetadata) SpatiaLiteSupport(eu.esdihumboldt.hale.io.jdbc.spatialite.internal.SpatiaLiteSupport) GeometryTypeMetadata(eu.esdihumboldt.hale.io.jdbc.spatialite.internal.GeometryTypeMetadata)

Aggregations

GeometryMetadata (eu.esdihumboldt.hale.common.schema.model.constraint.type.GeometryMetadata)1 GeometryTypeMetadata (eu.esdihumboldt.hale.io.jdbc.spatialite.internal.GeometryTypeMetadata)1 SpatiaLiteSupport (eu.esdihumboldt.hale.io.jdbc.spatialite.internal.SpatiaLiteSupport)1 SrsMetadata (eu.esdihumboldt.hale.io.jdbc.spatialite.internal.SrsMetadata)1