use of org.geolatte.geom.ByteBuffer in project hibernate-orm by hibernate.
the class MySQLExpectationsFactory method decode.
@Override
protected Geometry decode(Object bytes) {
if (bytes == null) {
return null;
}
ByteBuffer buffer = ByteBuffer.from((byte[]) bytes);
WkbDecoder decoder = Wkb.newDecoder(Wkb.Dialect.MYSQL_WKB);
return JTS.to(decoder.decode(buffer));
}
use of org.geolatte.geom.ByteBuffer in project hibernate-orm by hibernate.
the class PGGeometryTypeDescriptor method toGeometry.
public static Geometry<?> toGeometry(Object object) {
if (object == null) {
return null;
}
ByteBuffer buffer = null;
if (object instanceof PGobject) {
String pgValue = ((PGobject) object).getValue();
if (pgValue.startsWith("00") || pgValue.startsWith("01")) {
//we have a WKB because this pgValue starts with the bit-order byte
buffer = ByteBuffer.from(pgValue);
final WkbDecoder decoder = Wkb.newDecoder(Wkb.Dialect.POSTGIS_EWKB_1);
return decoder.decode(buffer);
} else {
return parseWkt(pgValue);
}
}
throw new IllegalStateException("Received object of type " + object.getClass().getCanonicalName());
}
use of org.geolatte.geom.ByteBuffer in project hibernate-orm by hibernate.
the class GeoDbWkb method to.
/**
* Encode the specified {@code Geometry} into a WKB
*
* @param geometry The value to encode
*
* @return A byte-array representing the geometry in WKB.
*/
public static byte[] to(Geometry geometry) {
final WkbEncoder encoder = Wkb.newEncoder(Wkb.Dialect.POSTGIS_EWKB_1);
final ByteBuffer buffer = encoder.encode(geometry, ByteOrder.NDR);
return (buffer == null ? null : buffer.toByteArray());
}
use of org.geolatte.geom.ByteBuffer in project hibernate-orm by hibernate.
the class MySQLGeometryTypeDescriptor method toGeometry.
private Geometry toGeometry(byte[] bytes) {
if (bytes == null) {
return null;
}
final ByteBuffer buffer = ByteBuffer.from(bytes);
final WkbDecoder decoder = Wkb.newDecoder(Wkb.Dialect.MYSQL_WKB);
return decoder.decode(buffer);
}
use of org.geolatte.geom.ByteBuffer in project querydsl by querydsl.
the class GeoDBWkbType 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());
}
Aggregations