|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.geotools.data.postgis.attributeio.WKBEncoder
This class is a JTS <->WKB converter that will convert JTS Geometry objects into Strings of hexadecimal characters that represent their Well Known Binary (WKB) equivalents.
For example, in a Postgres database with PostGIS capabilities, the following statements can be executed:
select asbinary('POINT(1 1)'::geometry, 'XDR'); asbinary -------------------------------------------- 00000000013FF00000000000003FF0000000000000 (1 row) select geomfromwkb('00000000013FF00000000000003FF0000000000000'::wkb); geomfromwkb ------------------- SRID=0;POINT(1 1) (1 row)
The WKBParser#WKB2Geometry(String) method will create a new JTS POINT object when passed "00000000013FF00000000000003FF0000000000000" as a parameter. Further, the WKBParser#Geometry2WKB(Geometry) method will create the string "00000000013FF00000000000003FF0000000000000" when passed a JTS POINT(1 1) geometry object.
Note: when using PostGIS's asbinary(...) method, use 'XDR' as a parameter to use BigEndian format in the WKB representation.
Field Summary |
Fields inherited from interface org.wkb4j.engine.WKBGeometryTypes |
linearRing, wkbGeometryCollection, wkbLineString, wkbMultiLineString, wkbMultiPoint, wkbMultiPolygon, wkbPoint, wkbPolygon |
Constructor Summary | |
WKBEncoder()
|
Method Summary | |
static java.lang.String |
bytesToString(byte[] bytes)
This method will convert a byte[] to a string of hex characters that represent the byte[] |
static byte[] |
encodeGeometry(com.vividsolutions.jts.geom.Geometry geom)
This method will convert a JTS Geometry to a an array of bytes that represent Well Known Binary representation of the geometry object in big endian encoding. |
static java.lang.String |
encodeGeometryHex(com.vividsolutions.jts.geom.Geometry geom)
This method will convert a JTS Geometry to a string of hex characters that represent Well Known Binary representation of the geometry object. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public WKBEncoder()
Method Detail |
public static byte[] encodeGeometry(com.vividsolutions.jts.geom.Geometry geom) throws java.io.IOException
geom
- -
a standard JTS geometry subclass, custom extensions are not
supported
java.io.IOException
- if an I/O error occurs with the data output streampublic static java.lang.String encodeGeometryHex(com.vividsolutions.jts.geom.Geometry geom) throws java.io.IOException
geom
- Either Point, LineString, Polygon, MultiPoint,
MultiLineString, or MultiPolygon
java.lang.Exception
- if an I/O error occurs with the EndianDataOutputStream or the
parser doesn't have any implementation for the specifed
Geometry.
java.io.IOException
public static java.lang.String bytesToString(byte[] bytes)
bytes
- an array of bytes
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |