我想從字節數組中提取一組座標到DoubleBuffer中。如何將字節數組數據導入DoubleBuffer
下面是我如何從主字節數組中提取一組座標到另一個字節數組的示例。
byte intPoints[] = new byte[4];
byte geomCoords[];
...
is = new ByteArrayInputStream(stmt.column_bytes(0)); //reads the polygon from db
...
is.read(intPoints); //intPoints now holds the number of points in the polygon
//After this is read the actual coordinate list is next
//Set the size of geomCoords to hold all coordinates,
//There are 2 coordinates per point and each coordinate is a double value(8 bytes)
geomCoords = new byte[ByteBuffer.wrap(intPoints).order(endian).getInt() * 2 * 8];
is.read(geomCoords); //geomCoords now holds all the coordinates for the polygon
我的問題是:
我怎樣才能得到geomCoords字節數組爲雙緩衝?
或
如果不創建geomCoords,我可以將這些數據存入DoubleBuffer嗎?速度和效率是關鍵,所以任何捷徑或優化是最受歡迎的!
提取'新的字節緩衝區(字節).asDoubleBuffer()' –
@MarkoTopolnik所以呢?:DoubleBuffer dbuf = new ByteBuffer(geomCoords).asDoubleBuffer(); – Hank
如何在一個字節數組中編碼座標? – Joni