use of org.geolatte.geom.ByteBuffer in project querydsl by querydsl.
the class MySQLWkbType method setValue.
@Override
public void setValue(PreparedStatement st, int startIndex, Geometry value) throws SQLException {
WkbEncoder encoder = Wkb.newEncoder(Wkb.Dialect.POSTGIS_EWKB_1);
ByteBuffer buffer = encoder.encode(value, byteOrder);
int srid = value.getSRID();
// prepend srid into first 4 bytes
byte[] wkb = buffer.toByteArray();
byte[] bytes = new byte[wkb.length + 4];
bytes[3] = (byte) ((srid >> 24) & 0xFF);
bytes[2] = (byte) ((srid >> 16) & 0xFF);
bytes[1] = (byte) ((srid >> 8) & 0xFF);
bytes[0] = (byte) (srid & 0xFF);
System.arraycopy(wkb, 0, bytes, 4, wkb.length);
st.setBytes(startIndex, bytes);
}
use of org.geolatte.geom.ByteBuffer in project querydsl by querydsl.
the class GeometryWkbType method setValue.
@Override
public void setValue(PreparedStatement st, int startIndex, Geometry value) throws SQLException {
WkbEncoder encoder = Wkb.newEncoder(Wkb.Dialect.POSTGIS_EWKB_1);
ByteBuffer buffer = encoder.encode(value, byteOrder);
st.setBytes(startIndex, buffer.toByteArray());
}
use of org.geolatte.geom.ByteBuffer in project hibernate-orm by hibernate.
the class MySQLGeometryTypeDescriptor method getBinder.
@Override
public <X> ValueBinder<X> getBinder(final JavaTypeDescriptor<X> javaTypeDescriptor) {
return new BasicBinder<X>(javaTypeDescriptor, this) {
@Override
protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException {
final WkbEncoder encoder = Wkb.newEncoder(Wkb.Dialect.MYSQL_WKB);
final Geometry geometry = getJavaDescriptor().unwrap(value, Geometry.class, options);
final ByteBuffer buffer = encoder.encode(geometry, ByteOrder.NDR);
final byte[] bytes = (buffer == null ? null : buffer.toByteArray());
st.setBytes(index, bytes);
}
@Override
protected void doBind(CallableStatement st, X value, String name, WrapperOptions options) throws SQLException {
final WkbEncoder encoder = Wkb.newEncoder(Wkb.Dialect.MYSQL_WKB);
final Geometry geometry = getJavaDescriptor().unwrap(value, Geometry.class, options);
final ByteBuffer buffer = encoder.encode(geometry, ByteOrder.NDR);
final byte[] bytes = (buffer == null ? null : buffer.toByteArray());
st.setBytes(name, bytes);
}
};
}
Aggregations