org.postgis.jts

## Class JtsBinaryWriter

- java.lang.Object
- - org.postgis.jts.JtsBinaryWriter

    public class JtsBinaryWriter
    extends Object

Create binary representation of geometries. Currently, only text rep (hexed) implementation is tested. Supports only 2 dimensional geometries. It should be easy to add char[] and CharSequence ByteGetter instances, although the latter one is not compatible with older jdks. I did not implement real unsigned 32-bit integers or emulate them with long, as both java Arrays and Strings currently can have only 2^31-1 elements (bytes), so we cannot even get or build Geometries with more than approx. 2^28 coordinates (8 bytes each).

Author:
  markus.schaber@logi-track.com

### Constructor Summary

Constructors
Constructor and Description
`JtsBinaryWriter()`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`protected int` `estimateBytes(com.vividsolutions.jts.geom.Geometry geom)` Estimate how much bytes a geometry will need in WKB.
`static int` `getCoordDim(com.vividsolutions.jts.geom.Geometry geom)`
`static int` `getCoordSequenceDim(com.vividsolutions.jts.geom.CoordinateSequence coords)`
`static int` `getWKBType(com.vividsolutions.jts.geom.Geometry geom)`
`static ValueSetter` `valueSetterForEndian(ByteSetter bytes, byte endian)` Get the appropriate ValueGetter for my endianness
`byte[]` `writeBinary(com.vividsolutions.jts.geom.Geometry geom)`
`byte[]` `writeBinary(com.vividsolutions.jts.geom.Geometry geom, byte REP)` Write a binary encoded geometry.
`protected void` `writeGeometry(com.vividsolutions.jts.geom.Geometry geom, ValueSetter dest)` Parse a geometry starting at offset.
`String` `writeHexed(com.vividsolutions.jts.geom.Geometry geom)`
`String` `writeHexed(com.vividsolutions.jts.geom.Geometry geom, byte REP)` Write a hex encoded geometry Currently, geometries with more than 2 dimensions and measures are not cleanly supported, but SRID is honored.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### JtsBinaryWriter

    public JtsBinaryWriter()

### Method Detail

#### valueSetterForEndian

    public static ValueSetter valueSetterForEndian(ByteSetter bytes,
                                                   byte endian)

Get the appropriate ValueGetter for my endianness

Parameters:
  `bytes` - The appropriate Byte Getter
Returns:
  the ValueGetter

#### writeHexed

    public String writeHexed(com.vividsolutions.jts.geom.Geometry geom,
                             byte REP)

Write a hex encoded geometry Currently, geometries with more than 2 dimensions and measures are not cleanly supported, but SRID is honored.

#### writeHexed

    public String writeHexed(com.vividsolutions.jts.geom.Geometry geom)

#### writeBinary

    public byte[] writeBinary(com.vividsolutions.jts.geom.Geometry geom,
                              byte REP)

Write a binary encoded geometry. Currently, geometries with more than 2 dimensions and measures are not cleanly supported, but SRID is honored.

#### writeBinary

    public byte[] writeBinary(com.vividsolutions.jts.geom.Geometry geom)

#### writeGeometry

    protected void writeGeometry(com.vividsolutions.jts.geom.Geometry geom,
                                 ValueSetter dest)

Parse a geometry starting at offset.

#### getWKBType

    public static int getWKBType(com.vividsolutions.jts.geom.Geometry geom)

#### estimateBytes

    protected int estimateBytes(com.vividsolutions.jts.geom.Geometry geom)

Estimate how much bytes a geometry will need in WKB.

#### getCoordDim

    public static final int getCoordDim(com.vividsolutions.jts.geom.Geometry geom)

#### getCoordSequenceDim

    public static final int getCoordSequenceDim(com.vividsolutions.jts.geom.CoordinateSequence coords)