drone-path 0.8.0 → 0.9.0
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.
- package/CHANGELOG.md +39 -0
- package/README.md +19 -26
- package/THIRD-PARTY-NOTICES.md +7 -0
- package/app/main.mjs +82 -28
- package/app/preload.cjs +3 -0
- package/dist/appassets.js +2 -11
- package/dist/apppaths.js +2 -10
- package/dist/appsession.js +59 -25
- package/dist/appstate.js +0 -18
- package/dist/assets.js +0 -7
- package/dist/buildinfo.js +71 -0
- package/dist/cammeta.js +123 -84
- package/dist/changeset-gate.js +0 -7
- package/dist/cli.js +0 -15
- package/dist/config.js +40 -52
- package/dist/configfile.js +0 -8
- package/dist/decimate.js +2 -12
- package/dist/exportjob.js +3 -19
- package/dist/ff.js +0 -8
- package/dist/fftools.js +0 -10
- package/dist/geo.js +3 -13
- package/dist/inputs.js +0 -4
- package/dist/manual/anchors.js +1 -7
- package/dist/manual/build.js +0 -6
- package/dist/manual/cliref.js +0 -6
- package/dist/manual/links.js +0 -17
- package/dist/manual/markdown.js +2 -10
- package/dist/manual/model.js +0 -3
- package/dist/manual/module.js +0 -3
- package/dist/manual/nav.js +0 -2
- package/dist/manual/reference.js +1 -4
- package/dist/page.js +3 -26
- package/dist/paths.js +0 -12
- package/dist/plan.js +1 -18
- package/dist/png.js +0 -3
- package/dist/proto.js +4 -4
- package/dist/range.js +0 -8
- package/dist/render.js +3 -53
- package/dist/renderer/dom.js +0 -6
- package/dist/renderer/framemath.js +0 -4
- package/dist/renderer/leaflet.js +0 -4
- package/dist/renderer/scene.js +10 -34
- package/dist/renderer/theme.js +58 -10
- package/dist/renderer/tilesources.js +0 -10
- package/dist/renderer/trail.js +1 -12
- package/dist/restyle.js +1 -9
- package/dist/run.js +45 -46
- package/dist/serve.js +0 -13
- package/dist/srt.js +30 -8
- package/dist/summary.js +0 -3
- package/dist/telemetry-json-schema.js +23 -0
- package/dist/telemetry-json.js +107 -0
- package/dist/telemetry-math.js +9 -45
- package/dist/telemetry.js +52 -9
- package/dist/tilecache.js +0 -5
- package/dist/tiles.js +2 -32
- package/dist/tracing.js +3 -27
- package/package.json +15 -12
package/dist/renderer/theme.js
CHANGED
|
@@ -1,16 +1,53 @@
|
|
|
1
|
-
// Per-style renderer colors. One mapping so the generated page and the app's
|
|
2
|
-
// map island can never drift apart. The trail core is shared across styles so
|
|
3
|
-
// every flight trail wears the one palette accent (#147).
|
|
4
|
-
/** The flight-trail color: the palette accent, one color everywhere. */
|
|
5
1
|
const TRAIL_COLOR = '#e87f54';
|
|
2
|
+
function parseHexColor(hex) {
|
|
3
|
+
const m = /^#([0-9a-f]{6}|[0-9a-f]{8})$/i.exec(hex);
|
|
4
|
+
if (!m)
|
|
5
|
+
throw new Error(`invalid trail color: ${hex}`);
|
|
6
|
+
const [r, g, b, a] = [0, 2, 4, 6].map((i) => i < m[1].length ? Number.parseInt(m[1].slice(i, i + 2), 16) : 255);
|
|
7
|
+
return { r, g, b, a: a / 255 };
|
|
8
|
+
}
|
|
9
|
+
function rgba(c, alpha) {
|
|
10
|
+
return `rgba(${c.r},${c.g},${c.b},${Math.round(alpha * 10000) / 10000})`;
|
|
11
|
+
}
|
|
12
|
+
function luminance(c) {
|
|
13
|
+
const linear = (v) => {
|
|
14
|
+
const s = v / 255;
|
|
15
|
+
return s <= 0.03928 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4;
|
|
16
|
+
};
|
|
17
|
+
return 0.2126 * linear(c.r) + 0.7152 * linear(c.g) + 0.0722 * linear(c.b);
|
|
18
|
+
}
|
|
19
|
+
function mix(base, tint, amount) {
|
|
20
|
+
const k = (x, y) => Math.round(x + (y - x) * amount);
|
|
21
|
+
return { r: k(base.r, tint.r), g: k(base.g, tint.g), b: k(base.b, tint.b), a: 1 };
|
|
22
|
+
}
|
|
23
|
+
const CASING_ANCHORS = {
|
|
24
|
+
satellite: {
|
|
25
|
+
anchor: { r: 10, g: 14, b: 20, a: 1 },
|
|
26
|
+
opposite: { r: 255, g: 255, b: 255, a: 1 },
|
|
27
|
+
alpha: 0.9,
|
|
28
|
+
},
|
|
29
|
+
topo: {
|
|
30
|
+
anchor: { r: 255, g: 255, b: 255, a: 1 },
|
|
31
|
+
opposite: { r: 10, g: 14, b: 20, a: 1 },
|
|
32
|
+
alpha: 1,
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
const CONTRAST_FLIP = 0.18;
|
|
36
|
+
const CORE_TINT = 0.2;
|
|
37
|
+
function deriveCasing(style, core) {
|
|
38
|
+
const { anchor, opposite, alpha } = CASING_ANCHORS[style];
|
|
39
|
+
const base = Math.abs(luminance(core) - luminance(anchor)) < CONTRAST_FLIP ? opposite : anchor;
|
|
40
|
+
return rgba(mix(base, core, CORE_TINT), alpha);
|
|
41
|
+
}
|
|
42
|
+
const GLOW_ALPHA = { satellite: 0.32, topo: 0.26 };
|
|
6
43
|
function trailGlow(alpha) {
|
|
7
|
-
|
|
8
|
-
return `rgba(${r},${g},${b},${alpha})`;
|
|
44
|
+
return rgba(parseHexColor(TRAIL_COLOR), alpha);
|
|
9
45
|
}
|
|
10
46
|
const THEMES = {
|
|
11
47
|
satellite: {
|
|
12
48
|
core: TRAIL_COLOR,
|
|
13
|
-
|
|
49
|
+
trailCore: TRAIL_COLOR,
|
|
50
|
+
glow: trailGlow(GLOW_ALPHA.satellite),
|
|
14
51
|
casing: 'rgba(10,14,20,0.9)',
|
|
15
52
|
ghost: '#ffffff',
|
|
16
53
|
ghostOpacity: 0.85,
|
|
@@ -20,7 +57,8 @@ const THEMES = {
|
|
|
20
57
|
},
|
|
21
58
|
topo: {
|
|
22
59
|
core: TRAIL_COLOR,
|
|
23
|
-
|
|
60
|
+
trailCore: TRAIL_COLOR,
|
|
61
|
+
glow: trailGlow(GLOW_ALPHA.topo),
|
|
24
62
|
casing: '#ffffff',
|
|
25
63
|
ghost: '#6b6252',
|
|
26
64
|
ghostOpacity: 0.7,
|
|
@@ -29,6 +67,16 @@ const THEMES = {
|
|
|
29
67
|
vignette: 0.06,
|
|
30
68
|
},
|
|
31
69
|
};
|
|
32
|
-
export function themeFor(style) {
|
|
33
|
-
|
|
70
|
+
export function themeFor(style, trailColor = null) {
|
|
71
|
+
const base = THEMES[style];
|
|
72
|
+
if (trailColor === null)
|
|
73
|
+
return base;
|
|
74
|
+
const core = parseHexColor(trailColor);
|
|
75
|
+
return {
|
|
76
|
+
...base,
|
|
77
|
+
core: rgba(core, 1),
|
|
78
|
+
trailCore: trailColor,
|
|
79
|
+
glow: rgba(core, GLOW_ALPHA[style] * core.a),
|
|
80
|
+
casing: deriveCasing(style, core),
|
|
81
|
+
};
|
|
34
82
|
}
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
// The tile-source vocabulary: where tiles come from and how they look. Pure
|
|
2
|
-
// data shared by the tile pipeline (Node) and the shared map renderer
|
|
3
|
-
// (browser); cache layout lives in tilecache.ts, download logic in tiles.ts.
|
|
4
|
-
// Lives inside renderer/ so the browser-served module graph stays within
|
|
5
|
-
// that directory.
|
|
6
1
|
export const TILE_SOURCES = {
|
|
7
2
|
// Esri World Imagery (free for non-commercial use, attribution required).
|
|
8
|
-
// Tiles are JPEG; the cache filename stays .png and browsers decode by
|
|
9
|
-
// content, which is fine for Leaflet <img> tiles.
|
|
10
3
|
satellite: {
|
|
11
4
|
cacheKey: 'esri-imagery',
|
|
12
5
|
url: 'https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}',
|
|
@@ -17,9 +10,6 @@ export const TILE_SOURCES = {
|
|
|
17
10
|
tileFilter: 'saturate(1.06) contrast(1.03)',
|
|
18
11
|
maxZoom: 19,
|
|
19
12
|
},
|
|
20
|
-
// OpenTopoMap: OSM topography with contour lines and shaded relief - rich
|
|
21
|
-
// detail in alpine terrain. Tiles are native to z17; Leaflet auto-scales
|
|
22
|
-
// them above that (maxNativeZoom), so the view zoom stays style-independent.
|
|
23
13
|
topo: {
|
|
24
14
|
cacheKey: 'opentopomap',
|
|
25
15
|
url: 'https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png',
|
package/dist/renderer/trail.js
CHANGED
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
// Trail growth state machine shared by the headless renderer and the app: at
|
|
2
|
-
// frame i the trail is the flown path so far - the decimated prefix before i
|
|
3
|
-
// plus the live tip at the frame's own position. The tip tracks the drone so
|
|
4
|
-
// the trail grows every frame (a prefix of decimated points alone stays empty
|
|
5
|
-
// for whole flights whenever the geometry collapses, #95), while the kept
|
|
6
|
-
// prefix stays bounded by the decimation budget. A changed frame pushes one
|
|
7
|
-
// setLatLngs per layer; repeated frames and empty tracks stay quiet.
|
|
8
|
-
// Largest k with trailFrame[k] <= i (trailFrame is strictly increasing):
|
|
9
|
-
// the textbook upper bound stepped back one; -1 when every point is later.
|
|
10
1
|
export function lastIndexAtOrBefore(trailFrame, i) {
|
|
11
2
|
let lo = 0;
|
|
12
3
|
let hi = trailFrame.length - 1;
|
|
@@ -31,8 +22,7 @@ export function createTrailController(trail, frames, layers) {
|
|
|
31
22
|
if (i === lastFrame)
|
|
32
23
|
return;
|
|
33
24
|
const tip = i >= 0 && i < frames.lat.length ? [frames.lat[i], frames.lon[i]] : null;
|
|
34
|
-
//
|
|
35
|
-
// exactly frame i would only duplicate it.
|
|
25
|
+
// A kept point at exactly frame i would duplicate the tip's position.
|
|
36
26
|
let end = lastIndexAtOrBefore(trail.frame, i);
|
|
37
27
|
if (tip !== null && trail.frame[end] === i)
|
|
38
28
|
end -= 1;
|
|
@@ -42,7 +32,6 @@ export function createTrailController(trail, frames, layers) {
|
|
|
42
32
|
if (tip !== null)
|
|
43
33
|
points.push(tip);
|
|
44
34
|
lastFrame = i;
|
|
45
|
-
// Fresh layers already hold an empty path; only clear what was drawn.
|
|
46
35
|
if (points.length === 0 && !drawn)
|
|
47
36
|
return;
|
|
48
37
|
drawn = points.length > 0;
|
package/dist/restyle.js
CHANGED
|
@@ -1,13 +1,5 @@
|
|
|
1
|
-
// Settings -> scene mapping for the app's live restyle. It runs the very
|
|
2
|
-
// planning the pipeline runs (page.planPageOpts over the telemetry's fix
|
|
3
|
-
// bbox), so a preview and an export from the same settings agree frame for
|
|
4
|
-
// frame. Pure (no DOM, no I/O): the browser UI and unit tests drive it
|
|
5
|
-
// directly.
|
|
6
1
|
import { buildSceneData, planPageOpts } from './page.js';
|
|
7
|
-
export function restyleSceneData(prev, config, meta,
|
|
8
|
-
// The output size to plan at: the export preview plans at the size the
|
|
9
|
-
// pipeline will render, while the player keeps the prepared scene's own.
|
|
10
|
-
size = { width: prev.width, height: prev.height }) {
|
|
2
|
+
export function restyleSceneData(prev, config, meta, size = { width: prev.width, height: prev.height }) {
|
|
11
3
|
const planned = planPageOpts({
|
|
12
4
|
bbox: meta.bbox,
|
|
13
5
|
width: size.width,
|
package/dist/run.js
CHANGED
|
@@ -6,6 +6,7 @@ import { resolveFfTools } from './fftools.js';
|
|
|
6
6
|
import { videoBaseName } from './inputs.js';
|
|
7
7
|
import { pathKey, uniquePath } from './paths.js';
|
|
8
8
|
import { loadTelemetry } from './telemetry.js';
|
|
9
|
+
import { buildTelemetryDocument, serializeTelemetryDocument, } from './telemetry-json.js';
|
|
9
10
|
import { prefetchTiles } from './tiles.js';
|
|
10
11
|
import { planIntroOutroFrames, planView } from './plan.js';
|
|
11
12
|
import { buildPageHtml, planPageOpts } from './page.js';
|
|
@@ -13,9 +14,6 @@ import { renderVideo } from './render.js';
|
|
|
13
14
|
import { assertValidFrameRange, effectiveZoomOut, hasAltitude, resolveHudSpec, } from './config.js';
|
|
14
15
|
import { fixesLabel, noLockCuesLabel, telemetrySummary, trackDistanceLabel, } from './summary.js';
|
|
15
16
|
import { NOOP_TRACER, stage } from './tracing.js';
|
|
16
|
-
// The preparation stages in execution order. The loading-bar step numbers
|
|
17
|
-
// derive from this sequence, so adding or reordering a stage cannot silently
|
|
18
|
-
// skew the bar (see PrepareProgress).
|
|
19
17
|
const PREPARE_STAGE_ORDER = ['probe', 'telemetry', 'plan'];
|
|
20
18
|
export function outputPathFor(videoPath, config) {
|
|
21
19
|
const base = videoBaseName(videoPath);
|
|
@@ -40,7 +38,6 @@ export function planOutputs(videos, config) {
|
|
|
40
38
|
return { out, plain };
|
|
41
39
|
});
|
|
42
40
|
}
|
|
43
|
-
// HUD sanity: drop chips whose data does not exist for this source.
|
|
44
41
|
function resolveHud(config, tel, log) {
|
|
45
42
|
const hud = resolveHudSpec(config.hud, hasAltitude(tel.frames.map((f) => f.alt)));
|
|
46
43
|
if (config.hud.alt && !hud.alt) {
|
|
@@ -78,8 +75,6 @@ function describeView(config, overview, tilesLabel) {
|
|
|
78
75
|
function mtimeOf(outPath) {
|
|
79
76
|
return fs.existsSync(outPath) ? fs.statSync(outPath).mtimeMs : null;
|
|
80
77
|
}
|
|
81
|
-
// Never leave a broken or partial render behind: on any failure the output
|
|
82
|
-
// this run wrote is deleted (a pre-existing file we did not touch stays).
|
|
83
78
|
function removePartialOutput(outPath, mtimeBefore, log) {
|
|
84
79
|
const mtimeNow = mtimeOf(outPath);
|
|
85
80
|
if (mtimeNow !== null && (mtimeBefore === null || mtimeNow !== mtimeBefore)) {
|
|
@@ -104,11 +99,6 @@ const realDeps = {
|
|
|
104
99
|
verifyOutput,
|
|
105
100
|
outputMatchesSource,
|
|
106
101
|
};
|
|
107
|
-
// A caller overrides only the dep its composition owns (the app shares its
|
|
108
|
-
// tile queue with every lane); nullish overrides - possible from untyped
|
|
109
|
-
// shell code - count as omitted, so no real dep is ever dropped. The bulk
|
|
110
|
-
// warm carries no cacheDir (providers own their cache), so the default
|
|
111
|
-
// binds the run's own cache here, where the run's config is in hand.
|
|
112
102
|
function resolveDeps(overrides, tileCache) {
|
|
113
103
|
return {
|
|
114
104
|
probeVideo: overrides?.probeVideo ?? realDeps.probeVideo,
|
|
@@ -120,9 +110,7 @@ function resolveDeps(overrides, tileCache) {
|
|
|
120
110
|
outputMatchesSource: overrides?.outputMatchesSource ?? realDeps.outputMatchesSource,
|
|
121
111
|
};
|
|
122
112
|
}
|
|
123
|
-
|
|
124
|
-
// keeps the render and the verification honest about what the source has.
|
|
125
|
-
function resolveRange(range, frames) {
|
|
113
|
+
export function resolveRange(range, frames) {
|
|
126
114
|
if (!range)
|
|
127
115
|
return null;
|
|
128
116
|
assertValidFrameRange(range);
|
|
@@ -155,27 +143,34 @@ async function probeStage(env) {
|
|
|
155
143
|
async function telemetryStage(env, probe) {
|
|
156
144
|
const { videoPath, config, log, tracer, parent, deps, tools, report } = env;
|
|
157
145
|
report('telemetry');
|
|
158
|
-
const
|
|
159
|
-
const
|
|
146
|
+
const loaded = await stage(tracer, 'telemetry.load', parent, {}, async (span) => {
|
|
147
|
+
const result = await deps.loadTelemetry(videoPath, {
|
|
160
148
|
frames: probe.frames,
|
|
161
149
|
fpsValue: probe.fps.value,
|
|
162
150
|
durationSec: probe.durationSec,
|
|
163
151
|
tools,
|
|
164
152
|
});
|
|
165
153
|
span.setAttributes({
|
|
166
|
-
'telemetry.source':
|
|
167
|
-
'telemetry.method':
|
|
168
|
-
'telemetry.fix.count':
|
|
169
|
-
'telemetry.noLock.count':
|
|
154
|
+
'telemetry.source': result.telemetry.source,
|
|
155
|
+
'telemetry.method': result.telemetry.method,
|
|
156
|
+
'telemetry.fix.count': result.telemetry.fixCount,
|
|
157
|
+
'telemetry.noLock.count': result.telemetry.noLock,
|
|
170
158
|
});
|
|
171
|
-
return
|
|
159
|
+
return result;
|
|
172
160
|
});
|
|
161
|
+
const tel = loaded.telemetry;
|
|
173
162
|
const summary = telemetrySummary(tel);
|
|
174
163
|
log(`telemetry: ${summary.source} (${summary.method}), ${fixesLabel(summary.fixes)}, ` +
|
|
175
164
|
`heading=${summary.headingMode}, track ${trackDistanceLabel(summary.trackDistanceM)}` +
|
|
176
165
|
(summary.noLock ? `, ${noLockCuesLabel(summary.noLock)}` : ''));
|
|
177
166
|
const hud = resolveHud(config, tel, log);
|
|
178
|
-
return {
|
|
167
|
+
return {
|
|
168
|
+
tel,
|
|
169
|
+
frameValues: loaded.frameValues,
|
|
170
|
+
protoFile: loaded.protoFile,
|
|
171
|
+
gimbalDevice: loaded.gimbalDevice,
|
|
172
|
+
hud,
|
|
173
|
+
};
|
|
179
174
|
}
|
|
180
175
|
async function viewPlanStage(env, tel) {
|
|
181
176
|
const { config, log, tracer, parent, report } = env;
|
|
@@ -192,9 +187,6 @@ async function viewPlanStage(env, tel) {
|
|
|
192
187
|
log(describeView(config, overview, config.style));
|
|
193
188
|
return overview;
|
|
194
189
|
}
|
|
195
|
-
// The render path's tile pre-warm: rendered frames must never fall back to
|
|
196
|
-
// placeholder tiles, so the whole plan settles before capture starts. The
|
|
197
|
-
// app's open flow skips this and lets the player fetch on demand.
|
|
198
190
|
async function tileWarmStage(deps, config, overview, log, tracer, parent) {
|
|
199
191
|
const tileStats = await stage(tracer, 'tiles.prefetch', parent, {}, async (span) => {
|
|
200
192
|
const stats = await deps.prefetchTiles({
|
|
@@ -215,9 +207,6 @@ async function tileWarmStage(deps, config, overview, log, tracer, parent) {
|
|
|
215
207
|
}
|
|
216
208
|
return tileStats;
|
|
217
209
|
}
|
|
218
|
-
// The preparation stages shared by the headless pipeline and the app: probe,
|
|
219
|
-
// telemetry, view plan. One trace context: the stages nest under the caller's
|
|
220
|
-
// parent span (or stand alone when none is given).
|
|
221
210
|
export async function prepareSession(videoPath, config, log, options = {}) {
|
|
222
211
|
const env = {
|
|
223
212
|
videoPath,
|
|
@@ -229,11 +218,9 @@ export async function prepareSession(videoPath, config, log, options = {}) {
|
|
|
229
218
|
tools: options.tools ?? resolveFfTools(config),
|
|
230
219
|
report: createPrepareReporter(options.onProgress),
|
|
231
220
|
};
|
|
232
|
-
// Config producers normalize the canvas (config.normalizeDimensions); the
|
|
233
|
-
// pipeline renders exactly what the vocabulary resolved.
|
|
234
221
|
const { width, height } = config;
|
|
235
222
|
const { probe, introOutro } = await probeStage(env);
|
|
236
|
-
const { tel, hud } = await telemetryStage(env, probe);
|
|
223
|
+
const { tel, frameValues, protoFile, gimbalDevice, hud } = await telemetryStage(env, probe);
|
|
237
224
|
const overview = await viewPlanStage(env, tel);
|
|
238
225
|
const frames = frameArrays(tel);
|
|
239
226
|
return {
|
|
@@ -241,17 +228,15 @@ export async function prepareSession(videoPath, config, log, options = {}) {
|
|
|
241
228
|
height,
|
|
242
229
|
probe,
|
|
243
230
|
tel,
|
|
231
|
+
frameValues,
|
|
232
|
+
protoFile,
|
|
233
|
+
gimbalDevice,
|
|
244
234
|
hud,
|
|
245
235
|
introOutro,
|
|
246
236
|
overview,
|
|
247
237
|
frames,
|
|
248
238
|
};
|
|
249
239
|
}
|
|
250
|
-
// Maps a prepared recording onto the shared renderer page's inputs through
|
|
251
|
-
// the same planning the app's live restyle uses; callers add the video option
|
|
252
|
-
// when they drive the interactive variant. The planning triple is computed
|
|
253
|
-
// once in prepareSession and passed down, so the summary and the rendered
|
|
254
|
-
// page cannot drift apart.
|
|
255
240
|
export function recordingPageOpts(prep, config) {
|
|
256
241
|
return planPageOpts({
|
|
257
242
|
bbox: prep.tel.bbox,
|
|
@@ -281,9 +266,7 @@ function buildOkSummary(ctx, elapsedSec) {
|
|
|
281
266
|
introFrames: introOutro.introN,
|
|
282
267
|
outroFrames: introOutro.outroN,
|
|
283
268
|
hud,
|
|
284
|
-
//
|
|
285
|
-
// TelemetrySummary must land here visibly, not silently drop a key
|
|
286
|
-
// from the --json line.
|
|
269
|
+
// Field by field, not a spread: a TelemetrySummary rename must land here visibly, not silently drop a --json key.
|
|
287
270
|
source: telemetry.source,
|
|
288
271
|
method: telemetry.method,
|
|
289
272
|
headingMode: telemetry.headingMode,
|
|
@@ -352,10 +335,23 @@ async function renderToOutput(env) {
|
|
|
352
335
|
await verifyRenderedOutput(env);
|
|
353
336
|
});
|
|
354
337
|
}
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
338
|
+
export function telemetryExportInput(prep) {
|
|
339
|
+
return {
|
|
340
|
+
source: prep.tel.source,
|
|
341
|
+
headingMode: prep.tel.headingMode,
|
|
342
|
+
frameCount: prep.probe.frames,
|
|
343
|
+
protoFile: prep.protoFile,
|
|
344
|
+
gimbalDevice: prep.gimbalDevice,
|
|
345
|
+
frames: prep.frameValues,
|
|
346
|
+
headingDeg: prep.tel.frames.map((frame) => frame.headingDeg),
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
function writeTelemetryExport(file, prep, log) {
|
|
350
|
+
const doc = buildTelemetryDocument(telemetryExportInput(prep));
|
|
351
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
352
|
+
fs.writeFileSync(file, serializeTelemetryDocument(doc));
|
|
353
|
+
log(`telemetry JSON: wrote ${file}`);
|
|
354
|
+
}
|
|
359
355
|
export async function processRecording(videoPath, config, log, outPath = outputPathFor(videoPath, config), options = {}) {
|
|
360
356
|
const t0 = Date.now();
|
|
361
357
|
const tracer = options.trace?.tracer ?? NOOP_TRACER;
|
|
@@ -381,6 +377,9 @@ export async function processRecording(videoPath, config, log, outPath = outputP
|
|
|
381
377
|
'source.fps': prep.probe.fps.value,
|
|
382
378
|
'telemetry.source': prep.tel.source,
|
|
383
379
|
});
|
|
380
|
+
if (config.telemetryJson) {
|
|
381
|
+
writeTelemetryExport(config.telemetryJson, prep, log);
|
|
382
|
+
}
|
|
384
383
|
const tileStats = await tileWarmStage(deps, config, prep.overview, log, tracer, root);
|
|
385
384
|
const range = resolveRange(options.range, prep.probe.frames);
|
|
386
385
|
const outFrames = range ? range.end - range.start + 1 : prep.probe.frames;
|
|
@@ -398,13 +397,13 @@ export async function processRecording(videoPath, config, log, outPath = outputP
|
|
|
398
397
|
return buildOkSummary(ctx, Math.round((Date.now() - t0) / 1000));
|
|
399
398
|
});
|
|
400
399
|
}
|
|
401
|
-
// Failures never abort the batch.
|
|
402
400
|
export async function runBatch(videos, config, log, emit, options = {}) {
|
|
403
401
|
const result = { ok: 0, skipped: 0, failed: 0 };
|
|
404
402
|
const deps = resolveDeps(options.deps, config.tileCache);
|
|
405
403
|
const tools = options.tools ?? resolveFfTools(config);
|
|
406
|
-
|
|
407
|
-
|
|
404
|
+
if (config.telemetryJson && videos.length > 1) {
|
|
405
|
+
throw new Error('--telemetry-json writes one document per run: give a single recording');
|
|
406
|
+
}
|
|
408
407
|
const plans = planOutputs(videos, config);
|
|
409
408
|
for (const [idx, video] of videos.entries()) {
|
|
410
409
|
const base = path.basename(video);
|
package/dist/serve.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
// Static assets and video streaming shared by the headless render server and
|
|
2
|
-
// the app's session server. URL routing and its guards live in src/assets.ts;
|
|
3
|
-
// this shell performs the I/O and writes the resolved result.
|
|
4
1
|
import fs from 'node:fs';
|
|
5
2
|
import path from 'node:path';
|
|
6
3
|
import { createRequire } from 'node:module';
|
|
@@ -10,12 +7,7 @@ import { mimeFor, resolveAsset } from './assets.js';
|
|
|
10
7
|
import { rangePlan } from './range.js';
|
|
11
8
|
const require_ = createRequire(import.meta.url);
|
|
12
9
|
const LEAFLET_DIR = path.dirname(require_.resolve('leaflet/dist/leaflet.js'));
|
|
13
|
-
/** Compiled shared renderer modules, served to generated pages as ESM. */
|
|
14
10
|
export const RENDERER_DIR = fileURLToPath(new URL('./renderer/', import.meta.url));
|
|
15
|
-
// Writes the shared router's result: the routed file (or its placeholder
|
|
16
|
-
// fallback) with its mime, or a 404 for a claimed URL without a file.
|
|
17
|
-
// Returns true when the URL belongs to one of the routes; callers route
|
|
18
|
-
// everything else themselves.
|
|
19
11
|
export function serveAsset(url, res, routes) {
|
|
20
12
|
const asset = resolveAsset(url, { ...routes, leafletDir: LEAFLET_DIR });
|
|
21
13
|
if (asset.kind === 'unrouted')
|
|
@@ -35,9 +27,6 @@ export function serveAsset(url, res, routes) {
|
|
|
35
27
|
res.end('not found');
|
|
36
28
|
return true;
|
|
37
29
|
}
|
|
38
|
-
// Streams a file with HTTP Range support so the <video> element can seek.
|
|
39
|
-
// The returned promise resolves once the file handle is released, so callers
|
|
40
|
-
// can order file cleanup after the stream.
|
|
41
30
|
export function serveFileWithRange(req, res, filePath) {
|
|
42
31
|
let size;
|
|
43
32
|
try {
|
|
@@ -62,8 +51,6 @@ export function serveFileWithRange(req, res, filePath) {
|
|
|
62
51
|
const stream = plan.status === 206
|
|
63
52
|
? fs.createReadStream(filePath, { start: plan.span.start, end: plan.span.end })
|
|
64
53
|
: fs.createReadStream(filePath);
|
|
65
|
-
// pipeline tears the read stream down when the client aborts (every video
|
|
66
|
-
// seek does), so the file handle is released and the promise settles.
|
|
67
54
|
return new Promise((resolve) => {
|
|
68
55
|
pipeline(stream, res, () => resolve());
|
|
69
56
|
});
|
package/dist/srt.js
CHANGED
|
@@ -1,16 +1,26 @@
|
|
|
1
|
-
// One cue per video frame; the cue index equals the video frame index. Cues
|
|
2
|
-
// whose latitude/longitude line is not a real GPS fix (src/geo.ts's
|
|
3
|
-
// gpsFix - the (0, 0) placeholder or worse) are kept with fix = null so
|
|
4
|
-
// alignment is never lost.
|
|
5
1
|
import { readFile } from 'node:fs/promises';
|
|
6
2
|
import { gpsFix } from './geo.js';
|
|
7
3
|
const RX_TIMING = /^(\d{2}):(\d{2}):(\d{2})[,.](\d{3})\s*-->/;
|
|
8
4
|
const RX_LATLON = /\[latitude:\s*(-?\d+\.?\d*)\]\s*\[longitude:\s*(-?\d+\.?\d*)\]/;
|
|
9
5
|
const RX_ALT = /\[rel_alt:\s*(-?\d+\.?\d*)\s+abs_alt:\s*(-?\d+\.?\d*)\]/;
|
|
6
|
+
const RX_ISO = /\[iso:\s*(-?\d+\.?\d*)\]/;
|
|
7
|
+
const RX_SHUTTER = /\[shutter:\s*([^\]]+)\]/;
|
|
8
|
+
const RX_CT = /\[ct:\s*(-?\d+\.?\d*)\]/;
|
|
9
|
+
const RX_FNUM = /\[fnum:\s*(-?\d+\.?\d*)\]/;
|
|
10
|
+
const RX_FRACTION = /^(\d+\.?\d*)\s*\/\s*(\d+\.?\d*)$/;
|
|
10
11
|
function parseNumber(text) {
|
|
11
12
|
const value = Number.parseFloat(text);
|
|
12
13
|
return Number.isFinite(value) ? value : null;
|
|
13
14
|
}
|
|
15
|
+
function parseShutter(text) {
|
|
16
|
+
const fraction = RX_FRACTION.exec(text.trim());
|
|
17
|
+
if (fraction) {
|
|
18
|
+
const denominator = parseNumber(fraction[2]);
|
|
19
|
+
const numerator = parseNumber(fraction[1]);
|
|
20
|
+
return denominator && numerator !== null ? numerator / denominator : null;
|
|
21
|
+
}
|
|
22
|
+
return parseNumber(text);
|
|
23
|
+
}
|
|
14
24
|
function stripFontTags(line) {
|
|
15
25
|
return line.replace(/<[^>]*>/g, '').trim();
|
|
16
26
|
}
|
|
@@ -26,15 +36,16 @@ function newCue(tSec) {
|
|
|
26
36
|
fix: null,
|
|
27
37
|
relAlt: null,
|
|
28
38
|
absAlt: null,
|
|
39
|
+
iso: null,
|
|
40
|
+
shutterTime: null,
|
|
41
|
+
whiteBalanceCctK: null,
|
|
42
|
+
fNumber: null,
|
|
29
43
|
};
|
|
30
44
|
}
|
|
31
45
|
export function parseSrtText(text) {
|
|
32
46
|
const cues = [];
|
|
33
47
|
let noLock = 0;
|
|
34
48
|
let baseMs = null;
|
|
35
|
-
// A second (repeated) lat/lon line in one cue must not count as another
|
|
36
|
-
// no-lock event - only the current cue can receive lines, so one flag is
|
|
37
|
-
// enough to remember whether it already saw one.
|
|
38
49
|
let cueSawLatLon = false;
|
|
39
50
|
for (const rawLine of text.split(/\r?\n/)) {
|
|
40
51
|
const line = stripFontTags(rawLine);
|
|
@@ -44,7 +55,6 @@ export function parseSrtText(text) {
|
|
|
44
55
|
if (timing) {
|
|
45
56
|
const ms = timingLineToMs(timing);
|
|
46
57
|
baseMs ??= ms;
|
|
47
|
-
// A timing line always starts a new cue.
|
|
48
58
|
cues.push(newCue((ms - baseMs) / 1000));
|
|
49
59
|
cueSawLatLon = false;
|
|
50
60
|
continue;
|
|
@@ -68,6 +78,18 @@ export function parseSrtText(text) {
|
|
|
68
78
|
cue.relAlt = parseNumber(alt[1]);
|
|
69
79
|
cue.absAlt = parseNumber(alt[2]);
|
|
70
80
|
}
|
|
81
|
+
const iso = cue.iso === null ? RX_ISO.exec(line) : null;
|
|
82
|
+
if (iso)
|
|
83
|
+
cue.iso = parseNumber(iso[1]);
|
|
84
|
+
const shutter = cue.shutterTime === null ? RX_SHUTTER.exec(line) : null;
|
|
85
|
+
if (shutter)
|
|
86
|
+
cue.shutterTime = parseShutter(shutter[1]);
|
|
87
|
+
const ct = cue.whiteBalanceCctK === null ? RX_CT.exec(line) : null;
|
|
88
|
+
if (ct)
|
|
89
|
+
cue.whiteBalanceCctK = parseNumber(ct[1]);
|
|
90
|
+
const fnum = cue.fNumber === null ? RX_FNUM.exec(line) : null;
|
|
91
|
+
if (fnum)
|
|
92
|
+
cue.fNumber = parseNumber(fnum[1]);
|
|
71
93
|
}
|
|
72
94
|
return { cues, noLock, count: cues.length };
|
|
73
95
|
}
|
package/dist/summary.js
CHANGED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { generateTelemetryJsonSchema } from './telemetry-json.js';
|
|
5
|
+
export function writeTelemetryJsonSchema(file) {
|
|
6
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
7
|
+
fs.writeFileSync(file, generateTelemetryJsonSchema());
|
|
8
|
+
}
|
|
9
|
+
function main() {
|
|
10
|
+
try {
|
|
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
|
+
catch (e) {
|
|
17
|
+
process.stderr.write(`[drone-path] ERROR: ${e.message}\n`);
|
|
18
|
+
process.exitCode = 1;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
|
22
|
+
main();
|
|
23
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const TELEMETRY_JSON_SCHEMA_VERSION = 1;
|
|
3
|
+
const GimbalDeviceSchema = z.strictObject({
|
|
4
|
+
id: z.int(),
|
|
5
|
+
type: z.int(),
|
|
6
|
+
subType: z.int(),
|
|
7
|
+
name: z.string(),
|
|
8
|
+
frequency: z.number(),
|
|
9
|
+
});
|
|
10
|
+
const TelemetryRecordSchema = z.strictObject({
|
|
11
|
+
frame: z.int(),
|
|
12
|
+
gimbalDeviceTimestampMs: z.int().optional(),
|
|
13
|
+
lat: z.number().optional(),
|
|
14
|
+
lng: z.number().optional(),
|
|
15
|
+
altAbs: z.number().optional(),
|
|
16
|
+
altRel: z.number().optional(),
|
|
17
|
+
gpsAltMm: z.int().optional(),
|
|
18
|
+
pitchDeg: z.number().optional(),
|
|
19
|
+
rollDeg: z.number().optional(),
|
|
20
|
+
yawDeg: z.number().optional(),
|
|
21
|
+
gimbalPitchDeg: z.number().optional(),
|
|
22
|
+
gimbalRollDeg: z.number().optional(),
|
|
23
|
+
gimbalYawDeg: z.number().optional(),
|
|
24
|
+
headingDeg: z.number(),
|
|
25
|
+
headingSource: z.enum(['yaw', 'cog']),
|
|
26
|
+
iso: z.int().optional(),
|
|
27
|
+
shutterTime: z.number().optional(),
|
|
28
|
+
whiteBalanceCctK: z.int().optional(),
|
|
29
|
+
fNumber: z.number().optional(),
|
|
30
|
+
});
|
|
31
|
+
export const TelemetryDocumentSchema = z.strictObject({
|
|
32
|
+
schemaVersion: z.literal(TELEMETRY_JSON_SCHEMA_VERSION),
|
|
33
|
+
protoFile: z.string().optional(),
|
|
34
|
+
source: z.enum(['srt', 'cammeta']),
|
|
35
|
+
headingMode: z.enum(['yaw', 'cog']),
|
|
36
|
+
frameCount: z.int(),
|
|
37
|
+
gimbalDevice: GimbalDeviceSchema.optional(),
|
|
38
|
+
frames: z.array(TelemetryRecordSchema),
|
|
39
|
+
});
|
|
40
|
+
const BEFORE_HEADING_KEYS = [
|
|
41
|
+
'gimbalDeviceTimestampMs',
|
|
42
|
+
'lat',
|
|
43
|
+
'lng',
|
|
44
|
+
'altAbs',
|
|
45
|
+
'altRel',
|
|
46
|
+
'gpsAltMm',
|
|
47
|
+
'pitchDeg',
|
|
48
|
+
'rollDeg',
|
|
49
|
+
'yawDeg',
|
|
50
|
+
'gimbalPitchDeg',
|
|
51
|
+
'gimbalRollDeg',
|
|
52
|
+
'gimbalYawDeg',
|
|
53
|
+
];
|
|
54
|
+
const EXPOSURE_KEYS = [
|
|
55
|
+
'iso',
|
|
56
|
+
'shutterTime',
|
|
57
|
+
'whiteBalanceCctK',
|
|
58
|
+
'fNumber',
|
|
59
|
+
];
|
|
60
|
+
const INTEGER_VALUE_KEYS = new Set([
|
|
61
|
+
'gimbalDeviceTimestampMs',
|
|
62
|
+
'gpsAltMm',
|
|
63
|
+
'iso',
|
|
64
|
+
'whiteBalanceCctK',
|
|
65
|
+
]);
|
|
66
|
+
function copyValue(record, key, value) {
|
|
67
|
+
if (value === null || value === undefined)
|
|
68
|
+
return;
|
|
69
|
+
record[key] = INTEGER_VALUE_KEYS.has(key) ? Math.round(value) : value;
|
|
70
|
+
}
|
|
71
|
+
function buildRecord(input, index) {
|
|
72
|
+
const row = input.frames[index] ?? {};
|
|
73
|
+
const record = {
|
|
74
|
+
frame: (input.frameStart ?? 0) + index,
|
|
75
|
+
};
|
|
76
|
+
for (const key of BEFORE_HEADING_KEYS)
|
|
77
|
+
copyValue(record, key, row[key]);
|
|
78
|
+
record.headingDeg = input.headingDeg[index];
|
|
79
|
+
record.headingSource = input.headingMode;
|
|
80
|
+
for (const key of EXPOSURE_KEYS)
|
|
81
|
+
copyValue(record, key, row[key]);
|
|
82
|
+
return record;
|
|
83
|
+
}
|
|
84
|
+
export function buildTelemetryDocument(input) {
|
|
85
|
+
if (input.headingDeg.length !== input.frameCount) {
|
|
86
|
+
throw new Error('telemetry JSON: heading count does not match the frame count');
|
|
87
|
+
}
|
|
88
|
+
const frames = [];
|
|
89
|
+
for (let index = 0; index < input.frameCount; index++) {
|
|
90
|
+
frames.push(buildRecord(input, index));
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
schemaVersion: TELEMETRY_JSON_SCHEMA_VERSION,
|
|
94
|
+
...(input.protoFile ? { protoFile: input.protoFile } : {}),
|
|
95
|
+
source: input.source,
|
|
96
|
+
headingMode: input.headingMode,
|
|
97
|
+
frameCount: input.frameCount,
|
|
98
|
+
...(input.gimbalDevice ? { gimbalDevice: input.gimbalDevice } : {}),
|
|
99
|
+
frames,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
export function serializeTelemetryDocument(doc) {
|
|
103
|
+
return `${JSON.stringify(doc, null, 2)}\n`;
|
|
104
|
+
}
|
|
105
|
+
export function generateTelemetryJsonSchema() {
|
|
106
|
+
return `${JSON.stringify(z.toJSONSchema(TelemetryDocumentSchema), null, 2)}\n`;
|
|
107
|
+
}
|