use of org.geolatte.geom.Geometry in project hibernate-orm by hibernate.
the class GeomEntity method createFrom.
static GeomEntity createFrom(TestDataElement element, Dialect dialect) throws WktDecodeException {
WktDecoder decoder = getWktDecoder(dialect);
Geometry geom = decoder.decode(element.wkt);
GeomEntity result = new GeomEntity();
result.setId(element.id);
result.setGeom(geom);
result.setType(element.type);
return result;
}
use of org.geolatte.geom.Geometry in project hibernate-orm by hibernate.
the class PGGeometryTypeDescriptor 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 PGobject obj = toPGobject(value, options);
st.setObject(index, obj);
}
@Override
protected void doBind(CallableStatement st, X value, String name, WrapperOptions options) throws SQLException {
final PGobject obj = toPGobject(value, options);
st.setObject(name, obj);
}
private PGobject toPGobject(X value, WrapperOptions options) throws SQLException {
final WkbEncoder encoder = Wkb.newEncoder(Wkb.Dialect.POSTGIS_EWKB_1);
final Geometry geometry = getJavaDescriptor().unwrap(value, Geometry.class, options);
final String hexString = encoder.encode(geometry, ByteOrder.NDR).toString();
final PGobject obj = new PGobject();
obj.setType("geometry");
obj.setValue(hexString);
return obj;
}
};
}
use of org.geolatte.geom.Geometry in project hibernate-orm by hibernate.
the class GeoDBGeometryTypeDescriptor 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 Geometry geometry = getJavaDescriptor().unwrap(value, Geometry.class, options);
st.setBytes(index, GeoDbWkb.to(geometry));
}
@Override
protected void doBind(CallableStatement st, X value, String name, WrapperOptions options) throws SQLException {
final Geometry geometry = getJavaDescriptor().unwrap(value, Geometry.class, options);
st.setBytes(name, GeoDbWkb.to(geometry));
}
};
}
use of org.geolatte.geom.Geometry 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);
}
};
}
use of org.geolatte.geom.Geometry in project querydsl by querydsl.
the class PGgeometryConverterTest method roundTrip.
@Test
public void roundTrip() {
List<Geometry> geometries = getGeometries();
for (Geometry geometry : geometries) {
org.postgis.Geometry converted = PGgeometryConverter.convert(geometry);
Geometry back = PGgeometryConverter.convert(converted);
assertEquals(geometry, back);
}
}
Aggregations