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.
- package/README.md +20 -74
- package/THIRD-PARTY-NOTICES.md +3 -82
- package/bin/drone-path.mjs +0 -0
- package/dist/cli.d.ts +14 -0
- package/dist/cli.js +7 -7
- package/dist/version.d.ts +1 -0
- package/package.json +21 -68
- package/CHANGELOG.md +0 -336
- package/app/ipc.d.mts +0 -43
- package/app/ipc.mjs +0 -216
- package/app/main.mjs +0 -356
- package/app/preload.cjs +0 -34
- package/app/update-policy.d.mts +0 -6
- package/app/update-policy.mjs +0 -6
- package/app/update.d.mts +0 -10
- package/app/update.mjs +0 -54
- package/dist/appassets.js +0 -35
- package/dist/apppaths.js +0 -20
- package/dist/appsession.js +0 -121
- package/dist/appstate.js +0 -94
- package/dist/assets.js +0 -60
- package/dist/buildinfo.js +0 -64
- package/dist/cammeta-decode.js +0 -237
- package/dist/cammeta.js +0 -92
- package/dist/changeset-gate.js +0 -39
- package/dist/config.js +0 -631
- package/dist/configfile.js +0 -86
- package/dist/decimate.js +0 -84
- package/dist/errors.js +0 -34
- package/dist/exec-tool.js +0 -13
- package/dist/exportjob.js +0 -90
- package/dist/ffmpeg-tools.js +0 -56
- package/dist/ffmpeg.js +0 -98
- package/dist/frametime.js +0 -32
- package/dist/geo.js +0 -60
- package/dist/logging.js +0 -1
- package/dist/manual/anchors.js +0 -17
- package/dist/manual/build.js +0 -67
- package/dist/manual/cliref.js +0 -34
- package/dist/manual/links.js +0 -59
- package/dist/manual/markdown.js +0 -98
- package/dist/manual/model.js +0 -1
- package/dist/manual/module.js +0 -5
- package/dist/manual/nav.js +0 -11
- package/dist/manual/reference.js +0 -18
- package/dist/paths.js +0 -16
- package/dist/pipeline.js +0 -402
- package/dist/plan.js +0 -106
- package/dist/png.js +0 -32
- package/dist/protobuf-wire.js +0 -102
- package/dist/range.js +0 -50
- package/dist/recordings.js +0 -55
- package/dist/render-page.js +0 -85
- package/dist/render.js +0 -268
- package/dist/renderer/boot.js +0 -7
- package/dist/renderer/dom.js +0 -177
- package/dist/renderer/framemath.js +0 -30
- package/dist/renderer/scene.js +0 -385
- package/dist/renderer/theme.js +0 -82
- package/dist/renderer/tilesources.js +0 -38
- package/dist/renderer/trail.js +0 -42
- package/dist/restyle.js +0 -16
- package/dist/serve.js +0 -27
- package/dist/srt.js +0 -98
- package/dist/telemetry-json-schema.js +0 -18
- package/dist/telemetry-json.js +0 -126
- package/dist/telemetry-math.js +0 -267
- package/dist/telemetry-summary.js +0 -19
- package/dist/telemetry.js +0 -95
- package/dist/tilecache.js +0 -21
- package/dist/tiles.js +0 -155
- package/dist/track-format.js +0 -13
- package/dist/track-geojson.js +0 -44
- package/dist/track-gpx.js +0 -34
- package/dist/track-kml.js +0 -47
- package/dist/track-kmz.js +0 -68
- package/dist/track-write.js +0 -41
- package/dist/track.js +0 -79
package/dist/renderer/scene.js
DELETED
|
@@ -1,385 +0,0 @@
|
|
|
1
|
-
import { TILE_SOURCES } from './tilesources.js';
|
|
2
|
-
import { droneMarkerMarkup, el, hudMarkup, mapMarkup, quietAttributionLinks, sceneCss, stripReadoutMarkup } from './dom.js';
|
|
3
|
-
import { computeScale, introOutroScale, metersPerPixel, scaleBarMeters } from './framemath.js';
|
|
4
|
-
import { themeFor } from './theme.js';
|
|
5
|
-
import { createTrailController } from './trail.js';
|
|
6
|
-
function hudEq(a, b) {
|
|
7
|
-
return (a.heading === b.heading && a.alt === b.alt && a.speed === b.speed);
|
|
8
|
-
}
|
|
9
|
-
function setChipText(chip, value, format) {
|
|
10
|
-
if (!chip)
|
|
11
|
-
return;
|
|
12
|
-
chip.textContent = value === null || value === undefined ? '--' : format(value);
|
|
13
|
-
}
|
|
14
|
-
/** A missing value renders exactly like a disabled chip: the dimmed "--". */
|
|
15
|
-
function isPlaceholder(value) {
|
|
16
|
-
return value === null || value === undefined;
|
|
17
|
-
}
|
|
18
|
-
let scopeCount = 0;
|
|
19
|
-
class SceneState {
|
|
20
|
-
ready;
|
|
21
|
-
data;
|
|
22
|
-
L;
|
|
23
|
-
host;
|
|
24
|
-
scopeClass = `scene-scope-${(scopeCount += 1)}`;
|
|
25
|
-
styleEl;
|
|
26
|
-
readyTimer;
|
|
27
|
-
settleReady = () => { };
|
|
28
|
-
attrEl;
|
|
29
|
-
mapEl;
|
|
30
|
-
frameEl;
|
|
31
|
-
scalelineEl;
|
|
32
|
-
scaletextEl;
|
|
33
|
-
map;
|
|
34
|
-
tiles;
|
|
35
|
-
latlngs;
|
|
36
|
-
bb;
|
|
37
|
-
layout;
|
|
38
|
-
decor;
|
|
39
|
-
headingChip = null;
|
|
40
|
-
altChip = null;
|
|
41
|
-
speedChip = null;
|
|
42
|
-
/** Chip container: inside the map frame for exports, or an external strip. */
|
|
43
|
-
hudRoot;
|
|
44
|
-
/** External strips get the column markup; the export frame keeps its pills. */
|
|
45
|
-
externalHud;
|
|
46
|
-
curIdx = 0;
|
|
47
|
-
constructor(host, firstData, L, hudHost) {
|
|
48
|
-
this.host = host;
|
|
49
|
-
this.data = firstData;
|
|
50
|
-
this.L = L;
|
|
51
|
-
host.classList.add(this.scopeClass);
|
|
52
|
-
this.styleEl = document.createElement('style');
|
|
53
|
-
document.head.appendChild(this.styleEl);
|
|
54
|
-
// One definedness rule for both: a caller either supplies the external
|
|
55
|
-
// strip host or gets the in-frame export HUD, never a mix of the two.
|
|
56
|
-
const externalHud = hudHost !== undefined;
|
|
57
|
-
host.innerHTML = mapMarkup(externalHud ? null : firstData.hud, firstData.attribution);
|
|
58
|
-
this.hudRoot = hudHost ?? el(host, '#hud');
|
|
59
|
-
this.externalHud = externalHud;
|
|
60
|
-
this.attrEl = el(host, '#attr');
|
|
61
|
-
this.applyChrome();
|
|
62
|
-
this.mapEl = el(host, '#map');
|
|
63
|
-
this.map = L.map(this.mapEl, {
|
|
64
|
-
zoomControl: false,
|
|
65
|
-
attributionControl: false,
|
|
66
|
-
dragging: false,
|
|
67
|
-
scrollWheelZoom: false,
|
|
68
|
-
doubleClickZoom: false,
|
|
69
|
-
boxZoom: false,
|
|
70
|
-
keyboard: false,
|
|
71
|
-
touchZoom: false,
|
|
72
|
-
fadeAnimation: false,
|
|
73
|
-
zoomAnimation: false,
|
|
74
|
-
markerZoomAnimation: false,
|
|
75
|
-
preferCanvas: true,
|
|
76
|
-
zoomSnap: 1,
|
|
77
|
-
});
|
|
78
|
-
this.tiles = this.makeTileLayer(firstData.tileUrl, firstData.style);
|
|
79
|
-
this.tiles.addTo(this.map);
|
|
80
|
-
this.latlngs = this.latlngsOf(firstData);
|
|
81
|
-
this.bb = L.latLngBounds(this.latlngs);
|
|
82
|
-
this.frameEl = el(host, '#map-frame');
|
|
83
|
-
this.scalelineEl = el(host, '#scaleline');
|
|
84
|
-
this.scaletextEl = el(host, '#scaletext');
|
|
85
|
-
// Leaflet only creates marker DOM once the map has a view: layoutMap() must precede buildDecor() so the arrow/wrap elements exist.
|
|
86
|
-
this.layoutMap();
|
|
87
|
-
this.decor = this.buildDecor();
|
|
88
|
-
this.rebuildHud();
|
|
89
|
-
this.ready = new Promise((resolve) => {
|
|
90
|
-
const markReady = () => resolve();
|
|
91
|
-
this.settleReady = markReady;
|
|
92
|
-
this.tiles.on('load', markReady);
|
|
93
|
-
this.readyTimer = setTimeout(markReady, 12000);
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
scale() {
|
|
97
|
-
return computeScale(this.data.width, this.data.height);
|
|
98
|
-
}
|
|
99
|
-
makeTileLayer(tileUrl, style) {
|
|
100
|
-
return this.L.tileLayer(tileUrl, {
|
|
101
|
-
maxZoom: TILE_SOURCES[style].maxZoom,
|
|
102
|
-
maxNativeZoom: TILE_SOURCES[style].maxNativeZoom ?? undefined,
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
latlngsOf(data) {
|
|
106
|
-
return data.lat.map((la, i) => [la, data.lon[i]]);
|
|
107
|
-
}
|
|
108
|
-
applyChrome() {
|
|
109
|
-
this.styleEl.textContent = sceneCss(TILE_SOURCES[this.data.style], themeFor(this.data.style, this.data.trailColor), this.data.width, this.data.height, this.scale(), this.scopeClass);
|
|
110
|
-
this.attrEl.innerHTML = this.data.attribution;
|
|
111
|
-
// The compact map card truncates the credit to one line; the hover title
|
|
112
|
-
// carries the full text wherever the browser can show it.
|
|
113
|
-
this.attrEl.title = this.attrEl.textContent ?? '';
|
|
114
|
-
quietAttributionLinks(this.attrEl);
|
|
115
|
-
}
|
|
116
|
-
layoutMap() {
|
|
117
|
-
const { data, map, mapEl, frameEl } = this;
|
|
118
|
-
const vw = frameEl.clientWidth || data.width;
|
|
119
|
-
const vh = frameEl.clientHeight || data.height;
|
|
120
|
-
let bigW;
|
|
121
|
-
let bigH;
|
|
122
|
-
if (data.view === 'follow') {
|
|
123
|
-
const pb1 = map.project(this.bb.getNorthWest(), data.zoom);
|
|
124
|
-
const pb2 = map.project(this.bb.getSouthEast(), data.zoom);
|
|
125
|
-
bigW = Math.max(2 * vw, Math.ceil(Math.abs(pb2.x - pb1.x) + 2 * vw));
|
|
126
|
-
bigH = Math.max(2 * vh, Math.ceil(Math.abs(pb2.y - pb1.y) + 2 * vh));
|
|
127
|
-
}
|
|
128
|
-
else {
|
|
129
|
-
bigW = 2 * vw;
|
|
130
|
-
bigH = 2 * vh;
|
|
131
|
-
}
|
|
132
|
-
mapEl.style.width = bigW + 'px';
|
|
133
|
-
mapEl.style.height = bigH + 'px';
|
|
134
|
-
map.invalidateSize();
|
|
135
|
-
map.setView(data.view === 'follow' ? this.bb.getCenter() : [data.center.lat, data.center.lon], data.zoom);
|
|
136
|
-
const c0 = map.project(map.getCenter(), data.zoom);
|
|
137
|
-
const latC = data.view === 'follow' ? this.bb.getCenter().lat : data.center.lat;
|
|
138
|
-
const mPerPx = metersPerPixel(latC, data.zoom);
|
|
139
|
-
const bestM = scaleBarMeters(mPerPx, 110 * this.scale());
|
|
140
|
-
this.scalelineEl.style.width = Math.round(bestM / mPerPx) + 'px';
|
|
141
|
-
this.scaletextEl.textContent = bestM >= 1000 ? bestM / 1000 + ' km' : bestM + ' m';
|
|
142
|
-
this.layout = { vw, vh, bigW, bigH, c0, bestM, mPerPx };
|
|
143
|
-
}
|
|
144
|
-
buildGhostLayers(theme, ghostLatlngs, ghostDash) {
|
|
145
|
-
const s = this.scale();
|
|
146
|
-
const layers = [];
|
|
147
|
-
if (theme.ghostCasing) {
|
|
148
|
-
const ghostCasing = this.L.polyline(ghostLatlngs, {
|
|
149
|
-
color: theme.ghostCasing,
|
|
150
|
-
weight: Math.max(3, 4.6 * s),
|
|
151
|
-
opacity: 1,
|
|
152
|
-
dashArray: ghostDash,
|
|
153
|
-
lineCap: 'round',
|
|
154
|
-
smoothFactor: 0,
|
|
155
|
-
});
|
|
156
|
-
ghostCasing.addTo(this.map);
|
|
157
|
-
layers.push(ghostCasing);
|
|
158
|
-
}
|
|
159
|
-
const ghost = this.L.polyline(ghostLatlngs, {
|
|
160
|
-
color: theme.ghost,
|
|
161
|
-
weight: Math.max(2, 2.8 * s),
|
|
162
|
-
opacity: theme.ghostOpacity,
|
|
163
|
-
dashArray: ghostDash,
|
|
164
|
-
lineCap: 'round',
|
|
165
|
-
smoothFactor: 0,
|
|
166
|
-
});
|
|
167
|
-
ghost.addTo(this.map);
|
|
168
|
-
layers.push(ghost);
|
|
169
|
-
return layers;
|
|
170
|
-
}
|
|
171
|
-
// Creation order sets stacking: thickest first so the core stays on top.
|
|
172
|
-
buildTrailLayers(theme) {
|
|
173
|
-
// smoothFactor 0 keeps Leaflet from re-simplifying the pre-decimated path.
|
|
174
|
-
const wCore = Math.max(3, 5.5 * this.scale());
|
|
175
|
-
const trailGlow = this.L.polyline([], {
|
|
176
|
-
color: theme.glow,
|
|
177
|
-
weight: wCore * 2.6,
|
|
178
|
-
opacity: 1,
|
|
179
|
-
lineCap: 'round',
|
|
180
|
-
lineJoin: 'round',
|
|
181
|
-
smoothFactor: 0,
|
|
182
|
-
});
|
|
183
|
-
trailGlow.addTo(this.map);
|
|
184
|
-
const trailCasing = this.L.polyline([], {
|
|
185
|
-
color: theme.casing,
|
|
186
|
-
weight: wCore * 1.6,
|
|
187
|
-
opacity: 0.9,
|
|
188
|
-
lineCap: 'round',
|
|
189
|
-
lineJoin: 'round',
|
|
190
|
-
smoothFactor: 0,
|
|
191
|
-
});
|
|
192
|
-
trailCasing.addTo(this.map);
|
|
193
|
-
const trail = this.L.polyline([], {
|
|
194
|
-
color: theme.trailCore,
|
|
195
|
-
weight: wCore,
|
|
196
|
-
opacity: 1,
|
|
197
|
-
lineCap: 'round',
|
|
198
|
-
lineJoin: 'round',
|
|
199
|
-
smoothFactor: 0,
|
|
200
|
-
});
|
|
201
|
-
trail.addTo(this.map);
|
|
202
|
-
return [trail, trailGlow, trailCasing];
|
|
203
|
-
}
|
|
204
|
-
buildMarker(theme, s) {
|
|
205
|
-
const startDot = this.L.circleMarker(this.latlngs[0], {
|
|
206
|
-
radius: Math.round(7 * s),
|
|
207
|
-
color: '#ffffff',
|
|
208
|
-
weight: Math.max(2, 2 * s),
|
|
209
|
-
fillColor: theme.core,
|
|
210
|
-
fillOpacity: 1,
|
|
211
|
-
});
|
|
212
|
-
startDot.addTo(this.map);
|
|
213
|
-
const drone = this.L.marker(this.latlngs[0], {
|
|
214
|
-
icon: this.L.divIcon({
|
|
215
|
-
className: 'drone-icon',
|
|
216
|
-
html: droneMarkerMarkup(theme.core),
|
|
217
|
-
iconSize: [Math.round(46 * s), Math.round(46 * s)],
|
|
218
|
-
iconAnchor: [Math.round(23 * s), Math.round(23 * s)],
|
|
219
|
-
}),
|
|
220
|
-
interactive: false,
|
|
221
|
-
keyboard: false,
|
|
222
|
-
});
|
|
223
|
-
drone.addTo(this.map);
|
|
224
|
-
return { startDot, drone };
|
|
225
|
-
}
|
|
226
|
-
buildDecor() {
|
|
227
|
-
const theme = themeFor(this.data.style, this.data.trailColor);
|
|
228
|
-
const s = this.scale();
|
|
229
|
-
const ghostLatlngs = this.data.trailLat.map((la, i) => [la, this.data.trailLon[i]]);
|
|
230
|
-
const ghostDash = Math.round(7 * s) + ' ' + Math.round(9 * s);
|
|
231
|
-
const ghostLayers = this.buildGhostLayers(theme, ghostLatlngs, ghostDash);
|
|
232
|
-
const trailLayers = this.buildTrailLayers(theme);
|
|
233
|
-
const { startDot, drone } = this.buildMarker(theme, s);
|
|
234
|
-
const decor = {
|
|
235
|
-
layers: [...trailLayers, startDot, drone, ...ghostLayers],
|
|
236
|
-
trailLayers,
|
|
237
|
-
drone,
|
|
238
|
-
trailCtl: createTrailController({
|
|
239
|
-
lat: this.data.trailLat,
|
|
240
|
-
lon: this.data.trailLon,
|
|
241
|
-
frame: this.data.trailFrame,
|
|
242
|
-
}, { lat: this.data.lat, lon: this.data.lon }, trailLayers),
|
|
243
|
-
arrowEl: this.host.querySelector('#drone-arrow'),
|
|
244
|
-
wrapEl: this.host.querySelector('.drone-wrap'),
|
|
245
|
-
};
|
|
246
|
-
if (!this.data.hud.heading && decor.arrowEl)
|
|
247
|
-
decor.arrowEl.style.display = 'none';
|
|
248
|
-
return decor;
|
|
249
|
-
}
|
|
250
|
-
rebuildDecor() {
|
|
251
|
-
for (const layer of this.decor.layers)
|
|
252
|
-
layer.remove();
|
|
253
|
-
this.decor = this.buildDecor();
|
|
254
|
-
}
|
|
255
|
-
rebuildHud() {
|
|
256
|
-
// Scoped to the chip container so an external strip and a second scene
|
|
257
|
-
// (the export preview) can never cross-write. A scene whose caller
|
|
258
|
-
// overlays its own pills draws none of its own (#283).
|
|
259
|
-
this.hudRoot.innerHTML = this.externalHud
|
|
260
|
-
? stripReadoutMarkup(this.data.hud)
|
|
261
|
-
: this.data.hudPills === false
|
|
262
|
-
? ''
|
|
263
|
-
: hudMarkup(this.data.hud);
|
|
264
|
-
this.headingChip = this.hudRoot.querySelector('#chip-heading');
|
|
265
|
-
this.altChip = this.hudRoot.querySelector('#chip-alt');
|
|
266
|
-
this.speedChip = this.hudRoot.querySelector('#chip-speed');
|
|
267
|
-
if (this.decor.arrowEl) {
|
|
268
|
-
this.decor.arrowEl.style.display = this.data.hud.heading ? '' : 'none';
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
updateTransform(i, k) {
|
|
272
|
-
const { data, layout, decor, mapEl } = this;
|
|
273
|
-
let dx = 0;
|
|
274
|
-
let dy = 0;
|
|
275
|
-
if (data.view === 'follow') {
|
|
276
|
-
const p = this.map.project(this.latlngs[i], data.zoom);
|
|
277
|
-
dx = p.x - layout.c0.x;
|
|
278
|
-
dy = p.y - layout.c0.y;
|
|
279
|
-
}
|
|
280
|
-
mapEl.style.transform =
|
|
281
|
-
'translate(' + (layout.vw / 2 - layout.bigW / 2 - k * dx) + 'px,' +
|
|
282
|
-
(layout.vh / 2 - layout.bigH / 2 - k * dy) + 'px) scale(' + k + ')';
|
|
283
|
-
if (decor.wrapEl) {
|
|
284
|
-
decor.wrapEl.style.transform = k === 1 ? '' : 'scale(' + 1 / k + ')';
|
|
285
|
-
}
|
|
286
|
-
this.scalelineEl.style.width = Math.round((layout.bestM / layout.mPerPx) * k) + 'px';
|
|
287
|
-
if (data.hud.heading && decor.arrowEl) {
|
|
288
|
-
decor.arrowEl.style.transform = 'rotate(' + data.headingDeg[i] + 'deg)';
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
updateHud(i) {
|
|
292
|
-
// A disabled chip and a missing sample share one presentation: the dimmed
|
|
293
|
-
// "--" placeholder instead of a value (#272 review).
|
|
294
|
-
this.setReadout(this.altChip, this.data.hud.alt ? this.data.alt[i] : null, (a) => String(Math.round(a)));
|
|
295
|
-
this.setReadout(this.speedChip, this.data.hud.speed ? this.data.speed[i] : null, (s) => s.toFixed(1));
|
|
296
|
-
this.setHeading(this.headingChip, this.data.headingDeg[i]);
|
|
297
|
-
}
|
|
298
|
-
/** The heading pill rotates its arrow like the marker does; a missing
|
|
299
|
-
sample falls back to the dimmed "--", matching the preview chip (#283). */
|
|
300
|
-
setHeading(chip, deg) {
|
|
301
|
-
if (!chip)
|
|
302
|
-
return;
|
|
303
|
-
const missing = deg === null || deg === undefined;
|
|
304
|
-
const arrow = chip.querySelector('.chip-arrow');
|
|
305
|
-
const num = chip.querySelector('.num');
|
|
306
|
-
if (arrow) {
|
|
307
|
-
arrow.style.display = missing ? 'none' : '';
|
|
308
|
-
if (!missing)
|
|
309
|
-
arrow.style.transform = 'rotate(' + deg + 'deg)';
|
|
310
|
-
}
|
|
311
|
-
if (num)
|
|
312
|
-
num.style.display = missing ? '' : 'none';
|
|
313
|
-
}
|
|
314
|
-
setReadout(chip, value, format) {
|
|
315
|
-
if (!chip)
|
|
316
|
-
return;
|
|
317
|
-
setChipText(chip.querySelector('.num'), value, format);
|
|
318
|
-
if (this.externalHud)
|
|
319
|
-
chip.classList.toggle('map-readout-off', isPlaceholder(value));
|
|
320
|
-
}
|
|
321
|
-
setFrame(i) {
|
|
322
|
-
this.curIdx = i;
|
|
323
|
-
this.decor.trailCtl.setFrame(i);
|
|
324
|
-
this.decor.drone.setLatLng(this.latlngs[i]);
|
|
325
|
-
const k = introOutroScale(i, this.data.introN, this.data.outroN, this.data.lat.length);
|
|
326
|
-
this.updateTransform(i, k);
|
|
327
|
-
this.updateHud(i);
|
|
328
|
-
// Canvas painting is deferred to requestAnimationFrame
|
|
329
|
-
return new Promise((resolve) => {
|
|
330
|
-
requestAnimationFrame(() => {
|
|
331
|
-
requestAnimationFrame(() => resolve());
|
|
332
|
-
});
|
|
333
|
-
});
|
|
334
|
-
}
|
|
335
|
-
relayout() {
|
|
336
|
-
this.layoutMap();
|
|
337
|
-
void this.setFrame(this.curIdx);
|
|
338
|
-
}
|
|
339
|
-
update(next) {
|
|
340
|
-
const prev = this.data;
|
|
341
|
-
this.data = next;
|
|
342
|
-
if (next.lat !== prev.lat) {
|
|
343
|
-
this.latlngs = this.latlngsOf(next);
|
|
344
|
-
this.bb = this.L.latLngBounds(this.latlngs);
|
|
345
|
-
}
|
|
346
|
-
const chromeChanged = next.style !== prev.style ||
|
|
347
|
-
next.trailColor !== prev.trailColor ||
|
|
348
|
-
next.width !== prev.width ||
|
|
349
|
-
next.height !== prev.height ||
|
|
350
|
-
next.attribution !== prev.attribution;
|
|
351
|
-
if (chromeChanged)
|
|
352
|
-
this.applyChrome();
|
|
353
|
-
if (next.style !== prev.style) {
|
|
354
|
-
// Zoom constraints are per tile layer (topo is native to z17), so a style switch swaps the layer instead of only its URL.
|
|
355
|
-
this.tiles.remove();
|
|
356
|
-
this.tiles = this.makeTileLayer(next.tileUrl, next.style);
|
|
357
|
-
this.tiles.addTo(this.map);
|
|
358
|
-
}
|
|
359
|
-
else if (next.tileUrl !== prev.tileUrl) {
|
|
360
|
-
this.tiles.setUrl(next.tileUrl);
|
|
361
|
-
}
|
|
362
|
-
const decorInvalidated = next.style !== prev.style ||
|
|
363
|
-
next.trailColor !== prev.trailColor ||
|
|
364
|
-
next.trailLat !== prev.trailLat ||
|
|
365
|
-
next.lat !== prev.lat ||
|
|
366
|
-
next.width !== prev.width ||
|
|
367
|
-
next.height !== prev.height;
|
|
368
|
-
if (decorInvalidated)
|
|
369
|
-
this.rebuildDecor();
|
|
370
|
-
if (!hudEq(prev.hud, next.hud) || next.hudPills !== prev.hudPills)
|
|
371
|
-
this.rebuildHud();
|
|
372
|
-
this.layoutMap();
|
|
373
|
-
return this.setFrame(this.curIdx);
|
|
374
|
-
}
|
|
375
|
-
dispose() {
|
|
376
|
-
clearTimeout(this.readyTimer);
|
|
377
|
-
this.settleReady();
|
|
378
|
-
this.map.remove();
|
|
379
|
-
this.styleEl.remove();
|
|
380
|
-
this.host.classList.remove(this.scopeClass);
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
export function createScene(host, firstData, deps) {
|
|
384
|
-
return new SceneState(host, firstData, deps.L, deps.hudHost);
|
|
385
|
-
}
|
package/dist/renderer/theme.js
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
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 };
|
|
43
|
-
function trailGlow(alpha) {
|
|
44
|
-
return rgba(parseHexColor(TRAIL_COLOR), alpha);
|
|
45
|
-
}
|
|
46
|
-
const THEMES = {
|
|
47
|
-
satellite: {
|
|
48
|
-
core: TRAIL_COLOR,
|
|
49
|
-
trailCore: TRAIL_COLOR,
|
|
50
|
-
glow: trailGlow(GLOW_ALPHA.satellite),
|
|
51
|
-
casing: 'rgba(10,14,20,0.9)',
|
|
52
|
-
ghost: '#ffffff',
|
|
53
|
-
ghostOpacity: 0.85,
|
|
54
|
-
ghostCasing: 'rgba(8,12,18,0.55)',
|
|
55
|
-
discBg: 'rgba(10,14,20,0.82)',
|
|
56
|
-
vignette: 0.16,
|
|
57
|
-
},
|
|
58
|
-
topo: {
|
|
59
|
-
core: TRAIL_COLOR,
|
|
60
|
-
trailCore: TRAIL_COLOR,
|
|
61
|
-
glow: trailGlow(GLOW_ALPHA.topo),
|
|
62
|
-
casing: '#ffffff',
|
|
63
|
-
ghost: '#6b6252',
|
|
64
|
-
ghostOpacity: 0.7,
|
|
65
|
-
ghostCasing: 'rgba(255,255,255,0.8)',
|
|
66
|
-
discBg: 'rgba(26,22,18,0.85)',
|
|
67
|
-
vignette: 0.06,
|
|
68
|
-
},
|
|
69
|
-
};
|
|
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
|
-
};
|
|
82
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
export const TILE_SOURCES = {
|
|
2
|
-
// Esri World Imagery (free for non-commercial use, attribution required).
|
|
3
|
-
satellite: {
|
|
4
|
-
cacheKey: 'esri-imagery',
|
|
5
|
-
url: 'https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}',
|
|
6
|
-
subdomains: [''],
|
|
7
|
-
attribution: 'Imagery © <a href="https://www.esri.com/">Esri</a>, Maxar, Earthstar Geographics, and the GIS User Community',
|
|
8
|
-
bg: '#0b0e14',
|
|
9
|
-
placeholderBg: '#2a2f38',
|
|
10
|
-
tileFilter: 'saturate(1.06) contrast(1.03)',
|
|
11
|
-
maxZoom: 19,
|
|
12
|
-
},
|
|
13
|
-
topo: {
|
|
14
|
-
cacheKey: 'opentopomap',
|
|
15
|
-
url: 'https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png',
|
|
16
|
-
subdomains: ['a', 'b', 'c'],
|
|
17
|
-
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, SRTM | Style: © <a href="https://opentopomap.org">OpenTopoMap</a> (CC-BY-SA)',
|
|
18
|
-
bg: '#eae5da',
|
|
19
|
-
placeholderBg: '#eae5da',
|
|
20
|
-
tileFilter: null,
|
|
21
|
-
maxZoom: 19,
|
|
22
|
-
maxNativeZoom: 17,
|
|
23
|
-
},
|
|
24
|
-
};
|
|
25
|
-
/** Leaflet wants HTML and the map style thumbnails plain text; the thumbnail
|
|
26
|
-
credits derive from these attributions so the wording can never drift. */
|
|
27
|
-
function plainCredit(html) {
|
|
28
|
-
return html
|
|
29
|
-
.replaceAll('©', '©')
|
|
30
|
-
.replace(/<a [^>]+>/g, '')
|
|
31
|
-
.replaceAll('</a>', '')
|
|
32
|
-
.split(' | ')
|
|
33
|
-
.map((part) => part.replace('Style: ', 'Style ')); // the thumbnail wording drops the colon
|
|
34
|
-
}
|
|
35
|
-
export const TILE_CREDITS = [
|
|
36
|
-
...plainCredit(TILE_SOURCES.satellite.attribution),
|
|
37
|
-
...plainCredit(TILE_SOURCES.topo.attribution),
|
|
38
|
-
].join(' · ');
|
package/dist/renderer/trail.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
export function lastIndexAtOrBefore(trailFrame, i) {
|
|
2
|
-
let lo = 0;
|
|
3
|
-
let hi = trailFrame.length - 1;
|
|
4
|
-
let k = -1;
|
|
5
|
-
while (lo <= hi) {
|
|
6
|
-
const mid = (lo + hi) >> 1;
|
|
7
|
-
if (trailFrame[mid] <= i) {
|
|
8
|
-
k = mid;
|
|
9
|
-
lo = mid + 1;
|
|
10
|
-
}
|
|
11
|
-
else {
|
|
12
|
-
hi = mid - 1;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
return k;
|
|
16
|
-
}
|
|
17
|
-
export function createTrailController(trail, frames, layers) {
|
|
18
|
-
let lastFrame = null;
|
|
19
|
-
let drawn = false;
|
|
20
|
-
return {
|
|
21
|
-
setFrame(i) {
|
|
22
|
-
if (i === lastFrame)
|
|
23
|
-
return;
|
|
24
|
-
const tip = i >= 0 && i < frames.lat.length ? [frames.lat[i], frames.lon[i]] : null;
|
|
25
|
-
// A kept point at exactly frame i would duplicate the tip's position.
|
|
26
|
-
let end = lastIndexAtOrBefore(trail.frame, i);
|
|
27
|
-
if (tip !== null && trail.frame[end] === i)
|
|
28
|
-
end -= 1;
|
|
29
|
-
const points = [];
|
|
30
|
-
for (let j = 0; j <= end; j++)
|
|
31
|
-
points.push([trail.lat[j], trail.lon[j]]);
|
|
32
|
-
if (tip !== null)
|
|
33
|
-
points.push(tip);
|
|
34
|
-
lastFrame = i;
|
|
35
|
-
if (points.length === 0 && !drawn)
|
|
36
|
-
return;
|
|
37
|
-
drawn = points.length > 0;
|
|
38
|
-
for (const layer of layers)
|
|
39
|
-
layer.setLatLngs(points);
|
|
40
|
-
},
|
|
41
|
-
};
|
|
42
|
-
}
|
package/dist/restyle.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { buildSceneData, planPageOpts } from './render-page.js';
|
|
2
|
-
export function restyleSceneData(prev, config, meta, size = { width: prev.width, height: prev.height }) {
|
|
3
|
-
const planned = planPageOpts({
|
|
4
|
-
bbox: meta.bbox,
|
|
5
|
-
width: size.width,
|
|
6
|
-
height: size.height,
|
|
7
|
-
config,
|
|
8
|
-
source: { fps: meta.fps, frames: meta.frames },
|
|
9
|
-
frames: prev,
|
|
10
|
-
previous: {
|
|
11
|
-
zoom: prev.zoom,
|
|
12
|
-
decimated: { lat: prev.trailLat, lon: prev.trailLon, frame: prev.trailFrame },
|
|
13
|
-
},
|
|
14
|
-
});
|
|
15
|
-
return buildSceneData(planned, meta.tileBase);
|
|
16
|
-
}
|
package/dist/serve.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import { createRequire } from 'node:module';
|
|
4
|
-
import { fileURLToPath } from 'node:url';
|
|
5
|
-
import { resolveAsset } from './assets.js';
|
|
6
|
-
const require_ = createRequire(import.meta.url);
|
|
7
|
-
const LEAFLET_DIR = path.dirname(require_.resolve('leaflet/dist/leaflet.js'));
|
|
8
|
-
export const RENDERER_DIR = fileURLToPath(new URL('./renderer/', import.meta.url));
|
|
9
|
-
export function serveAsset(url, res, routes) {
|
|
10
|
-
const asset = resolveAsset(url, { ...routes, leafletDir: LEAFLET_DIR });
|
|
11
|
-
if (asset.kind === 'unrouted')
|
|
12
|
-
return false;
|
|
13
|
-
if (asset.kind === 'file') {
|
|
14
|
-
let file = asset.filePath;
|
|
15
|
-
if (!fs.existsSync(file) && asset.fallbackPath && fs.existsSync(asset.fallbackPath)) {
|
|
16
|
-
file = asset.fallbackPath;
|
|
17
|
-
}
|
|
18
|
-
if (fs.existsSync(file) && fs.statSync(file).isFile()) {
|
|
19
|
-
res.writeHead(200, { 'Content-Type': asset.mime });
|
|
20
|
-
res.end(fs.readFileSync(file));
|
|
21
|
-
return true;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
res.writeHead(404, { 'Content-Type': 'text/plain' });
|
|
25
|
-
res.end('not found');
|
|
26
|
-
return true;
|
|
27
|
-
}
|
package/dist/srt.js
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { readFile } from 'node:fs/promises';
|
|
2
|
-
import { gpsFixOrNull } from './geo.js';
|
|
3
|
-
const RX_TIMING = /^(\d{2}):(\d{2}):(\d{2})[,.](\d{3})\s*-->/;
|
|
4
|
-
const RX_LATLON = /\[latitude:\s*(-?\d+\.?\d*)\]\s*\[longitude:\s*(-?\d+\.?\d*)\]/;
|
|
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*)$/;
|
|
11
|
-
function parseNumber(text) {
|
|
12
|
-
const value = Number.parseFloat(text);
|
|
13
|
-
return Number.isFinite(value) ? value : null;
|
|
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
|
-
}
|
|
24
|
-
function stripFontTags(line) {
|
|
25
|
-
return line.replace(/<[^>]*>/g, '').trim();
|
|
26
|
-
}
|
|
27
|
-
function timingLineToMs(match) {
|
|
28
|
-
return (Number(match[1]) * 3600000 +
|
|
29
|
-
Number(match[2]) * 60000 +
|
|
30
|
-
Number(match[3]) * 1000 +
|
|
31
|
-
Number(match[4]));
|
|
32
|
-
}
|
|
33
|
-
function newCue(tSec) {
|
|
34
|
-
return {
|
|
35
|
-
tSec,
|
|
36
|
-
fix: null,
|
|
37
|
-
relAlt: null,
|
|
38
|
-
absAlt: null,
|
|
39
|
-
iso: null,
|
|
40
|
-
shutterTime: null,
|
|
41
|
-
whiteBalanceCctK: null,
|
|
42
|
-
fNumber: null,
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
export function parseSrtText(text) {
|
|
46
|
-
const cues = [];
|
|
47
|
-
let noLock = 0;
|
|
48
|
-
let baseMs = null;
|
|
49
|
-
let cueSawLatLon = false;
|
|
50
|
-
for (const rawLine of text.split(/\r?\n/)) {
|
|
51
|
-
const line = stripFontTags(rawLine);
|
|
52
|
-
if (!line)
|
|
53
|
-
continue;
|
|
54
|
-
const timing = RX_TIMING.exec(line);
|
|
55
|
-
if (timing) {
|
|
56
|
-
const ms = timingLineToMs(timing);
|
|
57
|
-
baseMs ??= ms;
|
|
58
|
-
cues.push(newCue((ms - baseMs) / 1000));
|
|
59
|
-
cueSawLatLon = false;
|
|
60
|
-
continue;
|
|
61
|
-
}
|
|
62
|
-
if (cues.length === 0)
|
|
63
|
-
continue;
|
|
64
|
-
const cue = cues[cues.length - 1];
|
|
65
|
-
const latLon = RX_LATLON.exec(line);
|
|
66
|
-
if (latLon && !cueSawLatLon) {
|
|
67
|
-
cueSawLatLon = true;
|
|
68
|
-
const fix = gpsFixOrNull(parseNumber(latLon[1]), parseNumber(latLon[2]));
|
|
69
|
-
if (fix !== null) {
|
|
70
|
-
cue.fix = fix;
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
noLock++;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
const alt = RX_ALT.exec(line);
|
|
77
|
-
if (alt && cue.relAlt === null) {
|
|
78
|
-
cue.relAlt = parseNumber(alt[1]);
|
|
79
|
-
cue.absAlt = parseNumber(alt[2]);
|
|
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]);
|
|
93
|
-
}
|
|
94
|
-
return { cues, noLock, count: cues.length };
|
|
95
|
-
}
|
|
96
|
-
export async function parseSrt(path) {
|
|
97
|
-
return parseSrtText(await readFile(path, 'utf8'));
|
|
98
|
-
}
|