Search in sources :

Example 1 with HANAWKBWriterException

use of org.jkiss.dbeaver.ext.hana.model.data.wkb.HANAWKBWriterException in project dbeaver by serge-rider.

the class HANAGeometryValueHandler method bindParameter.

@Override
protected void bindParameter(JDBCSession session, JDBCPreparedStatement statement, DBSTypedObject paramType, int paramIndex, Object value) throws DBCException, SQLException {
    Object geometry = value;
    int srid = 0;
    if (geometry instanceof DBGeometry) {
        srid = ((DBGeometry) geometry).getSRID();
        geometry = ((DBGeometry) geometry).getRawValue();
    }
    if (srid == 0 && paramType instanceof GisAttribute) {
        srid = ((GisAttribute) paramType).getAttributeGeometrySRID(session.getProgressMonitor());
    }
    if (geometry == null) {
        statement.setNull(paramIndex, paramType.getTypeID());
    } else if (geometry instanceof Geometry) {
        Geometry g = (Geometry) geometry;
        if (g.getSRID() == 0) {
            g.setSRID(srid);
        }
        try {
            statement.setBytes(paramIndex, HANAWKBWriter.write(g, HANAXyzmModeFinder.findXyzmMode(g)));
        } catch (HANAWKBWriterException e) {
            throw new DBCException(e, session.getExecutionContext());
        }
    } else {
        throw new DBCException("Could not bind the value because the value type is not a known geometry type");
    }
}
Also used : DBGeometry(org.jkiss.dbeaver.model.gis.DBGeometry) Geometry(org.locationtech.jts.geom.Geometry) HANAWKBWriterException(org.jkiss.dbeaver.ext.hana.model.data.wkb.HANAWKBWriterException) GisAttribute(org.jkiss.dbeaver.model.gis.GisAttribute) DBGeometry(org.jkiss.dbeaver.model.gis.DBGeometry) DBSTypedObject(org.jkiss.dbeaver.model.struct.DBSTypedObject) DBCException(org.jkiss.dbeaver.model.exec.DBCException)

Example 2 with HANAWKBWriterException

use of org.jkiss.dbeaver.ext.hana.model.data.wkb.HANAWKBWriterException in project dbeaver by dbeaver.

the class HANAGeometryValueHandler method bindParameter.

@Override
protected void bindParameter(JDBCSession session, JDBCPreparedStatement statement, DBSTypedObject paramType, int paramIndex, Object value) throws DBCException, SQLException {
    Object geometry = value;
    int srid = 0;
    if (geometry instanceof DBGeometry) {
        srid = ((DBGeometry) geometry).getSRID();
        geometry = ((DBGeometry) geometry).getRawValue();
    }
    if (srid == 0 && paramType instanceof GisAttribute) {
        srid = ((GisAttribute) paramType).getAttributeGeometrySRID(session.getProgressMonitor());
    }
    if (geometry == null) {
        statement.setNull(paramIndex, paramType.getTypeID());
    } else if (geometry instanceof Geometry) {
        Geometry g = (Geometry) geometry;
        if (g.getSRID() == 0) {
            g.setSRID(srid);
        }
        try {
            statement.setBytes(paramIndex, HANAWKBWriter.write(g, HANAXyzmModeFinder.findXyzmMode(g)));
        } catch (HANAWKBWriterException e) {
            throw new DBCException(e, session.getExecutionContext());
        }
    } else {
        throw new DBCException("Could not bind the value because the value type is not a known geometry type");
    }
}
Also used : DBGeometry(org.jkiss.dbeaver.model.gis.DBGeometry) Geometry(org.locationtech.jts.geom.Geometry) HANAWKBWriterException(org.jkiss.dbeaver.ext.hana.model.data.wkb.HANAWKBWriterException) GisAttribute(org.jkiss.dbeaver.model.gis.GisAttribute) DBGeometry(org.jkiss.dbeaver.model.gis.DBGeometry) DBSTypedObject(org.jkiss.dbeaver.model.struct.DBSTypedObject) DBCException(org.jkiss.dbeaver.model.exec.DBCException)

Aggregations

HANAWKBWriterException (org.jkiss.dbeaver.ext.hana.model.data.wkb.HANAWKBWriterException)2 DBCException (org.jkiss.dbeaver.model.exec.DBCException)2 DBGeometry (org.jkiss.dbeaver.model.gis.DBGeometry)2 GisAttribute (org.jkiss.dbeaver.model.gis.GisAttribute)2 DBSTypedObject (org.jkiss.dbeaver.model.struct.DBSTypedObject)2 Geometry (org.locationtech.jts.geom.Geometry)2