drone-path-archive 1.1.0 → 1.1.1
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/export-map.d.ts +3 -1
- package/dist/export-map.js +64 -6
- package/dist/export.d.ts +3 -1
- package/dist/export.js +1 -1
- package/package.json +2 -2
package/dist/export-map.d.ts
CHANGED
|
@@ -8,5 +8,7 @@ interface MapClip {
|
|
|
8
8
|
export interface MapFlight {
|
|
9
9
|
clips: MapClip[];
|
|
10
10
|
}
|
|
11
|
-
export declare function archiveMapHtml(flights: readonly MapFlight[]
|
|
11
|
+
export declare function archiveMapHtml(flights: readonly MapFlight[], { offline }?: {
|
|
12
|
+
offline?: boolean;
|
|
13
|
+
}): string;
|
|
12
14
|
export {};
|
package/dist/export-map.js
CHANGED
|
@@ -2,6 +2,23 @@ import fs from 'node:fs';
|
|
|
2
2
|
import { createRequire } from 'node:module';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
const require = createRequire(import.meta.url);
|
|
5
|
+
// The video renderer has a self-contained module graph and serves tiles through its local cache.
|
|
6
|
+
const BASEMAPS = {
|
|
7
|
+
satellite: {
|
|
8
|
+
url: 'https://ibasemaps-api.arcgis.com/arcgis/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}',
|
|
9
|
+
subdomains: [''],
|
|
10
|
+
attribution: '<a href="https://www.esri.com/">Powered by Esri</a> | Imagery © Esri, Vantor, Earthstar Geographics, and the GIS User Community',
|
|
11
|
+
maxZoom: 19,
|
|
12
|
+
},
|
|
13
|
+
topo: {
|
|
14
|
+
url: 'https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png',
|
|
15
|
+
subdomains: ['a', 'b', 'c'],
|
|
16
|
+
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, SRTM | Style: © <a href="https://opentopomap.org">OpenTopoMap</a> (CC-BY-SA)',
|
|
17
|
+
maxZoom: 19,
|
|
18
|
+
maxNativeZoom: 17,
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
const tileOrigins = [...new Set(Object.values(BASEMAPS).flatMap(({ url, subdomains }) => subdomains.map((subdomain) => new URL(url.replace('{s}', subdomain)).origin)))].join(' ');
|
|
5
22
|
function leafletAssets() {
|
|
6
23
|
const root = path.dirname(require.resolve('leaflet/package.json'));
|
|
7
24
|
const read = (file) => fs.readFileSync(path.join(root, file), 'utf8');
|
|
@@ -11,11 +28,42 @@ function leafletAssets() {
|
|
|
11
28
|
const css = read('dist/leaflet.css').replace(/url\([^)]*\)/gu, 'none');
|
|
12
29
|
return { script, css, license: read('LICENSE') };
|
|
13
30
|
}
|
|
14
|
-
function
|
|
31
|
+
function basemapClient() {
|
|
32
|
+
return String.raw `
|
|
33
|
+
const { satellite, topo } = ${JSON.stringify(BASEMAPS)};
|
|
34
|
+
const { url: topoUrl, ...topoOptions } = topo;
|
|
35
|
+
const { url: imageryUrl, ...imageryOptions } = satellite;
|
|
36
|
+
const imagery = L.layerGroup();
|
|
37
|
+
const baseLayers = {
|
|
38
|
+
Topographic: L.tileLayer(topoUrl, topoOptions).addTo(map),
|
|
39
|
+
'Esri imagery': imagery,
|
|
40
|
+
'No basemap': L.layerGroup(),
|
|
41
|
+
};
|
|
42
|
+
const credentials = document.querySelector('#esri-credentials');
|
|
43
|
+
const apiKey = document.querySelector('#esri-key');
|
|
44
|
+
const tileError = document.querySelector('#esri-tile-error');
|
|
45
|
+
map.on('baselayerchange', ({ layer }) => {
|
|
46
|
+
credentials.hidden = layer !== imagery;
|
|
47
|
+
});
|
|
48
|
+
credentials.addEventListener('submit', (event) => {
|
|
49
|
+
event.preventDefault();
|
|
50
|
+
const key = apiKey.value.trim();
|
|
51
|
+
if (!key || !map.hasLayer(imagery)) return;
|
|
52
|
+
apiKey.value = '';
|
|
53
|
+
tileError.hidden = true;
|
|
54
|
+
imagery.clearLayers();
|
|
55
|
+
L.tileLayer(imageryUrl + '?token=' + encodeURIComponent(key), imageryOptions)
|
|
56
|
+
.on('tileerror', () => { tileError.hidden = false; })
|
|
57
|
+
.addTo(imagery);
|
|
58
|
+
});
|
|
59
|
+
`;
|
|
60
|
+
}
|
|
61
|
+
function mapClient(offline) {
|
|
15
62
|
// Kept separate from export data: popup text is only assigned to DOM nodes.
|
|
16
63
|
return String.raw `
|
|
17
64
|
const flights = JSON.parse(document.querySelector('#archive-data').textContent);
|
|
18
|
-
const map = L.map('map'
|
|
65
|
+
const map = L.map('map');
|
|
66
|
+
${offline ? 'const baseLayers = {};' : basemapClient()}
|
|
19
67
|
const bounds = L.latLngBounds([]);
|
|
20
68
|
const colors = ['#1565c0', '#a33e00', '#00736e', '#a12466', '#613aa1', '#537421'];
|
|
21
69
|
const anchor = flights.flatMap((flight) => flight.clips)
|
|
@@ -55,7 +103,10 @@ for (const [index, flight] of flights.entries()) {
|
|
|
55
103
|
}
|
|
56
104
|
}
|
|
57
105
|
}
|
|
58
|
-
|
|
106
|
+
const overlays = hasGaze ? { 'Camera footprints': footprints.addTo(map) } : {};
|
|
107
|
+
if (Object.keys(baseLayers).length || hasGaze) {
|
|
108
|
+
L.control.layers(baseLayers, overlays, { collapsed: false }).addTo(map);
|
|
109
|
+
}
|
|
59
110
|
if (bounds.isValid()) map.fitBounds(bounds, { padding: [24, 24], maxZoom: 17 });
|
|
60
111
|
else {
|
|
61
112
|
map.setView([0, 0], 2);
|
|
@@ -63,7 +114,7 @@ else {
|
|
|
63
114
|
}
|
|
64
115
|
`;
|
|
65
116
|
}
|
|
66
|
-
export function archiveMapHtml(flights) {
|
|
117
|
+
export function archiveMapHtml(flights, { offline = false } = {}) {
|
|
67
118
|
const { script, css, license } = leafletAssets();
|
|
68
119
|
const data = JSON.stringify(flights).replaceAll('<', '\\u003c');
|
|
69
120
|
return `<!doctype html>
|
|
@@ -71,24 +122,31 @@ export function archiveMapHtml(flights) {
|
|
|
71
122
|
<head>
|
|
72
123
|
<meta charset="utf-8">
|
|
73
124
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
74
|
-
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'">
|
|
125
|
+
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; form-action 'none'; img-src ${offline ? "'none'" : tileOrigins}">
|
|
75
126
|
<title>Drone Path archive</title>
|
|
76
127
|
<style>
|
|
77
128
|
${css}
|
|
78
129
|
html,body,#map{height:100%;margin:0}
|
|
79
130
|
#map{background:#f4f6f7}
|
|
80
131
|
#empty{position:absolute;z-index:1000;left:50%;top:1rem;transform:translateX(-50%);padding:.6rem 1rem;background:white;border:1px solid #aeb6bd;font:1rem system-ui,sans-serif}
|
|
132
|
+
#esri-credentials{position:absolute;z-index:1000;right:10px;bottom:24px;padding:.6rem;background:white;font:.9rem system-ui,sans-serif}
|
|
81
133
|
</style>
|
|
82
134
|
</head>
|
|
83
135
|
<body>
|
|
84
136
|
<div id="map" aria-label="Flight map"></div>
|
|
85
137
|
<div id="empty" hidden>No tracks match this export.</div>
|
|
138
|
+
${offline ? '' : `<form id="esri-credentials" autocomplete="off" hidden>
|
|
139
|
+
<label for="esri-key">ArcGIS API key</label>
|
|
140
|
+
<input id="esri-key" type="password" required>
|
|
141
|
+
<button type="submit">Load Esri imagery</button>
|
|
142
|
+
<p id="esri-tile-error" role="status" hidden>Some Esri tiles could not load. Check your key and connection.</p>
|
|
143
|
+
</form>`}
|
|
86
144
|
<script type="application/json" id="archive-data">${data}</script>
|
|
87
145
|
<!--
|
|
88
146
|
${license}
|
|
89
147
|
-->
|
|
90
148
|
<script>${script}</script>
|
|
91
|
-
<script>${mapClient()}</script>
|
|
149
|
+
<script>${mapClient(offline)}</script>
|
|
92
150
|
</body>
|
|
93
151
|
</html>
|
|
94
152
|
`;
|
package/dist/export.d.ts
CHANGED
|
@@ -4,7 +4,9 @@ interface ExportOptions {
|
|
|
4
4
|
redactLaunchM?: number;
|
|
5
5
|
includeGaze?: boolean;
|
|
6
6
|
}
|
|
7
|
-
export declare function exportArchiveMap(db: string, output: string, options?: ExportOptions
|
|
7
|
+
export declare function exportArchiveMap(db: string, output: string, options?: ExportOptions & {
|
|
8
|
+
offline?: boolean;
|
|
9
|
+
}): void;
|
|
8
10
|
export declare function exportArchiveTracks(db: string, output: string, options?: Omit<ExportOptions, 'includeGaze'>): void;
|
|
9
11
|
export declare function exportArchiveMarkers(db: string, output: string, options?: {
|
|
10
12
|
filters?: ListFilters;
|
package/dist/export.js
CHANGED
|
@@ -60,7 +60,7 @@ function writeExport(db, output, content) {
|
|
|
60
60
|
export function exportArchiveMap(db, output, options = {}) {
|
|
61
61
|
if (path.extname(output).toLowerCase() !== '.html')
|
|
62
62
|
throw new Error('expected an .html output file');
|
|
63
|
-
writeExport(db, output, archiveMapHtml(exportFlights(db, options)));
|
|
63
|
+
writeExport(db, output, archiveMapHtml(exportFlights(db, options), { offline: options.offline }));
|
|
64
64
|
}
|
|
65
65
|
export function exportArchiveTracks(db, output, options = {}) {
|
|
66
66
|
const format = trackFormatOf(output);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "drone-path-archive",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Scan a local library of drone recordings.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"directory": "packages/archive"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"drone-path-core": "~1.1.
|
|
32
|
+
"drone-path-core": "~1.1.1",
|
|
33
33
|
"leaflet": "~1.9.4",
|
|
34
34
|
"p-queue": "~10.0.0"
|
|
35
35
|
}
|