Package 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:
- [email protected]
-
-
Constructor Summary
Constructors Constructor Description JtsBinaryWriter()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected intestimateBytes(org.locationtech.jts.geom.Geometry geom)Estimate how much bytes a geometry will need in WKB.static intgetCoordDim(org.locationtech.jts.geom.Geometry geom)static intgetCoordSequenceDim(org.locationtech.jts.geom.CoordinateSequence coords)static intgetWKBType(org.locationtech.jts.geom.Geometry geom)static ValueSettervalueSetterForEndian(ByteSetter bytes, byte endian)Get the appropriate ValueGetter for my endiannessbyte[]writeBinary(org.locationtech.jts.geom.Geometry geom)byte[]writeBinary(org.locationtech.jts.geom.Geometry geom, byte REP)Write a binary encoded geometry.protected voidwriteGeometry(org.locationtech.jts.geom.Geometry geom, ValueSetter dest)Parse a geometry starting at offset.StringwriteHexed(org.locationtech.jts.geom.Geometry geom)StringwriteHexed(org.locationtech.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.
-
-
-
Method Detail
-
valueSetterForEndian
public static ValueSetter valueSetterForEndian(ByteSetter bytes, byte endian)
Get the appropriate ValueGetter for my endianness- Parameters:
bytes- The ByteSetterendian- The endian to be used- Returns:
- the appropriate ValueSetter for the specified endian
-
writeHexed
public String writeHexed(org.locationtech.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.- Parameters:
geom- The geometry to be writtenREP- The endianness representation to use for writing- Returns:
- String containing the hex-encoded geometry
-
writeHexed
public String writeHexed(org.locationtech.jts.geom.Geometry geom)
-
writeBinary
public byte[] writeBinary(org.locationtech.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.- Parameters:
geom- The geometry to be writtenREP- The endianness representation to use for writing- Returns:
- byte array containing the encoded geometry
-
writeBinary
public byte[] writeBinary(org.locationtech.jts.geom.Geometry geom)
-
writeGeometry
protected void writeGeometry(org.locationtech.jts.geom.Geometry geom, ValueSetter dest)Parse a geometry starting at offset.- Parameters:
geom- The Geometry to be writtendest- The ValueSettr to write to
-
getWKBType
public static int getWKBType(org.locationtech.jts.geom.Geometry geom)
-
estimateBytes
protected int estimateBytes(org.locationtech.jts.geom.Geometry geom)
Estimate how much bytes a geometry will need in WKB.- Parameters:
geom- Geometry to estimate- Returns:
- number of bytes needed
-
getCoordDim
public static final int getCoordDim(org.locationtech.jts.geom.Geometry geom)
-
getCoordSequenceDim
public static final int getCoordSequenceDim(org.locationtech.jts.geom.CoordinateSequence coords)
-
-