It seems JTS already has all these built-in. There is no need to get into
wkb4j madness! It's very simple actually:
// Geometry to WKB string
WKBWriter wkbWriter = new WKBWriter();
String wkb = WKBWriter.bytesToHex(wkbWriter_.write(geom));
// WKB string to Geometry
WKBReader wkbReader = new WKBReader();
Geometry geom = wkbReader.read(WKBReader.hexToBytes(wkb));
You can create your own WKBReader and WKBWriter by using the other
constructors as needed. For my purpose this is enough!
Regards,
Enam
Jody Garnett wrote:
>
> Take a look at the PostGIS code for "attribute io"; it has an
> implementation of how to encode here:
> - PgWKBAttributeIO.read( ResultSet, int )
>> if(useByteArray) {
>> byte bytes[] = rs.getBytes(position);
>> if (bytes == null) // ie. its a null column -> return
>> a null geometry!
>> return null;
>> return WKB2Geometry(Base64.decode(bytes));
>> } else {
>> return WKB2Geometry(hexToBytes(rs.getString(position)));
>> }
> - PgWKBAttributeIO.write( ResultSet, int, Object )
>> if(value == null) {
>> rs.updateNull(position);
>> } else {
>> rs.updateString(position,
>> WKBEncoder.encodeGeometryHex((Geometry) value));
>> }
> When you figure it out send an email to the list and we can make a page
> for the user guide :-)
>
>> Can someone provide me an example on how to convert a WKB to a string and
>> convert back a string to a JTS geometry ? I'm not entirely sure on how to
>> do
>> this using wkb4j. Any help would be appreciated.
>>
>> Enam
>>
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> Geotools-gt2-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>
>
--
View this message in context:
http://www.nabble.com/WKB-to-String-and-vice-versa-tp16146661p16263798.html
Sent from the geotools-gt2-users mailing list archive at Nabble.com.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users