-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
625 lines (548 loc) · 23.8 KB
/
index.html
File metadata and controls
625 lines (548 loc) · 23.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>GeoTool — Aerial Georeferencer</title>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css"/>
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
<style>
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=IBM+Plex+Sans:wght@300;400;500&display=swap');
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
--bg: #0f1117;
--surface: #181c27;
--panel: #1e2333;
--border: #2e3450;
--accent: #4f8ef7;
--accent2: #f7a24f;
--danger: #f75f5f;
--success: #4fd183;
--text: #d4d8ee;
--muted: #6b7599;
--mono: 'IBM Plex Mono', monospace;
--sans: 'IBM Plex Sans', sans-serif;
--header-h: 52px;
--sidebar-w: 320px;
}
html, body { height: 100%; background: var(--bg); color: var(--text); font-family: var(--sans); font-size: 14px; }
/* ── header ── */
header {
height: var(--header-h);
background: var(--surface);
border-bottom: 1px solid var(--border);
display: flex; align-items: center; gap: 16px;
padding: 0 20px;
position: relative; z-index: 900;
}
header .logo { font-family: var(--mono); font-size: 15px; font-weight: 500; color: var(--accent); letter-spacing: .04em; }
header .logo span { color: var(--muted); }
.mode-tabs { display: flex; gap: 4px; margin-left: auto; }
.mode-tab {
font-family: var(--mono); font-size: 11px; font-weight: 500;
padding: 5px 14px; border-radius: 4px; border: 1px solid var(--border);
background: transparent; color: var(--muted); cursor: pointer;
transition: all .15s;
}
.mode-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.mode-tab:hover:not(.active) { border-color: var(--accent); color: var(--accent); }
/* ── layout ── */
.workspace {
height: calc(100vh - var(--header-h));
display: flex;
}
/* ── sidebar ── */
.sidebar {
width: var(--sidebar-w);
background: var(--surface);
border-right: 1px solid var(--border);
display: flex; flex-direction: column;
overflow: hidden; flex-shrink: 0;
}
.sidebar-section { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.sidebar-section h3 { font-family: var(--mono); font-size: 10px; font-weight: 500; letter-spacing: .1em; color: var(--muted); text-transform: uppercase; margin-bottom: 10px; }
.image-info { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.image-info strong { color: var(--text); }
/* GCP list */
.gcp-list { flex: 1; overflow-y: auto; padding: 8px; }
.gcp-item {
background: var(--panel);
border: 1px solid var(--border);
border-radius: 6px;
padding: 8px 10px;
margin-bottom: 6px;
display: flex; align-items: flex-start; gap: 8px;
animation: slide-in .15s ease;
}
@keyframes slide-in { from { opacity:0; transform: translateX(-8px); } to { opacity:1; transform: none; } }
.gcp-num {
width: 20px; height: 20px; border-radius: 50%;
background: var(--accent); color: #fff;
font-family: var(--mono); font-size: 10px; font-weight: 500;
display: flex; align-items: center; justify-content: center;
flex-shrink: 0; margin-top: 1px;
}
.gcp-num.complete { background: var(--success); }
.gcp-num.partial { background: var(--accent2); }
.gcp-coords { flex: 1; }
.gcp-row { font-family: var(--mono); font-size: 10px; color: var(--muted); line-height: 1.7; }
.gcp-row span { color: var(--text); }
.gcp-del { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 14px; padding: 0 2px; }
.gcp-del:hover { color: var(--danger); }
/* step indicator */
.step-indicator {
display: flex; align-items: center; gap: 6px;
padding: 10px 16px;
border-bottom: 1px solid var(--border);
background: var(--panel);
}
.step-dot {
width: 8px; height: 8px; border-radius: 50%;
background: var(--border); transition: background .2s;
}
.step-dot.active { background: var(--accent); box-shadow: 0 0 6px var(--accent); }
.step-dot.done { background: var(--success); }
.step-label { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.step-label.active { color: var(--accent); }
/* action buttons */
.btn {
display: block; width: 100%;
padding: 9px 16px; border-radius: 5px;
font-family: var(--mono); font-size: 12px; font-weight: 500;
border: 1px solid var(--border); cursor: pointer;
transition: all .15s; text-align: center;
}
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.15); }
.btn-primary:disabled { opacity: .4; cursor: not-allowed; filter: none; }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); margin-top: 6px; }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--muted); margin-top: 6px; }
.btn-ghost:hover { border-color: var(--text); color: var(--text); }
/* status bar */
.status-bar {
padding: 8px 16px;
font-family: var(--mono); font-size: 11px;
border-top: 1px solid var(--border);
background: var(--panel);
min-height: 34px;
}
.status-ok { color: var(--success); }
.status-warn { color: var(--accent2); }
.status-err { color: var(--danger); }
.status-working { color: var(--accent); }
/* ── main area ── */
.main { flex: 1; display: flex; overflow: hidden; }
/* pick mode: side-by-side panels */
.panels { display: flex; width: 100%; }
.panel { flex: 1; position: relative; overflow: hidden; }
.panel + .panel { border-left: 2px solid var(--border); }
.panel-label {
position: absolute; top: 10px; left: 12px; z-index: 800;
font-family: var(--mono); font-size: 10px; font-weight: 500; letter-spacing: .08em;
background: rgba(15,17,23,.8); border: 1px solid var(--border);
padding: 3px 8px; border-radius: 3px; color: var(--muted);
pointer-events: none;
}
.panel-label.waiting { color: var(--accent2); border-color: var(--accent2); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.5} }
/* aerial canvas panel */
#aerial-panel { background: #000; cursor: crosshair; }
#aerial-canvas { display: block; width: 100%; height: 100%; }
.aerial-marker {
position: absolute; transform: translate(-50%,-50%);
width: 20px; height: 20px; border-radius: 50%;
border: 2px solid #fff;
font-family: var(--mono); font-size: 9px; color: #fff;
display: flex; align-items: center; justify-content: center;
pointer-events: none; font-weight: 500;
box-shadow: 0 0 0 1px rgba(0,0,0,.5);
}
/* OSM leaflet panel */
#osm-panel { position: relative; }
#osm-map { width: 100%; height: 100%; }
/* overlay mode */
#overlay-panel { display: none; width: 100%; position: relative; }
#overlay-map { width: 100%; height: 100%; }
.opacity-bar {
position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%);
z-index: 800; background: rgba(15,17,23,.9);
border: 1px solid var(--border); border-radius: 6px;
padding: 8px 14px; display: flex; align-items: center; gap: 10px;
font-family: var(--mono); font-size: 11px; color: var(--muted);
}
.opacity-bar input[type=range] { width: 160px; accent-color: var(--accent); }
/* crosshair on OSM during picking */
#osm-map.picking { cursor: crosshair !important; }
.leaflet-container.picking { cursor: crosshair !important; }
/* pending GCP highlight banner */
#pick-banner {
display: none;
position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
z-index: 850;
background: var(--accent2); color: #0f1117;
font-family: var(--mono); font-size: 11px; font-weight: 500;
padding: 6px 14px; border-radius: 4px;
white-space: nowrap; pointer-events: none;
}
/* scrollbar */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
</style>
</head>
<body>
<header>
<div class="logo">geo<span>/</span>tool</div>
<div class="mode-tabs">
<button class="mode-tab active" id="tab-pick" onclick="setMode('pick')">① GCP picker</button>
<button class="mode-tab" id="tab-overlay" onclick="setMode('overlay')" id="tab-overlay">② OSM overlay</button>
</div>
</header>
<div class="workspace">
<!-- ── sidebar ── -->
<aside class="sidebar">
<div class="step-indicator">
<div class="step-dot active" id="dot-1"></div>
<div class="step-label active" id="lbl-1">Click aerial</div>
<div style="width:18px;height:1px;background:var(--border)"></div>
<div class="step-dot" id="dot-2"></div>
<div class="step-label" id="lbl-2">Click OSM</div>
<div style="width:18px;height:1px;background:var(--border)"></div>
<div class="step-dot" id="dot-3"></div>
<div class="step-label" id="lbl-3">Warp</div>
</div>
<div class="sidebar-section">
<h3>Image</h3>
<div class="image-info" id="img-info">Loading…</div>
</div>
<div class="sidebar-section" style="flex-shrink:0">
<h3>Ground control points <span id="gcp-count" style="color:var(--accent)">0</span></h3>
<div style="font-family:var(--mono);font-size:10px;color:var(--muted);margin-bottom:4px">
Min 4 required · spread across image
</div>
</div>
<div class="gcp-list" id="gcp-list">
<div style="text-align:center;color:var(--muted);font-family:var(--mono);font-size:11px;margin-top:24px">
No GCPs yet.<br>Click a point on the aerial image to start.
</div>
</div>
<div style="padding:12px 16px;flex-shrink:0">
<button class="btn btn-primary" id="warp-btn" onclick="doWarp()" disabled>
▶ Generate GeoTIFF
</button>
<button class="btn btn-danger" onclick="clearGCPs()">✕ Clear all GCPs</button>
</div>
<div class="status-bar" id="status">Ready — click a point on the aerial</div>
</aside>
<!-- ── main ── -->
<main class="main">
<!-- pick mode -->
<div class="panels" id="pick-mode">
<!-- aerial panel -->
<div class="panel" id="aerial-panel">
<div class="panel-label" id="aerial-label">AERIAL — click to place GCP</div>
<canvas id="aerial-canvas"></canvas>
</div>
<!-- OSM panel -->
<div class="panel" id="osm-panel">
<div class="panel-label" id="osm-label">OSM — navigate to matching point</div>
<div id="pick-banner">▶ Now click the matching location on OSM</div>
<div id="osm-map"></div>
</div>
</div>
<!-- overlay mode -->
<div id="overlay-panel">
<div id="overlay-map"></div>
<div class="opacity-bar">
<span>Aerial opacity</span>
<input type="range" min="0" max="100" value="70" id="opacity-slider" oninput="setOverlayOpacity(this.value)">
<span id="opacity-val">70%</span>
</div>
</div>
</main>
</div>
<script>
// ── state ─────────────────────────────────────────────────────────────────────
let gcps = [];
let pendingAerial = null; // {px, py} waiting for OSM click
let imgW = 0, imgH = 0;
let osmMap, overlayMap, overlayLayer;
let aerialImg = new Image();
let canvas, ctx;
let canvasScale = 1, panX = 0, panY = 0;
let isPanning = false, lastMouse = null;
// ── init ──────────────────────────────────────────────────────────────────────
window.addEventListener('DOMContentLoaded', async () => {
canvas = document.getElementById('aerial-canvas');
ctx = canvas.getContext('2d');
// fetch image info
const info = await fetch('/image/info').then(r => r.json());
imgW = info.width; imgH = info.height;
document.getElementById('img-info').innerHTML =
`<strong>${info.path.split('/').pop()}</strong><br>${imgW} × ${imgH} px`;
// load image
aerialImg.src = '/image/raw';
aerialImg.onload = () => { fitCanvas(); drawAerial(); };
// resize
const ro = new ResizeObserver(fitCanvas);
ro.observe(document.getElementById('aerial-panel'));
// OSM map
osmMap = L.map('osm-map', { zoomControl: true }).setView([31.9, 34.82], 14);
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© OpenStreetMap contributors', maxZoom: 19
}).addTo(osmMap);
osmMap.on('click', onOSMClick);
loadGCPs();
});
// ── canvas rendering ──────────────────────────────────────────────────────────
function fitCanvas() {
const panel = document.getElementById('aerial-panel');
canvas.width = panel.clientWidth;
canvas.height = panel.clientHeight;
// fit image to canvas on first load
const scaleX = canvas.width / imgW;
const scaleY = canvas.height / imgH;
canvasScale = Math.min(scaleX, scaleY) * 0.95;
panX = (canvas.width - imgW * canvasScale) / 2;
panY = (canvas.height - imgH * canvasScale) / 2;
drawAerial();
}
function drawAerial() {
if (!ctx) return;
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.fillStyle = '#0a0a0a';
ctx.fillRect(0, 0, canvas.width, canvas.height);
if (aerialImg.complete && imgW) {
ctx.save();
ctx.translate(panX, panY);
ctx.scale(canvasScale, canvasScale);
ctx.drawImage(aerialImg, 0, 0);
ctx.restore();
}
// draw GCP markers
gcps.forEach((g, i) => {
const cx = panX + g.px * canvasScale;
const cy = panY + g.py * canvasScale;
drawMarker(cx, cy, i + 1, g.lon !== undefined ? 'complete' : 'partial');
});
// draw pending
if (pendingAerial) {
const cx = panX + pendingAerial.px * canvasScale;
const cy = panY + pendingAerial.py * canvasScale;
drawMarker(cx, cy, gcps.length + 1, 'partial');
}
}
function drawMarker(cx, cy, num, type) {
const color = type === 'complete' ? '#4fd183' : type === 'partial' ? '#f7a24f' : '#4f8ef7';
ctx.save();
// crosshair lines
ctx.strokeStyle = color; ctx.lineWidth = 1; ctx.globalAlpha = .7;
ctx.beginPath(); ctx.moveTo(cx - 12, cy); ctx.lineTo(cx + 12, cy); ctx.stroke();
ctx.beginPath(); ctx.moveTo(cx, cy - 12); ctx.lineTo(cx, cy + 12); ctx.stroke();
// circle
ctx.beginPath(); ctx.arc(cx, cy, 8, 0, Math.PI * 2);
ctx.strokeStyle = color; ctx.lineWidth = 1.5; ctx.globalAlpha = 1;
ctx.fillStyle = 'rgba(0,0,0,.55)'; ctx.fill(); ctx.stroke();
// number
ctx.fillStyle = '#fff'; ctx.font = 'bold 9px IBM Plex Mono, monospace';
ctx.textAlign = 'center'; ctx.textBaseline = 'middle';
ctx.fillText(num, cx, cy);
ctx.restore();
}
// ── canvas interaction ────────────────────────────────────────────────────────
canvas.addEventListener('click', e => {
if (isPanning) return;
const rect = canvas.getBoundingClientRect();
const mx = e.clientX - rect.left;
const my = e.clientY - rect.top;
const px = (mx - panX) / canvasScale;
const py = (my - panY) / canvasScale;
if (px < 0 || py < 0 || px > imgW || py > imgH) return;
pendingAerial = { px, py };
setStatus('Now click the matching road intersection on the OSM map →', 'warn');
stepTo(2);
document.getElementById('pick-banner').style.display = 'block';
document.getElementById('osm-map').classList.add('picking');
document.getElementById('aerial-label').textContent = 'AERIAL — point placed ✓';
document.getElementById('osm-label').classList.add('waiting');
document.getElementById('osm-label').textContent = 'OSM — click matching location';
drawAerial();
});
// pan + zoom
canvas.addEventListener('wheel', e => {
e.preventDefault();
const rect = canvas.getBoundingClientRect();
const mx = e.clientX - rect.left;
const my = e.clientY - rect.top;
const delta = e.deltaY < 0 ? 1.12 : 1 / 1.12;
panX = mx - (mx - panX) * delta;
panY = my - (my - panY) * delta;
canvasScale *= delta;
drawAerial();
}, { passive: false });
canvas.addEventListener('mousedown', e => {
if (e.button === 1 || e.button === 2) { isPanning = true; lastMouse = { x: e.clientX, y: e.clientY }; }
});
canvas.addEventListener('mousemove', e => {
if (!isPanning) return;
panX += e.clientX - lastMouse.x;
panY += e.clientY - lastMouse.y;
lastMouse = { x: e.clientX, y: e.clientY };
drawAerial();
});
canvas.addEventListener('mouseup', () => isPanning = false);
canvas.addEventListener('contextmenu', e => { e.preventDefault(); isPanning = false; });
// ── OSM click ─────────────────────────────────────────────────────────────────
function onOSMClick(e) {
if (!pendingAerial) return;
const { lat, lng } = e.latlng;
// add GCP
const gcp = {
id: Date.now(),
px: pendingAerial.px,
py: pendingAerial.py,
lon: lng,
lat: lat,
label: `GCP ${gcps.length + 1}`,
};
fetch('/gcps', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(gcp),
}).then(r => r.json()).then(saved => {
gcp.id = saved.id;
gcps.push(gcp);
// OSM marker
L.circleMarker([lat, lng], {
radius: 7, color: '#4fd183', fillColor: '#4fd183',
fillOpacity: .7, weight: 2,
}).bindTooltip(gcp.label).addTo(osmMap);
pendingAerial = null;
document.getElementById('pick-banner').style.display = 'none';
document.getElementById('osm-map').classList.remove('picking');
document.getElementById('osm-label').classList.remove('waiting');
document.getElementById('aerial-label').textContent = 'AERIAL — click to place GCP';
document.getElementById('osm-label').textContent = 'OSM — navigate to matching point';
stepTo(1);
renderGCPList();
drawAerial();
setStatus(`GCP ${gcps.length} added — (${lat.toFixed(5)}, ${lng.toFixed(5)})`, 'ok');
if (gcps.length >= 4) {
document.getElementById('warp-btn').disabled = false;
stepTo(3);
}
});
}
// ── GCP list rendering ────────────────────────────────────────────────────────
function renderGCPList() {
const list = document.getElementById('gcp-list');
document.getElementById('gcp-count').textContent = gcps.length;
if (!gcps.length) {
list.innerHTML = `<div style="text-align:center;color:var(--muted);font-family:var(--mono);font-size:11px;margin-top:24px">No GCPs yet.<br>Click a point on the aerial image to start.</div>`;
return;
}
list.innerHTML = gcps.map(g => `
<div class="gcp-item">
<div class="gcp-num complete">${gcps.indexOf(g) + 1}</div>
<div class="gcp-coords">
<div class="gcp-row">px <span>${Math.round(g.px)}, ${Math.round(g.py)}</span></div>
<div class="gcp-row">lon <span>${g.lon.toFixed(5)}</span> lat <span>${g.lat.toFixed(5)}</span></div>
</div>
<button class="gcp-del" onclick="deleteGCP(${g.id})" title="Remove">✕</button>
</div>
`).join('');
}
async function loadGCPs() {
const data = await fetch('/gcps').then(r => r.json());
gcps = data;
renderGCPList();
if (gcps.length >= 4) document.getElementById('warp-btn').disabled = false;
drawAerial();
}
async function deleteGCP(id) {
await fetch(`/gcps/${id}`, { method: 'DELETE' });
gcps = gcps.filter(g => g.id !== id);
renderGCPList();
drawAerial();
if (gcps.length < 4) document.getElementById('warp-btn').disabled = true;
}
async function clearGCPs() {
await fetch('/gcps/clear', { method: 'POST' });
gcps = [];
pendingAerial = null;
renderGCPList();
drawAerial();
document.getElementById('warp-btn').disabled = true;
setStatus('GCPs cleared', 'warn');
}
// ── warp ──────────────────────────────────────────────────────────────────────
async function doWarp() {
setStatus('Warping… this may take 30–60 s for large images', 'working');
document.getElementById('warp-btn').disabled = true;
document.getElementById('warp-btn').textContent = '⏳ Warping…';
const res = await fetch('/warp', { method: 'POST' });
const data = await res.json();
document.getElementById('warp-btn').textContent = '▶ Generate GeoTIFF';
document.getElementById('warp-btn').disabled = false;
if (data.error) {
setStatus('Error: ' + data.error, 'err');
return;
}
setStatus('GeoTIFF created ✓ — switching to overlay view', 'ok');
stepDone(3);
document.getElementById('tab-overlay').disabled = false;
setTimeout(() => setMode('overlay'), 800);
}
// ── overlay mode ──────────────────────────────────────────────────────────────
async function initOverlay() {
if (overlayMap) { overlayMap.invalidateSize(); return; }
overlayMap = L.map('overlay-map').setView([31.9, 34.82], 14);
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© OpenStreetMap contributors', maxZoom: 19
}).addTo(overlayMap);
const info = await fetch('/geotiff/bounds').then(r => r.json());
if (info.error) {
// fallback: try XYZ tiles
overlayLayer = L.tileLayer('/geotiff/tile/{z}/{x}/{y}.png', {
opacity: 0.7, maxZoom: 19, tms: false,
}).addTo(overlayMap);
return;
}
const bounds = info.bounds; // [[minLat, minLon], [maxLat, maxLon]]
overlayLayer = L.imageOverlay('/image/raw', bounds, { opacity: 0.7 })
.addTo(overlayMap);
overlayMap.fitBounds(bounds);
}
function setOverlayOpacity(val) {
document.getElementById('opacity-val').textContent = val + '%';
if (overlayLayer) overlayLayer.setOpacity(val / 100);
}
// ── mode switching ────────────────────────────────────────────────────────────
function setMode(mode) {
document.getElementById('pick-mode').style.display = mode === 'pick' ? 'flex' : 'none';
document.getElementById('overlay-panel').style.display = mode === 'overlay' ? 'block' : 'none';
document.getElementById('tab-pick').classList.toggle('active', mode === 'pick');
document.getElementById('tab-overlay').classList.toggle('active', mode === 'overlay');
if (mode === 'overlay') initOverlay();
if (mode === 'pick') setTimeout(drawAerial, 50);
}
// ── step indicator ────────────────────────────────────────────────────────────
function stepTo(n) {
[1,2,3].forEach(i => {
document.getElementById(`dot-${i}`).className = 'step-dot' + (i < n ? ' done' : i === n ? ' active' : '');
document.getElementById(`lbl-${i}`).className = 'step-label' + (i === n ? ' active' : '');
});
}
function stepDone(n) {
document.getElementById(`dot-${n}`).className = 'step-dot done';
}
// ── status ────────────────────────────────────────────────────────────────────
function setStatus(msg, type='') {
const el = document.getElementById('status');
el.textContent = msg;
el.className = 'status-bar' + (type ? ` status-${type}` : '');
}
</script>
</body>
</html>