Search in sources :

Example 1 with GisAttribute

use of org.jkiss.dbeaver.model.gis.GisAttribute in project dbeaver by serge-rider.

the class GISTextViewer method primeEditorValue.

@Override
public void primeEditorValue(Object value) throws DBException {
    super.primeEditorValue(value);
    valueSRID = 0;
    if (value instanceof Geometry) {
        this.valueSRID = ((Geometry) value).getSRID();
    } else if (value instanceof DBGeometry) {
        this.valueSRID = ((DBGeometry) value).getSRID();
    }
    if (valueSRID == 0) {
        DBSTypedObject column = valueController.getValueType();
        if (column instanceof GisAttribute) {
            valueSRID = ((GisAttribute) column).getAttributeGeometrySRID(new VoidProgressMonitor());
        }
    }
    updateToolBar();
}
Also used : DBGeometry(org.jkiss.dbeaver.model.gis.DBGeometry) Geometry(org.locationtech.jts.geom.Geometry) DBSTypedObject(org.jkiss.dbeaver.model.struct.DBSTypedObject) GisAttribute(org.jkiss.dbeaver.model.gis.GisAttribute) DBGeometry(org.jkiss.dbeaver.model.gis.DBGeometry) VoidProgressMonitor(org.jkiss.dbeaver.model.runtime.VoidProgressMonitor)

Example 2 with GisAttribute

use of org.jkiss.dbeaver.model.gis.GisAttribute 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)

Aggregations

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 HANAWKBWriterException (org.jkiss.dbeaver.ext.hana.model.data.wkb.HANAWKBWriterException)1 DBCException (org.jkiss.dbeaver.model.exec.DBCException)1 VoidProgressMonitor (org.jkiss.dbeaver.model.runtime.VoidProgressMonitor)1