From 6a94287cba0540262e80cccd0d3d490f0a75c4d3 Mon Sep 17 00:00:00 2001 From: "D. Berge" Date: Fri, 8 Aug 2025 11:21:05 +0200 Subject: [PATCH] Add type 3 binary bundle. Consisting of final positions + errors. --- lib/www/server/lib/binary/bundle.js | 55 ++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/lib/www/server/lib/binary/bundle.js b/lib/www/server/lib/binary/bundle.js index 5e70c05..45ed8a9 100644 --- a/lib/www/server/lib/binary/bundle.js +++ b/lib/www/server/lib/binary/bundle.js @@ -78,7 +78,7 @@ function bundle (json, opts = {}) { return encode.sequential(json, el => el.line, el => el.point, deltas, values, type) } else if (type == 2) { - /* Gun information: + /* Raw positions and gun information: * * - Δelem 0: BigUint64Array + Int16Array – timestamps * - elem 0‒1: Float32Array, Float32Array – Raw positions (x, y) @@ -225,6 +225,59 @@ function bundle (json, opts = {}) { console.log("DELTAS", deltas); console.log("VALUES", values); + return encode.sequential(json, el => el.sequence, el => el.point, deltas, values, type) + } else if (type == 3) { + /* Final positions and raw vs final errors: + * + * - Δelem 0: BigUint64Array + Int16Array – timestamps + * - elem 0‒1: Float32Array, Float32Array – Final positions (x, y) + * - elem 2‒3: Int16Array, Int16Array – (×10) Final - raw position errors (i, j) + */ + + // Add timestamps + deltas.push({ + // Timestamp + key: el => el.tstamp.valueOf(), + baseType: BigUint64Array, + incrType: Int16Array + }); + + // Add raw positions + values.push({ + // longitude + key: el => el.geometryfinal?.coordinates?.[0], + type: Float32Array + }); + values.push({ + // latitude + key: el => el.geometryfinal?.coordinates?.[1], + type: Float32Array + }); + + // Add raw inline, crossline errors relative to preplot + values.push({ + // Crossline + key: el => el.errorfinal?.coordinates?.[0] * 10, + type: Int16Array + }); + values.push({ + // Inline + key: el => el.errorfinal?.coordinates?.[1] * 10, + type: Int16Array + }); + + // Add raw inline, crossline errors relative to raw + values.push({ + // Crossline + key: el => (el.errorfinal?.coordinates?.[0] - el.errorraw?.coordinates?.[0]) * 10, + type: Int16Array + }); + values.push({ + // Inline + key: el => (el.errorfinal?.coordinates?.[1] - el.errorraw?.coordinates?.[1]) * 10, + type: Int16Array + }); + return encode.sequential(json, el => el.sequence, el => el.point, deltas, values, type) } }