drone-path-engine 1.0.0-rc1 → 1.1.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/dist/config.d.ts +1 -0
- package/dist/config.js +11 -15
- package/dist/configfile.d.ts +2 -0
- package/dist/configfile.js +15 -9
- package/dist/decimate.d.ts +2 -11
- package/dist/decimate.js +1 -84
- package/dist/pipeline.js +37 -20
- package/dist/plan.js +3 -2
- package/dist/render.js +9 -6
- package/dist/renderer/dom.js +1 -1
- package/dist/renderer/scene.js +17 -24
- package/package.json +2 -2
package/dist/config.d.ts
CHANGED
|
@@ -198,6 +198,7 @@ export declare function normalizeDimensions(width: number, height: number): {
|
|
|
198
198
|
};
|
|
199
199
|
export declare function isValidRenderConfig(config: RenderConfig): boolean;
|
|
200
200
|
export declare function validateRenderConfig(config: RenderConfig): void;
|
|
201
|
+
export declare function finalizeRenderConfig(config: RenderConfig): RenderConfig;
|
|
201
202
|
export interface ExportRequest {
|
|
202
203
|
outPath: string;
|
|
203
204
|
config: RenderConfig;
|
package/dist/config.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { parseFrameRange } from 'drone-path-core/frame-range';
|
|
3
|
-
import { numberValue, parseValue, strictShape } from 'drone-path-core/validation';
|
|
3
|
+
import { asRecord, isRecord, numberValue, parseValue, strictShape } from 'drone-path-core/validation';
|
|
4
4
|
export const MAP_STYLE_VALUES = ['satellite', 'topo'];
|
|
5
5
|
const VIEW_MODE_VALUES = ['follow', 'overview'];
|
|
6
6
|
const CAPTURE_FORMAT_VALUES = ['jpeg', 'png'];
|
|
@@ -68,7 +68,7 @@ function nullableStringValue(name) {
|
|
|
68
68
|
}
|
|
69
69
|
// The legacy key loops ran Object.keys on any object, arrays included;
|
|
70
70
|
// spreading keeps exactly those keys visible to the strict shapes below.
|
|
71
|
-
const keyedObjectInput = (value) =>
|
|
71
|
+
const keyedObjectInput = (value) => isRecord(value) ? { ...value } : value;
|
|
72
72
|
// The whitespace tolerance matches the legacy trim-before-match so the error
|
|
73
73
|
// can echo the raw untrimmed input.
|
|
74
74
|
const TRAIL_COLOR_RX = /^\s*#?([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})\s*$/i;
|
|
@@ -422,14 +422,7 @@ export function appearanceOf(config) {
|
|
|
422
422
|
}
|
|
423
423
|
export function settingsPatchOf(config) {
|
|
424
424
|
return {
|
|
425
|
-
|
|
426
|
-
view: config.view,
|
|
427
|
-
zoom: config.zoom,
|
|
428
|
-
zoomOut: config.zoomOut,
|
|
429
|
-
hud: config.hud,
|
|
430
|
-
introSec: config.introSec,
|
|
431
|
-
outroSec: config.outroSec,
|
|
432
|
-
trailColor: config.trailColor,
|
|
425
|
+
...appearanceOf(config),
|
|
433
426
|
codec: config.codec,
|
|
434
427
|
quality: config.quality,
|
|
435
428
|
preset: config.preset,
|
|
@@ -459,7 +452,7 @@ export function parseSettingsPatch(raw, origin) {
|
|
|
459
452
|
// The pick-request flavor of look settings: its error wording is the legacy
|
|
460
453
|
// IPC wording, deliberately distinct from validateRenderConfig's CLI wording.
|
|
461
454
|
export function parseAppearanceSettings(raw) {
|
|
462
|
-
const look =
|
|
455
|
+
const look = asRecord(raw);
|
|
463
456
|
const { style, view, hud } = look;
|
|
464
457
|
const mapStyle = parseValue(z.enum(MAP_STYLE_VALUES, {
|
|
465
458
|
error: (issue) => `unknown map style: ${String(issue.input)}`,
|
|
@@ -476,7 +469,7 @@ export function parseAppearanceSettings(raw) {
|
|
|
476
469
|
requireNonNegative(introSec, 'intro must be 0 or more');
|
|
477
470
|
requireNonNegative(outroSec, 'outro must be 0 or more');
|
|
478
471
|
const trailColor = asTrailColor(look.trailColor ?? null, 'trail color');
|
|
479
|
-
const chips =
|
|
472
|
+
const chips = asRecord(hud);
|
|
480
473
|
return {
|
|
481
474
|
style: mapStyle,
|
|
482
475
|
view: viewMode,
|
|
@@ -538,6 +531,10 @@ export function validateRenderConfig(config) {
|
|
|
538
531
|
if (!config.outSuffix)
|
|
539
532
|
throw new Error('out-suffix must not be empty');
|
|
540
533
|
}
|
|
534
|
+
export function finalizeRenderConfig(config) {
|
|
535
|
+
validateRenderConfig(config);
|
|
536
|
+
return { ...config, ...normalizeDimensions(config.width, config.height) };
|
|
537
|
+
}
|
|
541
538
|
const MAIN_OWNED_KEYS = [
|
|
542
539
|
// TELEMETRY_JSON_ALIAS.inputKey stays stripped as a legacy spelling of
|
|
543
540
|
// trackOut, so neither spelling can leak into an export request's config.
|
|
@@ -545,7 +542,7 @@ const MAIN_OWNED_KEYS = [
|
|
|
545
542
|
'skipExisting', 'recurse', 'trackOut', TELEMETRY_JSON_ALIAS.inputKey, 'json', 'quiet',
|
|
546
543
|
];
|
|
547
544
|
function parseRequestConfig(raw, base) {
|
|
548
|
-
if (
|
|
545
|
+
if (!isRecord(raw)) {
|
|
549
546
|
throw new Error('invalid export request: config');
|
|
550
547
|
}
|
|
551
548
|
const flat = { ...raw };
|
|
@@ -557,8 +554,7 @@ function parseRequestConfig(raw, base) {
|
|
|
557
554
|
: parseValue(hudSpecSchema('export request: config: hud'), hud);
|
|
558
555
|
const config = { ...base, ...normalizeOverrides(rest, 'export request: config') };
|
|
559
556
|
const merged = hudSpec === undefined ? config : { ...config, hud: hudSpec };
|
|
560
|
-
|
|
561
|
-
return { ...merged, ...normalizeDimensions(merged.width, merged.height) };
|
|
557
|
+
return finalizeRenderConfig(merged);
|
|
562
558
|
}
|
|
563
559
|
const EXPORT_REQUEST_SCHEMA = z.preprocess(keyedObjectInput, strictShape({
|
|
564
560
|
outPath: z.unknown().optional(),
|
package/dist/configfile.d.ts
CHANGED
|
@@ -14,6 +14,8 @@ export declare function resolveConfig(opts: {
|
|
|
14
14
|
cli?: ConfigOverrides;
|
|
15
15
|
configPath?: string | null;
|
|
16
16
|
cwd?: string;
|
|
17
|
+
discover?: boolean;
|
|
18
|
+
resolveOutDir?: boolean;
|
|
17
19
|
onDeprecated?: (message: string) => void;
|
|
18
20
|
cliTrackOutSpelling?: TrackOutSpelling | null;
|
|
19
21
|
}): ResolvedConfig;
|
package/dist/configfile.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { userDataDir } from './paths.js';
|
|
4
|
-
import { CONFIG_FILE_NAME, DEFAULT_CONFIG, assertOneTrackOutSpelling,
|
|
4
|
+
import { CONFIG_FILE_NAME, DEFAULT_CONFIG, assertOneTrackOutSpelling, finalizeRenderConfig, normalizeOverrides, trackOutSpellingOf, } from './config.js';
|
|
5
5
|
import { errorMessage } from 'drone-path-core/errors';
|
|
6
6
|
export function defaultTileCache() {
|
|
7
7
|
const override = process.env['DRONEPATH_TILE_CACHE'];
|
|
@@ -55,18 +55,25 @@ function mergeConfigLayers(fileCfg, cli) {
|
|
|
55
55
|
hud: { ...(cli.hud ?? fileCfg.hud ?? DEFAULT_CONFIG.hud) },
|
|
56
56
|
};
|
|
57
57
|
}
|
|
58
|
-
function resolveConfigPaths(config, cwd) {
|
|
58
|
+
function resolveConfigPaths(config, cwd, resolveOutDir = true) {
|
|
59
59
|
return {
|
|
60
60
|
...config,
|
|
61
61
|
tileCache: path.resolve(cwd, config.tileCache || defaultTileCache()),
|
|
62
|
-
outDir: config.outDir
|
|
62
|
+
outDir: config.outDir
|
|
63
|
+
? resolveOutDir
|
|
64
|
+
? path.resolve(cwd, config.outDir)
|
|
65
|
+
: config.outDir
|
|
66
|
+
: null,
|
|
63
67
|
};
|
|
64
68
|
}
|
|
65
69
|
export function resolveConfig(opts) {
|
|
66
70
|
const cwd = opts.cwd ?? process.cwd();
|
|
71
|
+
const discover = opts.discover ?? true;
|
|
67
72
|
const configPath = opts.configPath !== undefined && opts.configPath !== null
|
|
68
73
|
? path.resolve(cwd, opts.configPath)
|
|
69
|
-
:
|
|
74
|
+
: discover
|
|
75
|
+
? discoverConfigFile(cwd)
|
|
76
|
+
: null;
|
|
70
77
|
const fileLayer = configPath
|
|
71
78
|
? loadConfigFile(configPath, opts.onDeprecated)
|
|
72
79
|
: { overrides: {}, trackOutSpelling: null };
|
|
@@ -77,10 +84,9 @@ export function resolveConfig(opts) {
|
|
|
77
84
|
{ origin: 'the command line', spelling: opts.cliTrackOutSpelling ?? null },
|
|
78
85
|
]);
|
|
79
86
|
const merged = mergeConfigLayers(fileLayer.overrides, opts.cli ?? {});
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
87
|
+
const normalized = finalizeRenderConfig(merged);
|
|
88
|
+
return {
|
|
89
|
+
config: resolveConfigPaths(normalized, cwd, opts.resolveOutDir ?? true),
|
|
90
|
+
configPath,
|
|
84
91
|
};
|
|
85
|
-
return { config: resolveConfigPaths(normalized, cwd), configPath };
|
|
86
92
|
}
|
package/dist/decimate.d.ts
CHANGED
|
@@ -1,11 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
lon: number[];
|
|
4
|
-
frame: number[];
|
|
5
|
-
}
|
|
6
|
-
interface DecimateOptions {
|
|
7
|
-
epsilonPx?: number;
|
|
8
|
-
maxPoints?: number;
|
|
9
|
-
}
|
|
10
|
-
export declare function decimateTrack(lat: readonly number[], lon: readonly number[], zoom: number, options?: DecimateOptions): DecimatedTrack;
|
|
11
|
-
export {};
|
|
1
|
+
export { decimateTrack } from 'drone-path-core/decimate';
|
|
2
|
+
export type { DecimatedTrack } from 'drone-path-core/decimate';
|
package/dist/decimate.js
CHANGED
|
@@ -1,84 +1 @@
|
|
|
1
|
-
|
|
2
|
-
const DEFAULT_EPSILON_PX = 1;
|
|
3
|
-
const DEFAULT_MAX_POINTS = 3000;
|
|
4
|
-
export function decimateTrack(lat, lon, zoom, options = {}) {
|
|
5
|
-
const epsilonPx = options.epsilonPx ?? DEFAULT_EPSILON_PX;
|
|
6
|
-
const maxPoints = options.maxPoints ?? DEFAULT_MAX_POINTS;
|
|
7
|
-
if (!(epsilonPx >= 0))
|
|
8
|
-
throw new Error('epsilon must be >= 0');
|
|
9
|
-
if (!Number.isInteger(maxPoints) || maxPoints < 2) {
|
|
10
|
-
throw new Error('maxPoints must be an integer >= 2');
|
|
11
|
-
}
|
|
12
|
-
if (lat.length !== lon.length) {
|
|
13
|
-
throw new Error('lat and lon must have the same length');
|
|
14
|
-
}
|
|
15
|
-
const n = lat.length;
|
|
16
|
-
if (n === 0)
|
|
17
|
-
return { lat: [], lon: [], frame: [] };
|
|
18
|
-
if (n === 1)
|
|
19
|
-
return { lat: [lat[0]], lon: [lon[0]], frame: [0] };
|
|
20
|
-
const px = new Array(n);
|
|
21
|
-
for (let i = 0; i < n; i++)
|
|
22
|
-
px[i] = project(lon[i], lat[i], zoom);
|
|
23
|
-
let keep = douglasPeucker(px, epsilonPx);
|
|
24
|
-
if (keep.length > maxPoints) {
|
|
25
|
-
let hi = epsilonPx > 0 ? epsilonPx * 2 : 1;
|
|
26
|
-
let hiKeep = douglasPeucker(px, hi);
|
|
27
|
-
while (hiKeep.length > maxPoints) {
|
|
28
|
-
hi *= 2;
|
|
29
|
-
hiKeep = douglasPeucker(px, hi);
|
|
30
|
-
}
|
|
31
|
-
keep = hiKeep;
|
|
32
|
-
}
|
|
33
|
-
const track = { lat: [], lon: [], frame: [] };
|
|
34
|
-
for (const i of keep) {
|
|
35
|
-
track.lat.push(lat[i]);
|
|
36
|
-
track.lon.push(lon[i]);
|
|
37
|
-
track.frame.push(i);
|
|
38
|
-
}
|
|
39
|
-
return track;
|
|
40
|
-
}
|
|
41
|
-
function douglasPeucker(px, epsilon) {
|
|
42
|
-
const n = px.length;
|
|
43
|
-
const keep = new Uint8Array(n);
|
|
44
|
-
keep[0] = 1;
|
|
45
|
-
keep[n - 1] = 1;
|
|
46
|
-
const stack = [0, n - 1];
|
|
47
|
-
while (stack.length > 0) {
|
|
48
|
-
const end = stack.pop();
|
|
49
|
-
const start = stack.pop();
|
|
50
|
-
if (end - start < 2)
|
|
51
|
-
continue;
|
|
52
|
-
const a = px[start];
|
|
53
|
-
const b = px[end];
|
|
54
|
-
const mid = (start + end) / 2;
|
|
55
|
-
let maxDist = -1;
|
|
56
|
-
let maxIdx = -1;
|
|
57
|
-
for (let i = start + 1; i < end; i++) {
|
|
58
|
-
const d = distanceToSegment(px[i], a, b);
|
|
59
|
-
if (d > maxDist ||
|
|
60
|
-
(d === maxDist && Math.abs(i - mid) < Math.abs(maxIdx - mid))) {
|
|
61
|
-
maxDist = d;
|
|
62
|
-
maxIdx = i;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
if (maxDist > epsilon) {
|
|
66
|
-
keep[maxIdx] = 1;
|
|
67
|
-
stack.push(start, maxIdx, maxIdx, end);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
const indices = [];
|
|
71
|
-
for (let i = 0; i < n; i++)
|
|
72
|
-
if (keep[i])
|
|
73
|
-
indices.push(i);
|
|
74
|
-
return indices;
|
|
75
|
-
}
|
|
76
|
-
function distanceToSegment(p, a, b) {
|
|
77
|
-
const dx = b.x - a.x;
|
|
78
|
-
const dy = b.y - a.y;
|
|
79
|
-
const lenSq = dx * dx + dy * dy;
|
|
80
|
-
if (lenSq === 0)
|
|
81
|
-
return Math.sqrt((p.x - a.x) ** 2 + (p.y - a.y) ** 2);
|
|
82
|
-
const t = Math.max(0, Math.min(1, ((p.x - a.x) * dx + (p.y - a.y) * dy) / lenSq));
|
|
83
|
-
return Math.sqrt((p.x - (a.x + t * dx)) ** 2 + (p.y - (a.y + t * dy)) ** 2);
|
|
84
|
-
}
|
|
1
|
+
export { decimateTrack } from 'drone-path-core/decimate';
|
package/dist/pipeline.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
-
import { ERR_OUTPUT_VERIFICATION, ERR_RENDER_CANCELED, errorMessage } from 'drone-path-core/errors';
|
|
3
|
+
import { ERR_OUTPUT_VERIFICATION, ERR_RENDER_CANCELED, codedError, errorMessage } from 'drone-path-core/errors';
|
|
4
4
|
import { probeVideo } from 'drone-path-core/ffmpeg';
|
|
5
5
|
import { outputMatchesSource, verifyOutput } from './ffmpeg-output.js';
|
|
6
6
|
import { resolveFfmpegTools } from 'drone-path-core/ffmpeg-tools';
|
|
@@ -150,6 +150,7 @@ async function telemetryStage(env, probe) {
|
|
|
150
150
|
frames: probe.frames,
|
|
151
151
|
fpsValue: probe.fps.value,
|
|
152
152
|
durationSec: probe.durationSec,
|
|
153
|
+
camMeta: probe.camMeta,
|
|
153
154
|
tools,
|
|
154
155
|
});
|
|
155
156
|
const tel = loaded.telemetry;
|
|
@@ -174,9 +175,12 @@ async function viewPlanStage(env, tel) {
|
|
|
174
175
|
log(describeView(config, overview, config.style));
|
|
175
176
|
return overview;
|
|
176
177
|
}
|
|
178
|
+
function canceledError(cause) {
|
|
179
|
+
return codedError(ERR_RENDER_CANCELED, { code: 'RENDER_CANCELED', cause });
|
|
180
|
+
}
|
|
177
181
|
async function tileWarmStage(deps, config, overview, log, signal) {
|
|
178
182
|
if (signal?.aborted)
|
|
179
|
-
throw
|
|
183
|
+
throw canceledError();
|
|
180
184
|
let tileStats;
|
|
181
185
|
try {
|
|
182
186
|
tileStats = await deps.prefetchTiles({
|
|
@@ -188,26 +192,18 @@ async function tileWarmStage(deps, config, overview, log, signal) {
|
|
|
188
192
|
}
|
|
189
193
|
catch (err) {
|
|
190
194
|
if (signal?.aborted)
|
|
191
|
-
throw
|
|
195
|
+
throw canceledError(err);
|
|
192
196
|
throw err;
|
|
193
197
|
}
|
|
194
198
|
if (signal?.aborted)
|
|
195
|
-
throw
|
|
199
|
+
throw canceledError();
|
|
196
200
|
if (tileStats.downloaded) {
|
|
197
201
|
log(`tiles: ${tileStats.downloaded} downloaded, ${tileStats.failed} placeholders`);
|
|
198
202
|
}
|
|
199
203
|
return tileStats;
|
|
200
204
|
}
|
|
201
|
-
|
|
202
|
-
const
|
|
203
|
-
videoPath,
|
|
204
|
-
config,
|
|
205
|
-
log,
|
|
206
|
-
deps: resolveDeps(options.deps, config.tileCache),
|
|
207
|
-
tools: options.tools ?? resolveFfmpegTools(config),
|
|
208
|
-
report: createPrepareReporter(options.onProgress),
|
|
209
|
-
};
|
|
210
|
-
const { width, height } = config;
|
|
205
|
+
async function prepareWithEnv(env) {
|
|
206
|
+
const { width, height } = env.config;
|
|
211
207
|
const { probe, introOutro } = await probeStage(env);
|
|
212
208
|
const { tel, frameValues, trackValues, protoFile, gimbalDevice, hud } = await telemetryStage(env, probe);
|
|
213
209
|
const overview = await viewPlanStage(env, tel);
|
|
@@ -227,6 +223,16 @@ export async function prepareSession(videoPath, config, log, options = {}) {
|
|
|
227
223
|
frames,
|
|
228
224
|
};
|
|
229
225
|
}
|
|
226
|
+
export async function prepareSession(videoPath, config, log, options = {}) {
|
|
227
|
+
return prepareWithEnv({
|
|
228
|
+
videoPath,
|
|
229
|
+
config,
|
|
230
|
+
log,
|
|
231
|
+
deps: resolveDeps(options.deps, config.tileCache),
|
|
232
|
+
tools: options.tools ?? resolveFfmpegTools(config),
|
|
233
|
+
report: createPrepareReporter(options.onProgress),
|
|
234
|
+
});
|
|
235
|
+
}
|
|
230
236
|
export function recordingPageOpts(prep, config) {
|
|
231
237
|
return planPageOpts({
|
|
232
238
|
bbox: prep.tel.bbox,
|
|
@@ -279,8 +285,16 @@ async function verifyRenderedOutput(env) {
|
|
|
279
285
|
const { ctx, deps, tools } = env;
|
|
280
286
|
const verify = await deps.verifyOutput(tools, ctx.outPath, ctx.outFrames, ctx.probe.fps.value);
|
|
281
287
|
if (!verify.ok) {
|
|
282
|
-
throw
|
|
283
|
-
`expected ${ctx.outFrames} @ ${ctx.probe.fps.str}
|
|
288
|
+
throw codedError(`${ERR_OUTPUT_VERIFICATION}got ${verify.frames} frames @ ${verify.fps ?? 'unknown'}, ` +
|
|
289
|
+
`expected ${ctx.outFrames} @ ${ctx.probe.fps.str}`, {
|
|
290
|
+
code: 'OUTPUT_VERIFICATION',
|
|
291
|
+
params: {
|
|
292
|
+
frames: verify.frames,
|
|
293
|
+
fps: verify.fps ?? 'unknown',
|
|
294
|
+
expectedFrames: ctx.outFrames,
|
|
295
|
+
expectedFps: ctx.probe.fps.str,
|
|
296
|
+
},
|
|
297
|
+
});
|
|
284
298
|
}
|
|
285
299
|
ctx.log(ctx.frameRange
|
|
286
300
|
? 'verified: frame count and frame rate are 1:1 within the exported range'
|
|
@@ -347,14 +361,17 @@ export async function processRecording(videoPath, config, log, outPath = outputP
|
|
|
347
361
|
const deps = resolveDeps(options.deps, config.tileCache);
|
|
348
362
|
const tools = options.tools ?? resolveFfmpegTools(config);
|
|
349
363
|
if (options.signal?.aborted)
|
|
350
|
-
throw
|
|
351
|
-
const prep = await
|
|
352
|
-
|
|
364
|
+
throw canceledError();
|
|
365
|
+
const prep = await prepareWithEnv({
|
|
366
|
+
videoPath,
|
|
367
|
+
config,
|
|
368
|
+
log,
|
|
353
369
|
deps,
|
|
354
370
|
tools,
|
|
371
|
+
report: createPrepareReporter(options.onProgress),
|
|
355
372
|
});
|
|
356
373
|
if (options.signal?.aborted)
|
|
357
|
-
throw
|
|
374
|
+
throw canceledError();
|
|
358
375
|
if (config.trackOut) {
|
|
359
376
|
writeTrackExport(config.trackOut, prep, log);
|
|
360
377
|
}
|
package/dist/plan.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { MIN_DIMENSION } from './config.js';
|
|
1
2
|
import { project } from 'drone-path-core/geo';
|
|
2
3
|
import { TILE_SOURCES } from './renderer/tilesources.js';
|
|
3
4
|
const MIN_ZOOM = 2;
|
|
@@ -53,8 +54,8 @@ function tilesCovering(centerPx, trackSpanPx, zoom, width, height, follow, maxNa
|
|
|
53
54
|
export function computeOverview({ bbox, width, height, maxZoom = 19, zoomOut = 0, follow = false, maxNativeZoom = null, zoomOverride = 0, }) {
|
|
54
55
|
const padX = Math.round(width * 0.08);
|
|
55
56
|
const padY = Math.round(height * 0.08);
|
|
56
|
-
const availW = Math.max(
|
|
57
|
-
const availH = Math.max(
|
|
57
|
+
const availW = Math.max(MIN_DIMENSION, width - 2 * padX);
|
|
58
|
+
const availH = Math.max(MIN_DIMENSION, height - 2 * padY);
|
|
58
59
|
let zoom;
|
|
59
60
|
if (zoomOverride > 0) {
|
|
60
61
|
zoom = Math.max(MIN_ZOOM, Math.min(maxZoom, Math.round(zoomOverride)));
|
package/dist/render.js
CHANGED
|
@@ -2,7 +2,7 @@ import http from 'node:http';
|
|
|
2
2
|
import { spawn } from 'node:child_process';
|
|
3
3
|
import { once } from 'node:events';
|
|
4
4
|
import { MIME } from './assets.js';
|
|
5
|
-
import { ERR_RENDER_CANCELED, errorMessage } from 'drone-path-core/errors';
|
|
5
|
+
import { ERR_RENDER_CANCELED, codedError, errorMessage } from 'drone-path-core/errors';
|
|
6
6
|
import { RENDERER_DIR, serveAsset } from './serve.js';
|
|
7
7
|
const PAGE_LOAD_TIMEOUT_MS = 60000;
|
|
8
8
|
const SCREENSHOT_TIMEOUT_MS = 60000;
|
|
@@ -267,6 +267,9 @@ async function captureFrame(run, loop, page, idx) {
|
|
|
267
267
|
run.onCapture?.({ done, total: run.frames });
|
|
268
268
|
}
|
|
269
269
|
}
|
|
270
|
+
function canceledError(cause) {
|
|
271
|
+
return codedError(ERR_RENDER_CANCELED, { code: 'RENDER_CANCELED', cause });
|
|
272
|
+
}
|
|
270
273
|
async function workerLoop(run, loop, workerId) {
|
|
271
274
|
const page = await run.active.newPage({
|
|
272
275
|
viewport: { width: run.width, height: run.height },
|
|
@@ -279,7 +282,7 @@ async function workerLoop(run, loop, workerId) {
|
|
|
279
282
|
if (loop.failed)
|
|
280
283
|
return;
|
|
281
284
|
if (run.signal?.aborted)
|
|
282
|
-
throw
|
|
285
|
+
throw canceledError();
|
|
283
286
|
const idx = loop.cursor++;
|
|
284
287
|
if (idx >= run.frames)
|
|
285
288
|
break;
|
|
@@ -326,13 +329,13 @@ async function captureAndEncode(active, env) {
|
|
|
326
329
|
const stream = new OrderedFrameStream(encoder, workerCount);
|
|
327
330
|
const abortEncode = () => {
|
|
328
331
|
encoder.kill();
|
|
329
|
-
stream.abort(
|
|
332
|
+
stream.abort(canceledError());
|
|
330
333
|
};
|
|
331
334
|
signal?.addEventListener('abort', abortEncode, { once: true });
|
|
332
335
|
try {
|
|
333
336
|
await runWorkers({ ...ctx, active, url, stream, timing }, workerCount);
|
|
334
337
|
if (signal?.aborted)
|
|
335
|
-
throw
|
|
338
|
+
throw canceledError();
|
|
336
339
|
await finishEncode(encoder, stream, log, outPath);
|
|
337
340
|
}
|
|
338
341
|
catch (e) {
|
|
@@ -341,7 +344,7 @@ async function captureAndEncode(active, env) {
|
|
|
341
344
|
if (signal?.aborted) {
|
|
342
345
|
throw e instanceof Error && e.message === ERR_RENDER_CANCELED
|
|
343
346
|
? e
|
|
344
|
-
:
|
|
347
|
+
: canceledError(e);
|
|
345
348
|
}
|
|
346
349
|
throw e;
|
|
347
350
|
}
|
|
@@ -379,7 +382,7 @@ export async function renderVideo(opts) {
|
|
|
379
382
|
tools,
|
|
380
383
|
};
|
|
381
384
|
if (signal?.aborted)
|
|
382
|
-
throw
|
|
385
|
+
throw canceledError();
|
|
383
386
|
const timing = { evalMs: 0, captureMs: 0, emitMs: 0 };
|
|
384
387
|
const { server, url } = await startServer({ html, style, tileCache, log });
|
|
385
388
|
const env = { ctx, url, timing, workerCount };
|
package/dist/renderer/dom.js
CHANGED
|
@@ -78,7 +78,7 @@ function attrCss(at, scale) {
|
|
|
78
78
|
return `
|
|
79
79
|
${at} #attr {
|
|
80
80
|
position: absolute; right: 0; bottom: 0; z-index: 1000; max-width: 72%;
|
|
81
|
-
background: rgba(12, 14, 22, 0.
|
|
81
|
+
background: rgba(12, 14, 22, 0.8); color: rgba(255,255,255,0.88);
|
|
82
82
|
font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
|
|
83
83
|
font-size: ${Math.round(11 * scale)}px; line-height: 1.35;
|
|
84
84
|
padding: ${Math.round(2 * scale)}px ${Math.round(8 * scale)}px;
|
package/dist/renderer/scene.js
CHANGED
|
@@ -6,14 +6,14 @@ import { createTrailController } from './trail.js';
|
|
|
6
6
|
function hudEq(a, b) {
|
|
7
7
|
return (a.heading === b.heading && a.alt === b.alt && a.speed === b.speed);
|
|
8
8
|
}
|
|
9
|
+
/** A missing value renders exactly like a disabled chip: the dimmed "--". */
|
|
10
|
+
function isMissing(value) {
|
|
11
|
+
return value === null || value === undefined;
|
|
12
|
+
}
|
|
9
13
|
function setChipText(chip, value, format) {
|
|
10
14
|
if (!chip)
|
|
11
15
|
return;
|
|
12
|
-
chip.textContent = value
|
|
13
|
-
}
|
|
14
|
-
/** A missing value renders exactly like a disabled chip: the dimmed "--". */
|
|
15
|
-
function isPlaceholder(value) {
|
|
16
|
-
return value === null || value === undefined;
|
|
16
|
+
chip.textContent = isMissing(value) ? '--' : format(value);
|
|
17
17
|
}
|
|
18
18
|
let scopeCount = 0;
|
|
19
19
|
class SceneState {
|
|
@@ -305,7 +305,7 @@ class SceneState {
|
|
|
305
305
|
setHeading(chip, deg) {
|
|
306
306
|
if (!chip)
|
|
307
307
|
return;
|
|
308
|
-
const missing = deg
|
|
308
|
+
const missing = isMissing(deg);
|
|
309
309
|
const arrow = chip.querySelector('.chip-arrow');
|
|
310
310
|
const num = chip.querySelector('.num');
|
|
311
311
|
if (arrow) {
|
|
@@ -321,7 +321,7 @@ class SceneState {
|
|
|
321
321
|
return;
|
|
322
322
|
setChipText(chip.querySelector('.num'), value, format);
|
|
323
323
|
if (this.externalHud)
|
|
324
|
-
chip.classList.toggle('map-readout-off',
|
|
324
|
+
chip.classList.toggle('map-readout-off', isMissing(value));
|
|
325
325
|
}
|
|
326
326
|
setFrame(i) {
|
|
327
327
|
this.curIdx = i;
|
|
@@ -346,18 +346,17 @@ class SceneState {
|
|
|
346
346
|
update(next) {
|
|
347
347
|
const prev = this.data;
|
|
348
348
|
this.data = next;
|
|
349
|
-
|
|
349
|
+
const styleChanged = next.style !== prev.style;
|
|
350
|
+
const sizeChanged = next.width !== prev.width || next.height !== prev.height;
|
|
351
|
+
const trackChanged = next.lat !== prev.lat || next.lon !== prev.lon;
|
|
352
|
+
if (trackChanged) {
|
|
350
353
|
this.latlngs = this.latlngsOf(next);
|
|
351
354
|
this.bb = this.L.latLngBounds(this.latlngs);
|
|
352
355
|
}
|
|
353
|
-
const
|
|
354
|
-
|
|
355
|
-
next.width !== prev.width ||
|
|
356
|
-
next.height !== prev.height ||
|
|
357
|
-
next.attribution !== prev.attribution;
|
|
358
|
-
if (chromeChanged)
|
|
356
|
+
const lookChanged = styleChanged || next.trailColor !== prev.trailColor || sizeChanged;
|
|
357
|
+
if (lookChanged || next.attribution !== prev.attribution)
|
|
359
358
|
this.applyChrome();
|
|
360
|
-
if (
|
|
359
|
+
if (styleChanged) {
|
|
361
360
|
// Zoom constraints are per tile layer (topo is native to z17), so a style switch swaps the layer instead of only its URL.
|
|
362
361
|
this.tiles.remove();
|
|
363
362
|
this.tiles = this.makeTileLayer(next.tileUrl, next.style);
|
|
@@ -366,16 +365,10 @@ class SceneState {
|
|
|
366
365
|
else if (next.tileUrl !== prev.tileUrl) {
|
|
367
366
|
this.tiles.setUrl(next.tileUrl);
|
|
368
367
|
}
|
|
369
|
-
const
|
|
370
|
-
next.trailColor !== prev.trailColor ||
|
|
371
|
-
next.trailLat !== prev.trailLat ||
|
|
368
|
+
const trailChanged = next.trailLat !== prev.trailLat ||
|
|
372
369
|
next.trailLon !== prev.trailLon ||
|
|
373
|
-
next.trailFrame !== prev.trailFrame
|
|
374
|
-
|
|
375
|
-
next.lon !== prev.lon ||
|
|
376
|
-
next.width !== prev.width ||
|
|
377
|
-
next.height !== prev.height;
|
|
378
|
-
if (decorInvalidated)
|
|
370
|
+
next.trailFrame !== prev.trailFrame;
|
|
371
|
+
if (lookChanged || trailChanged || trackChanged)
|
|
379
372
|
this.rebuildDecor();
|
|
380
373
|
if (!hudEq(prev.hud, next.hud) ||
|
|
381
374
|
next.hudPills !== prev.hudPills ||
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "drone-path-engine",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Plan and render flight-path map overlays from drone telemetry.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@types/leaflet": "~1.9.22",
|
|
33
|
-
"drone-path-core": "~1.
|
|
33
|
+
"drone-path-core": "~1.1.0",
|
|
34
34
|
"leaflet": "~1.9.4",
|
|
35
35
|
"p-queue": "~10.0.0",
|
|
36
36
|
"playwright-core": "~1.65.0",
|