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();
}
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");
}
}
Aggregations