Package org.locationtech.spatial4j.io
Class BinaryCodec
- java.lang.Object
-
- org.locationtech.spatial4j.io.BinaryCodec
-
- Direct Known Subclasses:
JtsBinaryCodec
public class BinaryCodec extends Object
A binary shape format. It is not designed to be a published standard, unlike Well Known Binary (WKB). The initial release is simple but it could get more optimized to use fewer bytes or to write & read pre-computed index structures.Immutable and thread-safe.
-
-
Field Summary
Fields Modifier and Type Field Description protected SpatialContextctxprotected static byteTYPE_CIRCLEprotected static byteTYPE_COLLprotected static byteTYPE_GEOMprotected static byteTYPE_POINTprotected static byteTYPE_RECT
-
Constructor Summary
Constructors Constructor Description BinaryCodec(SpatialContext ctx, SpatialContextFactory factory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CirclereadCircle(DataInput dataInput)ShapeCollectionreadCollection(DataInput dataInput)protected doublereadDim(DataInput dataInput)PointreadPoint(DataInput dataInput)RectanglereadRect(DataInput dataInput)ShapereadShape(DataInput dataInput)protected ShapereadShapeByTypeIfSupported(DataInput dataInput, byte type)protected bytetypeForShape(Shape s)voidwriteCircle(DataOutput dataOutput, Circle c)voidwriteCollection(DataOutput dataOutput, ShapeCollection col)protected voidwriteDim(DataOutput dataOutput, double v)voidwritePoint(DataOutput dataOutput, Point pt)voidwriteRect(DataOutput dataOutput, Rectangle r)voidwriteShape(DataOutput dataOutput, Shape s)protected booleanwriteShapeByTypeIfSupported(DataOutput dataOutput, Shape s)Note: writes the type byte even if not supportedprotected booleanwriteShapeByTypeIfSupported(DataOutput dataOutput, Shape s, byte type)
-
-
-
Field Detail
-
TYPE_POINT
protected static final byte TYPE_POINT
- See Also:
- Constant Field Values
-
TYPE_RECT
protected static final byte TYPE_RECT
- See Also:
- Constant Field Values
-
TYPE_CIRCLE
protected static final byte TYPE_CIRCLE
- See Also:
- Constant Field Values
-
TYPE_COLL
protected static final byte TYPE_COLL
- See Also:
- Constant Field Values
-
TYPE_GEOM
protected static final byte TYPE_GEOM
- See Also:
- Constant Field Values
-
ctx
protected final SpatialContext ctx
-
-
Constructor Detail
-
BinaryCodec
public BinaryCodec(SpatialContext ctx, SpatialContextFactory factory)
-
-
Method Detail
-
readShape
public Shape readShape(DataInput dataInput) throws IOException
- Throws:
IOException
-
writeShape
public void writeShape(DataOutput dataOutput, Shape s) throws IOException
- Throws:
IOException
-
readShapeByTypeIfSupported
protected Shape readShapeByTypeIfSupported(DataInput dataInput, byte type) throws IOException
- Throws:
IOException
-
writeShapeByTypeIfSupported
protected boolean writeShapeByTypeIfSupported(DataOutput dataOutput, Shape s) throws IOException
Note: writes the type byte even if not supported- Throws:
IOException
-
writeShapeByTypeIfSupported
protected boolean writeShapeByTypeIfSupported(DataOutput dataOutput, Shape s, byte type) throws IOException
- Throws:
IOException
-
typeForShape
protected byte typeForShape(Shape s)
-
readDim
protected double readDim(DataInput dataInput) throws IOException
- Throws:
IOException
-
writeDim
protected void writeDim(DataOutput dataOutput, double v) throws IOException
- Throws:
IOException
-
readPoint
public Point readPoint(DataInput dataInput) throws IOException
- Throws:
IOException
-
writePoint
public void writePoint(DataOutput dataOutput, Point pt) throws IOException
- Throws:
IOException
-
readRect
public Rectangle readRect(DataInput dataInput) throws IOException
- Throws:
IOException
-
writeRect
public void writeRect(DataOutput dataOutput, Rectangle r) throws IOException
- Throws:
IOException
-
readCircle
public Circle readCircle(DataInput dataInput) throws IOException
- Throws:
IOException
-
writeCircle
public void writeCircle(DataOutput dataOutput, Circle c) throws IOException
- Throws:
IOException
-
readCollection
public ShapeCollection readCollection(DataInput dataInput) throws IOException
- Throws:
IOException
-
writeCollection
public void writeCollection(DataOutput dataOutput, ShapeCollection col) throws IOException
- Throws:
IOException
-
-