drone-path 0.12.1 → 1.0.0-rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/README.md +20 -74
  2. package/THIRD-PARTY-NOTICES.md +3 -82
  3. package/bin/drone-path.mjs +0 -0
  4. package/dist/cli.d.ts +14 -0
  5. package/dist/cli.js +7 -7
  6. package/dist/version.d.ts +1 -0
  7. package/package.json +21 -68
  8. package/CHANGELOG.md +0 -336
  9. package/app/ipc.d.mts +0 -43
  10. package/app/ipc.mjs +0 -216
  11. package/app/main.mjs +0 -356
  12. package/app/preload.cjs +0 -34
  13. package/app/update-policy.d.mts +0 -6
  14. package/app/update-policy.mjs +0 -6
  15. package/app/update.d.mts +0 -10
  16. package/app/update.mjs +0 -54
  17. package/dist/appassets.js +0 -35
  18. package/dist/apppaths.js +0 -20
  19. package/dist/appsession.js +0 -121
  20. package/dist/appstate.js +0 -94
  21. package/dist/assets.js +0 -60
  22. package/dist/buildinfo.js +0 -64
  23. package/dist/cammeta-decode.js +0 -237
  24. package/dist/cammeta.js +0 -92
  25. package/dist/changeset-gate.js +0 -39
  26. package/dist/config.js +0 -631
  27. package/dist/configfile.js +0 -86
  28. package/dist/decimate.js +0 -84
  29. package/dist/errors.js +0 -34
  30. package/dist/exec-tool.js +0 -13
  31. package/dist/exportjob.js +0 -90
  32. package/dist/ffmpeg-tools.js +0 -56
  33. package/dist/ffmpeg.js +0 -98
  34. package/dist/frametime.js +0 -32
  35. package/dist/geo.js +0 -60
  36. package/dist/logging.js +0 -1
  37. package/dist/manual/anchors.js +0 -17
  38. package/dist/manual/build.js +0 -67
  39. package/dist/manual/cliref.js +0 -34
  40. package/dist/manual/links.js +0 -59
  41. package/dist/manual/markdown.js +0 -98
  42. package/dist/manual/model.js +0 -1
  43. package/dist/manual/module.js +0 -5
  44. package/dist/manual/nav.js +0 -11
  45. package/dist/manual/reference.js +0 -18
  46. package/dist/paths.js +0 -16
  47. package/dist/pipeline.js +0 -402
  48. package/dist/plan.js +0 -106
  49. package/dist/png.js +0 -32
  50. package/dist/protobuf-wire.js +0 -102
  51. package/dist/range.js +0 -50
  52. package/dist/recordings.js +0 -55
  53. package/dist/render-page.js +0 -85
  54. package/dist/render.js +0 -268
  55. package/dist/renderer/boot.js +0 -7
  56. package/dist/renderer/dom.js +0 -177
  57. package/dist/renderer/framemath.js +0 -30
  58. package/dist/renderer/scene.js +0 -385
  59. package/dist/renderer/theme.js +0 -82
  60. package/dist/renderer/tilesources.js +0 -38
  61. package/dist/renderer/trail.js +0 -42
  62. package/dist/restyle.js +0 -16
  63. package/dist/serve.js +0 -27
  64. package/dist/srt.js +0 -98
  65. package/dist/telemetry-json-schema.js +0 -18
  66. package/dist/telemetry-json.js +0 -126
  67. package/dist/telemetry-math.js +0 -267
  68. package/dist/telemetry-summary.js +0 -19
  69. package/dist/telemetry.js +0 -95
  70. package/dist/tilecache.js +0 -21
  71. package/dist/tiles.js +0 -155
  72. package/dist/track-format.js +0 -13
  73. package/dist/track-geojson.js +0 -44
  74. package/dist/track-gpx.js +0 -34
  75. package/dist/track-kml.js +0 -47
  76. package/dist/track-kmz.js +0 -68
  77. package/dist/track-write.js +0 -41
  78. package/dist/track.js +0 -79
@@ -1,18 +0,0 @@
1
- import fs from 'node:fs';
2
- import path from 'node:path';
3
- import { fileURLToPath } from 'node:url';
4
- import { runToolMain } from './errors.js';
5
- import { generateTelemetryJsonSchema } from './telemetry-json.js';
6
- export function writeTelemetryJsonSchema(file) {
7
- fs.mkdirSync(path.dirname(file), { recursive: true });
8
- fs.writeFileSync(file, generateTelemetryJsonSchema());
9
- }
10
- function main() {
11
- const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
12
- const file = path.join(root, 'docs', 'telemetry-json.schema.json');
13
- writeTelemetryJsonSchema(file);
14
- process.stderr.write(`[drone-path] docs: wrote ${path.relative(root, file)}\n`);
15
- }
16
- if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
17
- void runToolMain(main);
18
- }
@@ -1,126 +0,0 @@
1
- import fs from 'node:fs';
2
- import path from 'node:path';
3
- import { z } from 'zod';
4
- import { resolveFrameRange } from './config.js';
5
- export const TELEMETRY_JSON_SCHEMA_VERSION = 1;
6
- const GimbalDeviceSchema = z.strictObject({
7
- id: z.int(),
8
- type: z.int(),
9
- subType: z.int(),
10
- name: z.string(),
11
- frequency: z.number(),
12
- });
13
- const TelemetryRecordSchema = z.strictObject({
14
- frame: z.int(),
15
- gimbalDeviceTimestampMs: z.int().optional(),
16
- lat: z.number().optional(),
17
- lng: z.number().optional(),
18
- altAbs: z.number().optional(),
19
- altRel: z.number().optional(),
20
- gpsAltMm: z.int().optional(),
21
- pitchDeg: z.number().optional(),
22
- rollDeg: z.number().optional(),
23
- yawDeg: z.number().optional(),
24
- gimbalPitchDeg: z.number().optional(),
25
- gimbalRollDeg: z.number().optional(),
26
- gimbalYawDeg: z.number().optional(),
27
- headingDeg: z.number(),
28
- headingSource: z.enum(['yaw', 'cog']),
29
- iso: z.int().optional(),
30
- shutterTime: z.number().optional(),
31
- whiteBalanceCctK: z.int().optional(),
32
- fNumber: z.number().optional(),
33
- });
34
- export const TelemetryDocumentSchema = z.strictObject({
35
- schemaVersion: z.literal(TELEMETRY_JSON_SCHEMA_VERSION),
36
- protoFile: z.string().optional(),
37
- source: z.enum(['srt', 'cammeta']),
38
- headingMode: z.enum(['yaw', 'cog']),
39
- frameCount: z.int(),
40
- gimbalDevice: GimbalDeviceSchema.optional(),
41
- frames: z.array(TelemetryRecordSchema),
42
- });
43
- // The Record annotation makes a schema field without an entry here a compile
44
- // error instead of a silently dropped record key.
45
- const TELEMETRY_VALUES = {
46
- gimbalDeviceTimestampMs: { position: 'before-heading', integer: true },
47
- lat: { position: 'before-heading' },
48
- lng: { position: 'before-heading' },
49
- altAbs: { position: 'before-heading' },
50
- altRel: { position: 'before-heading' },
51
- gpsAltMm: { position: 'before-heading', integer: true },
52
- pitchDeg: { position: 'before-heading' },
53
- rollDeg: { position: 'before-heading' },
54
- yawDeg: { position: 'before-heading' },
55
- gimbalPitchDeg: { position: 'before-heading' },
56
- gimbalRollDeg: { position: 'before-heading' },
57
- gimbalYawDeg: { position: 'before-heading' },
58
- iso: { position: 'exposure', integer: true },
59
- shutterTime: { position: 'exposure' },
60
- whiteBalanceCctK: { position: 'exposure', integer: true },
61
- fNumber: { position: 'exposure' },
62
- };
63
- function valueKeys(position) {
64
- return Object.keys(TELEMETRY_VALUES).filter((key) => TELEMETRY_VALUES[key].position === position);
65
- }
66
- const BEFORE_HEADING_KEYS = valueKeys('before-heading');
67
- const EXPOSURE_KEYS = valueKeys('exposure');
68
- function copyValue(record, key, value) {
69
- if (value === null || value === undefined)
70
- return;
71
- record[key] = TELEMETRY_VALUES[key].integer ? Math.round(value) : value;
72
- }
73
- function buildRecord(input, index) {
74
- const row = input.frames[index] ?? {};
75
- const record = {
76
- frame: (input.frameStart ?? 0) + index,
77
- };
78
- for (const key of BEFORE_HEADING_KEYS)
79
- copyValue(record, key, row[key]);
80
- record.headingDeg = input.headingDeg[index];
81
- record.headingSource = input.headingMode;
82
- for (const key of EXPOSURE_KEYS)
83
- copyValue(record, key, row[key]);
84
- return record;
85
- }
86
- export function segmentTelemetryInput(input, range) {
87
- const segment = resolveFrameRange(range, input.frameCount);
88
- if (!segment)
89
- return input;
90
- return {
91
- ...input,
92
- frameCount: segment.end - segment.start + 1,
93
- frames: input.frames.slice(segment.start, segment.end + 1),
94
- headingDeg: input.headingDeg.slice(segment.start, segment.end + 1),
95
- frameStart: segment.start,
96
- };
97
- }
98
- export function buildTelemetryDocument(input) {
99
- if (input.headingDeg.length !== input.frameCount) {
100
- throw new Error('telemetry JSON: heading count does not match the frame count');
101
- }
102
- const frames = [];
103
- for (let index = 0; index < input.frameCount; index++) {
104
- frames.push(buildRecord(input, index));
105
- }
106
- return {
107
- schemaVersion: TELEMETRY_JSON_SCHEMA_VERSION,
108
- ...(input.protoFile ? { protoFile: input.protoFile } : {}),
109
- source: input.source,
110
- headingMode: input.headingMode,
111
- frameCount: input.frameCount,
112
- ...(input.gimbalDevice ? { gimbalDevice: input.gimbalDevice } : {}),
113
- frames,
114
- };
115
- }
116
- export function serializeTelemetryDocument(doc) {
117
- return `${JSON.stringify(doc, null, 2)}\n`;
118
- }
119
- export function writeTelemetryDocument(file, input) {
120
- const doc = buildTelemetryDocument(input);
121
- fs.mkdirSync(path.dirname(file), { recursive: true });
122
- fs.writeFileSync(file, serializeTelemetryDocument(doc));
123
- }
124
- export function generateTelemetryJsonSchema() {
125
- return `${JSON.stringify(z.toJSONSchema(TelemetryDocumentSchema), null, 2)}\n`;
126
- }
@@ -1,267 +0,0 @@
1
- import { bearingDeg, circularMeanDeg, haversineM } from './geo.js';
2
- import { timeAt } from './frametime.js';
3
- const MAX_INTERPOLATION_GAP_S = 3;
4
- const SPEED_SMOOTHING_SPAN = 5;
5
- const HEADING_MIN_MOVE_M = 1.5;
6
- const HEADING_HALF_WINDOW_S = 0.35;
7
- const HEADING_MAX_BASELINE_S = 3;
8
- const HEADING_MIN_SPEED_MPS = 0.5;
9
- const HEADING_SMOOTHING_SPAN = 4;
10
- function isFixSample(sample) {
11
- return sample.fix !== null;
12
- }
13
- function fixRefs(samples) {
14
- const refs = [];
15
- samples.forEach((sample, index) => {
16
- if (isFixSample(sample))
17
- refs.push({ ...sample, index });
18
- });
19
- return refs;
20
- }
21
- function altitudeOf(sample) {
22
- return sample.relAlt ?? sample.absAlt ?? null;
23
- }
24
- function positionOfSample(sample) {
25
- return { fix: sample.fix, alt: altitudeOf(sample) };
26
- }
27
- function interpolateAltitude(a, b, fraction) {
28
- const altA = altitudeOf(a);
29
- const altB = altitudeOf(b);
30
- if (altA === null)
31
- return altB;
32
- if (altB === null)
33
- return altA;
34
- return altA + (altB - altA) * fraction;
35
- }
36
- function nearestFix(samples, idx, direction) {
37
- let i = idx;
38
- while (i >= 0 && i < samples.length) {
39
- const sample = samples[i];
40
- if (isFixSample(sample))
41
- return sample;
42
- i += direction;
43
- }
44
- return null;
45
- }
46
- function positionAt(samples, t, maxGapSec = MAX_INTERPOLATION_GAP_S) {
47
- const n = samples.length;
48
- if (n === 0)
49
- return { fix: null, alt: null };
50
- if (t <= samples[0].tSec)
51
- return positionOfSample(samples[0]);
52
- if (t >= samples[n - 1].tSec)
53
- return positionOfSample(samples[n - 1]);
54
- const lo = sampleIndexBefore(samples, t);
55
- const hi = lo + 1;
56
- const a = nearestFix(samples, lo, -1);
57
- const b = nearestFix(samples, hi, 1);
58
- if (a !== null && b === null)
59
- return positionOfSample(a);
60
- if (a === null && b !== null)
61
- return positionOfSample(b);
62
- if (a === null || b === null)
63
- return { fix: null, alt: null };
64
- const dt = b.tSec - a.tSec;
65
- const gapOk = dt > 0 && dt <= maxGapSec;
66
- const fraction = gapOk ? (t - a.tSec) / dt : 0;
67
- return {
68
- fix: {
69
- lat: a.fix.lat + (b.fix.lat - a.fix.lat) * fraction,
70
- lon: a.fix.lon + (b.fix.lon - a.fix.lon) * fraction,
71
- },
72
- alt: interpolateAltitude(a, b, fraction),
73
- };
74
- }
75
- function sampleIndexBefore(samples, t) {
76
- let lo = 0;
77
- let hi = samples.length - 1;
78
- while (hi - lo > 1) {
79
- const mid = (lo + hi) >> 1;
80
- if (samples[mid].tSec <= t)
81
- lo = mid;
82
- else
83
- hi = mid;
84
- }
85
- return lo;
86
- }
87
- function nearestSampleIndex(samples, t) {
88
- const lo = sampleIndexBefore(samples, t);
89
- const hi = Math.min(lo + 1, samples.length - 1);
90
- return t - samples[lo].tSec <= samples[hi].tSec - t ? lo : hi;
91
- }
92
- function computeTrackStats(fixes) {
93
- const bbox = {
94
- minLat: Infinity,
95
- maxLat: -Infinity,
96
- minLon: Infinity,
97
- maxLon: -Infinity,
98
- };
99
- let trackDistanceM = 0;
100
- let prev = null;
101
- for (const { fix } of fixes) {
102
- bbox.minLat = Math.min(bbox.minLat, fix.lat);
103
- bbox.maxLat = Math.max(bbox.maxLat, fix.lat);
104
- bbox.minLon = Math.min(bbox.minLon, fix.lon);
105
- bbox.maxLon = Math.max(bbox.maxLon, fix.lon);
106
- if (prev !== null) {
107
- trackDistanceM += haversineM(prev, fix);
108
- }
109
- prev = fix;
110
- }
111
- return { bbox, trackDistanceM };
112
- }
113
- function computeSpeedBySample(sampleCount, fixes) {
114
- const rawSpeed = new Array(fixes.length).fill(null);
115
- for (let k = 1; k < fixes.length - 1; k++) {
116
- const dt = fixes[k + 1].tSec - fixes[k - 1].tSec;
117
- if (dt > 0.001) {
118
- rawSpeed[k] = haversineM(fixes[k - 1].fix, fixes[k + 1].fix) / dt;
119
- }
120
- }
121
- rawSpeed[0] = rawSpeed[1] ?? 0;
122
- rawSpeed[fixes.length - 1] = rawSpeed[fixes.length - 2] ?? 0;
123
- const speedBySample = new Array(sampleCount).fill(0);
124
- for (let k = 0; k < fixes.length; k++) {
125
- const lo = Math.max(0, k - SPEED_SMOOTHING_SPAN);
126
- const hi = Math.min(fixes.length - 1, k + SPEED_SMOOTHING_SPAN);
127
- let sum = 0;
128
- let count = 0;
129
- for (let j = lo; j <= hi; j++) {
130
- const v = rawSpeed[j];
131
- if (v !== null) {
132
- sum += v;
133
- count++;
134
- }
135
- }
136
- speedBySample[fixes[k].index] = count ? sum / count : 0;
137
- }
138
- return speedBySample;
139
- }
140
- function computeHeadingBySample(samples, fixes, speedBySample) {
141
- const hasYaw = samples.some((sample) => sample.yawDeg !== null);
142
- const headingMode = hasYaw ? 'yaw' : 'cog';
143
- const rawHeading = new Array(fixes.length).fill(null);
144
- if (hasYaw) {
145
- fillYawHeadings(fixes, rawHeading);
146
- }
147
- else {
148
- fillCourseOverGroundHeadings(fixes, speedBySample, rawHeading);
149
- }
150
- fillHeadingGaps(rawHeading);
151
- const defaultHeading = rawHeading[0] ?? firstKnownHeading(rawHeading) ?? 0;
152
- const headingBySample = new Array(samples.length).fill(defaultHeading);
153
- for (let k = 0; k < fixes.length; k++) {
154
- const lo = Math.max(0, k - HEADING_SMOOTHING_SPAN);
155
- const hi = Math.min(fixes.length - 1, k + HEADING_SMOOTHING_SPAN);
156
- const window = [];
157
- for (let j = lo; j <= hi; j++) {
158
- window.push(rawHeading[j] ?? defaultHeading);
159
- }
160
- headingBySample[fixes[k].index] = circularMeanDeg(window);
161
- }
162
- return { headingBySample, headingMode };
163
- }
164
- function fillYawHeadings(fixes, rawHeading) {
165
- for (let k = 0; k < fixes.length; k++) {
166
- const yaw = fixes[k].yawDeg;
167
- if (yaw !== null && Number.isFinite(yaw))
168
- rawHeading[k] = ((yaw % 360) + 360) % 360;
169
- }
170
- }
171
- function fillCourseOverGroundHeadings(fixes, speedBySample, rawHeading) {
172
- for (let k = 0; k < fixes.length; k++) {
173
- const tk = fixes[k].tSec;
174
- if ((speedBySample[fixes[k].index] ?? 0) < HEADING_MIN_SPEED_MPS)
175
- continue;
176
- let ka = k;
177
- let kb = k;
178
- let displacement = 0;
179
- for (const half of [HEADING_HALF_WINDOW_S, HEADING_MAX_BASELINE_S]) {
180
- ka = k;
181
- kb = k;
182
- while (ka > 0 && fixes[ka].tSec > tk - half)
183
- ka--;
184
- while (kb < fixes.length - 1 && fixes[kb].tSec < tk + half)
185
- kb++;
186
- displacement = haversineM(fixes[ka].fix, fixes[kb].fix);
187
- if (displacement >= HEADING_MIN_MOVE_M)
188
- break;
189
- }
190
- if (displacement >= HEADING_MIN_MOVE_M) {
191
- rawHeading[k] = bearingDeg(fixes[ka].fix, fixes[kb].fix);
192
- }
193
- }
194
- }
195
- function fillHeadingGaps(rawHeading) {
196
- let last = null;
197
- for (let k = 0; k < rawHeading.length; k++) {
198
- if (rawHeading[k] !== null)
199
- last = rawHeading[k];
200
- else
201
- rawHeading[k] = last;
202
- }
203
- const fallback = firstKnownHeading(rawHeading) ?? 0;
204
- for (let k = 0; k < rawHeading.length; k++) {
205
- rawHeading[k] ??= fallback;
206
- }
207
- }
208
- function firstKnownHeading(rawHeading) {
209
- for (const heading of rawHeading) {
210
- if (heading !== null)
211
- return heading;
212
- }
213
- return null;
214
- }
215
- function buildFrameData(samples, frames, fpsValue, speedBySample, headingBySample) {
216
- const frameData = [];
217
- for (let frame = 0; frame < frames; frame++) {
218
- const t = timeAt(frame, fpsValue);
219
- const pos = positionAt(samples, t);
220
- const si = nearestSampleIndex(samples, t);
221
- frameData.push({
222
- fix: pos.fix,
223
- alt: pos.alt,
224
- speed: Math.round(speedBySample[si] * 10) / 10,
225
- headingDeg: Math.round(headingBySample[si] * 10) / 10,
226
- });
227
- }
228
- return frameData;
229
- }
230
- function bridgeMissingFramePositions(frameData) {
231
- const first = frameData.find((d) => d.fix !== null);
232
- const last = [...frameData].reverse().find((d) => d.fix !== null);
233
- if (!first || !last)
234
- return;
235
- let lead = 0;
236
- while (lead < frameData.length && frameData[lead].fix === null) {
237
- frameData[lead].fix = first.fix;
238
- lead++;
239
- }
240
- let trail = frameData.length - 1;
241
- while (trail >= lead && frameData[trail].fix === null) {
242
- frameData[trail].fix = last.fix;
243
- trail--;
244
- }
245
- }
246
- export function computeTelemetry(loaded, timing) {
247
- const { samples, source, method, noLock } = loaded;
248
- const fixes = fixRefs(samples);
249
- if (fixes.length < 2)
250
- throw new Error('telemetry has fewer than 2 GPS fixes');
251
- const { bbox, trackDistanceM } = computeTrackStats(fixes);
252
- const speedBySample = computeSpeedBySample(samples.length, fixes);
253
- const { headingBySample, headingMode } = computeHeadingBySample(samples, fixes, speedBySample);
254
- const frameData = buildFrameData(samples, timing.frames, timing.fpsValue, speedBySample, headingBySample);
255
- bridgeMissingFramePositions(frameData);
256
- return {
257
- source,
258
- method,
259
- headingMode,
260
- sampleCount: samples.length,
261
- fixCount: fixes.length,
262
- noLock,
263
- frames: frameData,
264
- bbox,
265
- trackDistanceM,
266
- };
267
- }
@@ -1,19 +0,0 @@
1
- export function telemetrySummary(tel) {
2
- return {
3
- source: tel.source,
4
- method: tel.method,
5
- headingMode: tel.headingMode,
6
- fixCount: tel.fixCount,
7
- noLock: tel.noLock,
8
- trackDistanceM: Math.round(tel.trackDistanceM),
9
- };
10
- }
11
- export function fixCountLabel(fixCount) {
12
- return `${fixCount} fixes`;
13
- }
14
- export function noLockCountLabel(noLock) {
15
- return `${noLock} no-lock cues`;
16
- }
17
- export function trackDistanceLabel(trackDistanceM) {
18
- return `${trackDistanceM} m`;
19
- }
package/dist/telemetry.js DELETED
@@ -1,95 +0,0 @@
1
- import { ERR_NO_TELEMETRY } from './errors.js';
2
- import { parseSrt } from './srt.js';
3
- import { parseCamMeta } from './cammeta.js';
4
- import { findSrtSidecar } from './recordings.js';
5
- import { computeTelemetry } from './telemetry-math.js';
6
- function srtCueToFrameValues(cue) {
7
- return {
8
- lat: cue.fix?.lat ?? null,
9
- lng: cue.fix?.lon ?? null,
10
- altAbs: cue.absAlt,
11
- altRel: cue.relAlt,
12
- iso: cue.iso,
13
- shutterTime: cue.shutterTime,
14
- whiteBalanceCctK: cue.whiteBalanceCctK,
15
- fNumber: cue.fNumber,
16
- };
17
- }
18
- function camSampleToFrameValues(sample) {
19
- return {
20
- gimbalDeviceTimestampMs: sample.gimbalDeviceTimestampMs,
21
- lat: sample.fix?.lat ?? null,
22
- lng: sample.fix?.lon ?? null,
23
- altAbs: sample.absAlt,
24
- altRel: sample.relAlt,
25
- gpsAltMm: sample.gpsAltMm,
26
- pitchDeg: sample.pitchDeg,
27
- rollDeg: sample.rollDeg,
28
- yawDeg: sample.yawDeg,
29
- gimbalPitchDeg: sample.gimbalPitchDeg,
30
- gimbalRollDeg: sample.gimbalRollDeg,
31
- gimbalYawDeg: sample.gimbalYawDeg,
32
- iso: sample.iso,
33
- whiteBalanceCctK: sample.whiteBalanceCctK,
34
- };
35
- }
36
- async function loadSamples(tools, videoPath, durationSec) {
37
- const cam = await parseCamMeta(tools, videoPath, durationSec, { keepAll: true });
38
- if (cam) {
39
- const fixSamples = cam.samples.filter((sample) => sample.fix !== null);
40
- if (fixSamples.length === 0) {
41
- throw new Error(`${ERR_NO_TELEMETRY}the CAM meta (DVTM) stream has no GPS fix pairs; ` +
42
- 'the .SRT sidecar is only consulted when no CAM meta stream is present');
43
- }
44
- return {
45
- samples: fixSamples,
46
- source: 'cammeta',
47
- method: cam.method,
48
- noLock: cam.noLock,
49
- frameValues: cam.method === 'dvtm-packets' ? cam.samples.map(camSampleToFrameValues) : [],
50
- trackValues: cam.samples.map((sample) => ({
51
- ...camSampleToFrameValues(sample),
52
- tSec: sample.tSec,
53
- })),
54
- protoFile: cam.protoFile,
55
- gimbalDevice: cam.gimbalDevice,
56
- };
57
- }
58
- const srtPath = findSrtSidecar(videoPath);
59
- if (srtPath) {
60
- const parsed = await parseSrt(srtPath);
61
- if (parsed.count === 0)
62
- throw new Error(`SRT sidecar has no cues: ${srtPath}`);
63
- return {
64
- samples: parsed.cues.map((cue) => ({
65
- tSec: cue.tSec,
66
- fix: cue.fix,
67
- relAlt: cue.relAlt,
68
- absAlt: cue.absAlt,
69
- yawDeg: null,
70
- })),
71
- source: 'srt',
72
- method: 'srt-cues',
73
- noLock: parsed.noLock,
74
- frameValues: parsed.cues.map(srtCueToFrameValues),
75
- trackValues: parsed.cues.map((cue) => ({
76
- ...srtCueToFrameValues(cue),
77
- tSec: cue.tSec,
78
- })),
79
- protoFile: null,
80
- gimbalDevice: null,
81
- };
82
- }
83
- throw new Error(`${ERR_NO_TELEMETRY}no CAM meta (DVTM) stream and no .SRT sidecar`);
84
- }
85
- export async function loadTelemetry(videoPath, { frames, fpsValue, durationSec, tools, }) {
86
- const loaded = await loadSamples(tools, videoPath, durationSec);
87
- const { frameValues, trackValues, protoFile, gimbalDevice, ...samples } = loaded;
88
- return {
89
- telemetry: computeTelemetry(samples, { frames, fpsValue }),
90
- frameValues,
91
- trackValues,
92
- protoFile,
93
- gimbalDevice,
94
- };
95
- }
package/dist/tilecache.js DELETED
@@ -1,21 +0,0 @@
1
- import path from 'node:path';
2
- import { TILE_SOURCES } from './renderer/tilesources.js';
3
- function cacheKeyFor(style) {
4
- return TILE_SOURCES[style].cacheKey;
5
- }
6
- export function parseTilePathname(pathname) {
7
- const m = /^\/tiles\/([a-z0-9_-]+)\/(\d+)\/(\d+)\/(\d+)\.png$/.exec(pathname);
8
- if (!m)
9
- return null;
10
- const style = Object.hasOwn(TILE_SOURCES, m[1]) ? m[1] : null;
11
- return style === null
12
- ? null
13
- : { style, tile: { z: Number(m[2]), x: Number(m[3]), y: Number(m[4]) } };
14
- }
15
- export function tilePaths(cacheDir, style, tile) {
16
- const dir = path.join(cacheDir, cacheKeyFor(style), String(tile.z), String(tile.x));
17
- return {
18
- file: path.join(dir, `${tile.y}.png`),
19
- placeholder: path.join(dir, `${tile.y}.placeholder.png`),
20
- };
21
- }