use of org.locationtech.jts.io.WKBReader in project sis by apache.
the class Factory method parseWKB.
/**
* Reads the given Well Known Binary (WKB).
* This implementation does not change the buffer position.
*
* @param data the sequence of bytes to parse.
* @return the geometry object for the given WKB.
* @throws ParseException if the WKB can not be parsed.
*/
@Override
public GeometryWrapper<Geometry> parseWKB(final ByteBuffer data) throws ParseException {
byte[] array;
if (data.hasArray()) {
/*
* Try to use the underlying array without copy if possible.
* Copy only if the position or length does not match.
*/
array = data.array();
int lower = data.arrayOffset();
int upper = data.limit() + lower;
lower += data.position();
if (lower != 0 || upper != array.length) {
array = Arrays.copyOfRange(array, lower, upper);
}
} else {
array = new byte[data.remaining()];
data.get(array);
}
// WKBReader(GeometryFactory) constructor is cheap.
return new Wrapper(new WKBReader(factory).read(array));
}
Aggregations