1

バイト配列から 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 バイト配列を DoubleBuffer に入れることができますか?
または
、geomCoords を作成せずにこのデータを DoubleBuffer に入れることはできますか? スピードと効率が鍵となるため、近道や最適化は大歓迎です!

4

1 に答える 1

0

バイト バッファー内の 8 バイトが実際に Double であることがわかっている場合は、単純に

DoubleBuffer dbls = new ByteBuffer(geomCoords).asDoubleBuffer();

これで、各ポイントを次のように抽出できますdbls.get();

于 2013-06-30T16:40:51.837 に答える