public class WKBReader extends Object
Geometryfrom a byte stream in Well-Known Binary format.
Supports use of an InStream, which allows easy use
with arbitrary byte stream sources.
This class reads the format describe in WKBWriter.
It also partially handles
the Extended WKB format used by PostGIS,
by parsing and storing SRID values.
The reader repairs structurally-invalid input
(specifically, LineStrings and LinearRings which contain
too few points have vertices added,
and non-closed rings are closed).
This class is designed to support reuse of a single instance to read multiple geometries. This class is not thread-safe; each thread should create its own instance.
for a formal format specification| Constructor and Description |
|---|
WKBReader() |
WKBReader(GeometryFactory geometryFactory) |
| Modifier and Type | Method and Description |
|---|---|
static LineString |
createClosedRing(LineString seq,
int size) |
static LineString |
ensureValidRing(LineString seq)
Ensures that a LineString forms a valid ring,
returning a new closed sequence of the correct length if required.
|
static LineString |
extend(LineString seq,
int size) |
static byte[] |
hexToBytes(String hex)
Converts a hexadecimal string to a byte array.
|
static boolean |
isEqual(LineString cs1,
LineString cs2)
Tests whether two
LineStrings are equal. |
static boolean |
isRing(LineString seq)
Tests whether a
LineString forms a valid LinearRing,
by checking the sequence length and closure
(whether the first and last points are identical in 2D). |
Geometry |
read(byte[] bytes)
Reads a single
Geometry in WKB format from a byte array. |
Geometry |
read(InStream is)
|
public WKBReader()
public WKBReader(GeometryFactory geometryFactory)
public static LineString createClosedRing(LineString seq, int size)
public static LineString ensureValidRing(LineString seq)
seq - the sequence to testgeometryFactory - the CoordinateSequenceFactory to use to create the new sequencepublic static LineString extend(LineString seq, int size)
public static byte[] hexToBytes(String hex)
hex - a string containing hex digitspublic static boolean isEqual(LineString cs1, LineString cs2)
LineStrings are equal.
To be equal, the sequences must be the same length.
They do not need to be of the same dimension,
but the ordinate values for the smallest dimension of the two
must be equal.
Two NaN ordinates values are considered to be equal.cs1 - a LineStringcs2 - a LineStringpublic static boolean isRing(LineString seq)
LineString forms a valid LinearRing,
by checking the sequence length and closure
(whether the first and last points are identical in 2D).
Self-intersection is not checked.seq - the sequence to testLinearRingpublic Geometry read(byte[] bytes) throws ParseException
Geometry in WKB format from a byte array.bytes - the byte array to read fromParseException - if the WKB is ill-formedpublic Geometry read(InStream is) throws IOException, ParseException
is - the stream to read fromIOException - if the underlying stream creates an errorParseException - if the WKB is ill-formedCopyright © 2015 Revolution Systems Inc.. All rights reserved.