byte byteOrderWKB = dis.readByte();
private Figure[] readFigures(ByteOrderDataInStream is, int num) throws IOException { Figure[] figures = new Figure[num]; for (int i = 0; i < num; i++) { Figure figure = new Figure(); figure.attributes = is.readByte(); figure.pointOffset = is.readInt(); figures[i] = figure; } return figures; }
private Figure[] readFigures(ByteOrderDataInStream is, int num) throws IOException { Figure[] figures = new Figure[num]; for (int i = 0; i < num; i++) { Figure figure = new Figure(); figure.attributes = is.readByte(); figure.pointOffset = is.readInt(); figures[i] = figure; } return figures; }
private Shape[] readShapes(ByteOrderDataInStream is, int num) throws IOException { Shape[] shapes = new Shape[num]; for (int i = 0; i < num; i++) { Shape shape = new Shape(); shape.parentOffset = is.readInt(); shape.figureOffset = is.readInt(); shape.type = TYPES[is.readByte() - 1]; shapes[i] = shape; } return shapes; }
private Shape[] readShapes(ByteOrderDataInStream is, int num) throws IOException { Shape[] shapes = new Shape[num]; for (int i = 0; i < num; i++) { Shape shape = new Shape(); shape.parentOffset = is.readInt(); shape.figureOffset = is.readInt(); shape.type = TYPES[is.readByte() - 1]; shapes[i] = shape; } return shapes; }
ByteOrderDataInStream dis = new ByteOrderDataInStream(); dis.setInStream(new ByteArrayInStream(bytes)); byte byteOrder = dis.readByte();
/** * Read the first bytes of Geometry WKB. * @param bytes WKB Bytes * @return Geometry MetaData * @throws IOException If WKB meta is invalid (do not check the Geometry) */ public static GeometryMetaData getMetaDataFromWKB(byte[] bytes) throws IOException { ByteOrderDataInStream dis = new ByteOrderDataInStream(); dis.setInStream(new ByteArrayInStream(bytes)); // determine byte order byte byteOrderWKB = dis.readByte(); // always set byte order, since it may change from geometry to geometry int byteOrder = byteOrderWKB == WKBConstants.wkbNDR ? ByteOrderValues.LITTLE_ENDIAN : ByteOrderValues.BIG_ENDIAN; dis.setOrder(byteOrder); int typeInt = dis.readInt(); int geometryType = typeInt & 0xff; // determine if Z values are present boolean hasZ = (typeInt & 0x80000000) != 0; int inputDimension = hasZ ? 3 : 2; // determine if SRIDs are present boolean hasSRID = (typeInt & 0x20000000) != 0; int SRID = 0; if (hasSRID) { SRID = dis.readInt(); } return new GeometryMetaData(inputDimension, hasSRID, hasZ, geometryType, SRID); } }
/** * Read the first bytes of Geometry WKB. * @param bytes WKB Bytes * @return Geometry MetaData * @throws IOException If WKB meta is invalid (do not check the Geometry) */ public static GeometryMetaData getMetaDataFromWKB(byte[] bytes) throws IOException { ByteOrderDataInStream dis = new ByteOrderDataInStream(); dis.setInStream(new ByteArrayInStream(bytes)); // determine byte order byte byteOrderWKB = dis.readByte(); // always set byte order, since it may change from geometry to geometry int byteOrder = byteOrderWKB == WKBConstants.wkbNDR ? ByteOrderValues.LITTLE_ENDIAN : ByteOrderValues.BIG_ENDIAN; dis.setOrder(byteOrder); int typeInt = dis.readInt(); int geometryType = typeInt & 0xff; // determine if Z values are present boolean hasZ = (typeInt & 0x80000000) != 0; int inputDimension = hasZ ? 3 : 2; // determine if SRIDs are present boolean hasSRID = (typeInt & 0x20000000) != 0; int SRID = 0; if (hasSRID) { SRID = dis.readInt(); } return new GeometryMetaData(inputDimension, hasSRID, hasZ, geometryType, SRID); } }
byte byteOrder = dis.readByte();
byte byteOrderWKB = dis.readByte();