本文整理了Java中org.geolatte.geom.codec.Wkb
类的一些代码示例,展示了Wkb
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Wkb
类的具体详情如下:
包路径:org.geolatte.geom.codec.Wkb
类名称:Wkb
[英]Creates encoders/decoders for WKB geometry representations.
Note that the WkbEncoder/WkbDecoder
instances returned by the factory methods are not thread-safe.
[中]为WKB几何体表示创建编码器/解码器。
请注意,工厂方法返回的WkbEncoder/WkbDecoder
实例不是线程安全的。
代码示例来源:origin: hibernate/hibernate-orm
private static Geometry<?> toGeometry(ByteBuffer buffer) {
if ( buffer == null ) {
return null;
}
WkbDecoder decoder = Wkb.newDecoder( Wkb.Dialect.HANA_EWKB );
return decoder.decode( buffer );
}
代码示例来源:origin: hibernate/hibernate-orm
public static byte[] toEWKB(Geometry<?> geometry) {
WkbEncoder encoder = Wkb.newEncoder( Wkb.Dialect.HANA_EWKB );
ByteBuffer bytes = encoder.encode( geometry, ByteOrder.NDR );
return bytes.toByteArray();
}
}
代码示例来源:origin: hibernate/hibernate-orm
@Override
protected Geometry decode(Object o) {
return JTS.to( Wkb.fromWkb( ByteBuffer.from( (byte[]) o ) ) );
}
}
代码示例来源:origin: hibernate/hibernate-orm
@Test
public void testWkbNDR() throws SQLException {
String wkb = Wkb.toWkb( geom, ByteOrder.NDR ).toString();
testCase( wkb, geom );
}
代码示例来源:origin: org.geolatte/geolatte-geom
/**
* Creates a <code>WkbDecoder</code> for the specified WKB <code>Dialect</code>.
*
* @param dialect the WKB dialect
* @return an <code>WkbDecoder</code> that supports the specified dialect
*/
public static WkbDecoder newDecoder(Dialect dialect) {
Class<? extends WkbDecoder> decoderClass = DECODERS.get(dialect);
assert (decoderClass != null) : "A variant declared, but no encoder/decoder registered.";
return createInstance(decoderClass);
}
代码示例来源:origin: hibernate/hibernate-orm
@Test
public void testWkbXDR() throws SQLException {
String wkb = Wkb.toWkb( geom, ByteOrder.XDR ).toString();
testCase( wkb, geom );
}
代码示例来源:origin: org.geolatte/geolatte-geom
/**
* Creates a <code>WkbDecoder</code> for the default WKB <code>Dialect</code>.
*
* @return an <code>WkbDecoder</code> that supports the specified dialect
*/
public static WkbDecoder newDecoder() {
Class<? extends WkbDecoder> decoderClass = DECODERS.get(DEFAULT_DIALECT);
assert (decoderClass != null) : "A variant declared, but no encoder/decoder registered.";
return createInstance(decoderClass);
}
代码示例来源:origin: hibernate/hibernate-orm
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 );
}
代码示例来源:origin: hibernate/hibernate-orm
/**
* 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() );
}
代码示例来源:origin: org.geolatte/geolatte-geom
/**
* Encodes a <code>Geometry</code> into a WKB representation using the NDR (little-endian) byte-order.
*
* <p>This methods uses the default WKB dialect (Postgis v1.5 EWKB ).</p>
*
* @param geometry The <code>Geometry</code> to be encoded as WKB.
* @return A buffer of bytes that contains the WKB-encoded <code>Geometry</code>.
*/
public static ByteBuffer toWkb(Geometry geometry) {
return toWkb(geometry, ByteOrder.NDR);
}
代码示例来源:origin: org.geolatte/geolatte-geom
private Object readResolve() throws ObjectStreamException {
return Wkb.fromWkb(ByteBuffer.from(this.buffer));
}
代码示例来源:origin: org.geolatte/geolatte-geom
/**
* Creates a <code>WkbEncoder</code> for the specified WKB <code>Dialect</code>.
*
* @param dialect the WKB dialect
* @return an <code>WkbEncoder</code> that supports the specified dialect
*/
public static WkbEncoder newEncoder(Dialect dialect) {
Class<? extends WkbEncoder> decoderClass = ENCODERS.get(dialect);
assert (decoderClass != null) : "A variant declared, but no encoder/decoder registered.";
return createInstance(decoderClass);
}
代码示例来源:origin: hibernate/hibernate-orm
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() );
}
代码示例来源:origin: hibernate/hibernate-orm
@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 );
}
代码示例来源:origin: org.geolatte/geolatte-geom
protected Object writeReplace() throws ObjectStreamException {
ByteBuffer buffer = Wkb.toWkb(this);
return new SerializationProxy(buffer);
}
代码示例来源:origin: org.geolatte/geolatte-geom
/**
* Creates a <code>WkbEncoder</code> for the default WKB <code>Dialect</code>.
*
* @return an <code>WkbEncoder</code> that supports the specified dialect
*/
public static WkbEncoder newEncoder() {
Class<? extends WkbEncoder> decoderClass = ENCODERS.get(DEFAULT_DIALECT);
assert (decoderClass != null) : "A variant declared, but no encoder/decoder registered.";
return createInstance(decoderClass);
}
代码示例来源:origin: hibernate/hibernate-orm
@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 ) );
}
}
代码示例来源:origin: hibernate/hibernate-orm
@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 );
}
};
代码示例来源:origin: hibernate/hibernate-orm
return JTS.from( (org.locationtech.jts.geom.Geometry) object );
final WkbDecoder decoder = Wkb.newDecoder( Wkb.Dialect.POSTGIS_EWKB_1 );
if ( object instanceof Blob ) {
return decoder.decode( toByteBuffer( (Blob) object ) );
代码示例来源:origin: hibernate/hibernate-orm
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;
}
内容来源于网络,如有侵权,请联系作者删除!