forked from OpenDrift/opendrift
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgaza_reverse_optimizer_web.html
More file actions
1112 lines (963 loc) · 41.9 KB
/
Copy pathgaza_reverse_optimizer_web.html
File metadata and controls
1112 lines (963 loc) · 41.9 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
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html>
<head>
<title>Gaza Delivery - Reverse Launch Point Optimizer</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css" />
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<style>
body {
margin: 0;
padding: 15px;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
}
.app-container {
max-width: 1800px;
margin: 0 auto;
background: white;
border-radius: 15px;
box-shadow: 0 10px 30px rgba(0,0,0,0.3);
overflow: hidden;
}
.header {
background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
color: white;
padding: 25px;
text-align: center;
}
.main-tabs {
display: flex;
background: #f8f9fa;
border-bottom: 3px solid #e9ecef;
}
.tab {
flex: 1;
padding: 15px 20px;
text-align: center;
cursor: pointer;
background: #f8f9fa;
border: none;
font-weight: 600;
color: #495057;
transition: all 0.3s;
}
.tab.active {
background: white;
color: #2c3e50;
border-bottom: 3px solid #3498db;
}
.tab:hover:not(.active) {
background: #e9ecef;
}
.tab-content {
display: none;
padding: 25px;
}
.tab-content.active {
display: block;
}
.workflow-grid {
display: grid;
grid-template-columns: 400px 1fr;
gap: 25px;
height: 600px;
}
.control-panel {
background: #f8f9fa;
border-radius: 12px;
padding: 20px;
border: 2px solid #e9ecef;
overflow-y: auto;
}
.map-panel {
background: white;
border-radius: 12px;
border: 2px solid #e9ecef;
overflow: hidden;
position: relative;
}
#map {
height: 100%;
width: 100%;
}
.map-overlay {
position: absolute;
top: 10px;
left: 10px;
background: rgba(255,255,255,0.95);
padding: 15px;
border-radius: 8px;
z-index: 1000;
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
max-width: 300px;
}
.step-section {
margin: 20px 0;
padding: 20px;
border: 2px solid #e9ecef;
border-radius: 12px;
background: white;
}
.step-header {
display: flex;
align-items: center;
margin-bottom: 15px;
}
.step-number {
background: #3498db;
color: white;
width: 30px;
height: 30px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
font-weight: bold;
margin-right: 15px;
}
.step-completed .step-number {
background: #27ae60;
}
.step-active .step-number {
background: #e74c3c;
animation: pulse 2s infinite;
}
@keyframes pulse {
0% { transform: scale(1); }
50% { transform: scale(1.1); }
100% { transform: scale(1); }
}
.form-group {
margin: 15px 0;
}
label {
display: block;
font-weight: 600;
color: #2c3e50;
margin-bottom: 8px;
}
input, select, textarea {
width: 100%;
padding: 10px 15px;
border: 2px solid #e9ecef;
border-radius: 8px;
font-size: 14px;
transition: border-color 0.3s;
box-sizing: border-box;
}
input:focus, select:focus {
border-color: #3498db;
outline: none;
}
.btn {
background: #3498db;
color: white;
padding: 12px 24px;
border: none;
border-radius: 8px;
cursor: pointer;
font-weight: 600;
font-size: 14px;
transition: background 0.3s;
width: 100%;
margin: 10px 0;
}
.btn:hover {
background: #2980b9;
}
.btn.primary {
background: #e74c3c;
font-size: 16px;
padding: 15px 30px;
}
.btn.primary:hover {
background: #c0392b;
}
.btn.success {
background: #27ae60;
}
.btn.success:hover {
background: #229954;
}
.scenario-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 20px;
margin: 20px 0;
}
.scenario-card {
background: white;
border: 2px solid #e9ecef;
border-radius: 12px;
padding: 20px;
cursor: pointer;
transition: all 0.3s;
position: relative;
}
.scenario-card:hover {
border-color: #3498db;
transform: translateY(-2px);
box-shadow: 0 4px 8px rgba(52, 152, 219, 0.2);
}
.scenario-card.selected {
border-color: #e74c3c;
background: #fef9f9;
}
.scenario-card.optimized {
border-color: #27ae60;
background: #f8fff8;
}
.scenario-badge {
position: absolute;
top: -10px;
right: -10px;
background: #27ae60;
color: white;
padding: 5px 10px;
border-radius: 15px;
font-size: 12px;
font-weight: bold;
}
.results-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
gap: 20px;
margin: 20px 0;
}
.result-card {
background: white;
border: 2px solid #e9ecef;
border-radius: 12px;
padding: 20px;
}
.metric-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 15px;
margin: 15px 0;
}
.metric-item {
text-align: center;
padding: 15px;
background: #f8f9fa;
border-radius: 8px;
border: 1px solid #e9ecef;
}
.metric-value {
font-size: 24px;
font-weight: bold;
color: #3498db;
}
.metric-label {
font-size: 12px;
color: #6c757d;
margin-top: 5px;
}
.progress-bar {
background: #e9ecef;
border-radius: 10px;
height: 20px;
margin: 10px 0;
overflow: hidden;
}
.progress-fill {
background: linear-gradient(90deg, #3498db, #2980b9);
height: 100%;
transition: width 0.3s ease;
display: flex;
align-items: center;
justify-content: center;
color: white;
font-weight: bold;
font-size: 12px;
}
.status-indicator {
padding: 8px 15px;
border-radius: 20px;
font-size: 13px;
font-weight: bold;
text-align: center;
margin: 10px 0;
}
.status-waiting {
background: #ffeaa7;
color: #d63031;
}
.status-running {
background: #74b9ff;
color: #0984e3;
}
.status-complete {
background: #00b894;
color: white;
}
.coordinates-display {
background: #2c3e50;
color: white;
padding: 15px;
border-radius: 8px;
font-family: monospace;
margin: 10px 0;
}
.legend {
background: rgba(255,255,255,0.95);
padding: 15px;
border-radius: 8px;
margin: 10px;
border: 2px solid #e9ecef;
}
.legend-item {
display: flex;
align-items: center;
margin: 8px 0;
}
.legend-color {
width: 20px;
height: 20px;
border-radius: 50%;
margin-right: 10px;
border: 2px solid white;
box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.comparison-table {
width: 100%;
border-collapse: collapse;
margin: 20px 0;
background: white;
border-radius: 8px;
overflow: hidden;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.comparison-table th {
background: #3498db;
color: white;
padding: 15px;
text-align: center;
font-weight: 600;
}
.comparison-table td {
padding: 12px 15px;
text-align: center;
border-bottom: 1px solid #e9ecef;
}
.comparison-table tr:hover {
background: #f8f9fa;
}
.best-result {
background: #d5f4e6 !important;
font-weight: bold;
}
</style>
</head>
<body>
<div class="app-container">
<div class="header">
<h1>🎯 Gaza Delivery - Reverse Launch Point Optimizer</h1>
<p>Set your target destination and container specs - we'll find the optimal launch points</p>
</div>
<!-- Main Navigation Tabs -->
<div class="main-tabs">
<button class="tab active" onclick="showTab('workflow')">🔧 Optimization Workflow</button>
<button class="tab" onclick="showTab('scenarios')">📊 Scenario Comparison</button>
<button class="tab" onclick="showTab('results')">🎯 Detailed Results</button>
<button class="tab" onclick="showTab('analysis')">📈 Analysis & Charts</button>
</div>
<!-- WORKFLOW TAB -->
<div class="tab-content active" id="workflow">
<div class="workflow-grid">
<div class="control-panel">
<h3>🛠️ Optimization Setup</h3>
<!-- Step 1: Set Target -->
<div class="step-section step-active" id="step-target">
<div class="step-header">
<div class="step-number">1</div>
<div>
<h4>Set Target Destination</h4>
<p>Click on the map to set your target landing point</p>
</div>
</div>
<button class="btn" onclick="enableTargetSelection()">📍 Click Map to Set Target</button>
<div class="coordinates-display" id="target-coords">
Target: Not set
</div>
</div>
<!-- Step 2: Container Physics -->
<div class="step-section" id="step-container">
<div class="step-header">
<div class="step-number">2</div>
<div>
<h4>Configure Container</h4>
<p>Set container specifications and physics</p>
</div>
</div>
<div class="form-group">
<label>Container Preset:</label>
<select id="container-preset" onchange="loadContainerPreset()">
<option value="jerry_can_rope">5L Jerry Can with Rope (Recommended)</option>
<option value="optimized_bottle">Optimized 2L Bottle</option>
<option value="standard_bottle">Standard 2L Bottle</option>
<option value="heavy_anchor">Heavy Container with Long Rope</option>
<option value="custom">Custom Configuration</option>
</select>
</div>
<div class="metric-grid" id="container-metrics">
<div class="metric-item">
<div class="metric-value" id="container-mass">2.5</div>
<div class="metric-label">Mass (kg)</div>
</div>
<div class="metric-item">
<div class="metric-value" id="container-density">500</div>
<div class="metric-label">Density (kg/m³)</div>
</div>
<div class="metric-item">
<div class="metric-value" id="container-stability">9.1</div>
<div class="metric-label">Stability (1-10)</div>
</div>
<div class="metric-item">
<div class="metric-value" id="container-rope">5.0m</div>
<div class="metric-label">Rope Length</div>
</div>
</div>
</div>
<!-- Step 3: Search Parameters -->
<div class="step-section" id="step-search">
<div class="step-header">
<div class="step-number">3</div>
<div>
<h4>Search Parameters</h4>
<p>Define the search area and constraints</p>
</div>
</div>
<div class="form-group">
<label>Search Radius (km):</label>
<input type="range" id="search-radius" min="10" max="100" value="50" oninput="updateSearchDisplay()">
<span id="search-radius-display">50 km</span>
</div>
<div class="form-group">
<label>Optimization Intensity:</label>
<select id="optimization-intensity">
<option value="fast">Fast (30 points, 2-3 min)</option>
<option value="balanced" selected>Balanced (50 points, 5-7 min)</option>
<option value="thorough">Thorough (100 points, 10-15 min)</option>
<option value="exhaustive">Exhaustive (200 points, 20-30 min)</option>
</select>
</div>
</div>
<!-- Step 4: Run Optimization -->
<div class="step-section" id="step-optimize">
<div class="step-header">
<div class="step-number">4</div>
<div>
<h4>Run Optimization</h4>
<p>Find optimal launch points for all scenarios</p>
</div>
</div>
<button class="btn primary" onclick="runFullOptimization()" id="optimize-btn">
🚀 Find Optimal Launch Points
</button>
<div id="optimization-status"></div>
<div class="progress-bar" style="display: none;" id="progress-container">
<div class="progress-fill" id="progress-bar">0%</div>
</div>
</div>
</div>
<div class="map-panel">
<div id="map"></div>
<div class="map-overlay">
<h4>🗺️ Interactive Map</h4>
<p><strong>Target:</strong> <span id="map-target-coords">Click to set</span></p>
<p><strong>Mode:</strong> <span id="map-mode">View</span></p>
<div class="legend" id="map-legend" style="display: none;">
<h5>Launch Points:</h5>
<div class="legend-item">
<div class="legend-color" style="background: #e74c3c;"></div>
<span>Maximum Success</span>
</div>
<div class="legend-item">
<div class="legend-color" style="background: #3498db;"></div>
<span>Fastest Delivery</span>
</div>
<div class="legend-item">
<div class="legend-color" style="background: #27ae60;"></div>
<span>Most Precise</span>
</div>
<div class="legend-item">
<div class="legend-color" style="background: #f39c12;"></div>
<span>Weather Robust</span>
</div>
<div class="legend-item">
<div class="legend-color" style="background: #9b59b6;"></div>
<span>Stealth Mode</span>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- SCENARIOS TAB -->
<div class="tab-content" id="scenarios">
<h2>📊 Optimization Scenarios</h2>
<p>Each scenario optimizes for different priorities. Choose scenarios to compare or run all for comprehensive analysis.</p>
<div class="scenario-grid">
<div class="scenario-card" data-scenario="maximum_success" onclick="toggleScenario(this)">
<h3>🎯 Maximum Success Rate</h3>
<p>Prioritizes highest probability of reaching target destination.</p>
<div class="metric-grid">
<div class="metric-item">
<div class="metric-value">--</div>
<div class="metric-label">Success Rate</div>
</div>
<div class="metric-item">
<div class="metric-value">--</div>
<div class="metric-label">Launch Point</div>
</div>
</div>
</div>
<div class="scenario-card" data-scenario="fastest_delivery" onclick="toggleScenario(this)">
<h3>⚡ Fastest Delivery</h3>
<p>Minimizes transit time while maintaining good success rate.</p>
<div class="metric-grid">
<div class="metric-item">
<div class="metric-value">--</div>
<div class="metric-label">Transit Time</div>
</div>
<div class="metric-item">
<div class="metric-value">--</div>
<div class="metric-label">Launch Point</div>
</div>
</div>
</div>
<div class="scenario-card" data-scenario="most_precise" onclick="toggleScenario(this)">
<h3>🎱 Most Precise Landing</h3>
<p>Minimizes dispersion for pinpoint accuracy at target.</p>
<div class="metric-grid">
<div class="metric-item">
<div class="metric-value">--</div>
<div class="metric-label">Precision Score</div>
</div>
<div class="metric-item">
<div class="metric-value">--</div>
<div class="metric-label">Launch Point</div>
</div>
</div>
</div>
<div class="scenario-card" data-scenario="weather_robust" onclick="toggleScenario(this)">
<h3>🌊 Weather Robust</h3>
<p>Best performance across varying weather conditions.</p>
<div class="metric-grid">
<div class="metric-item">
<div class="metric-value">--</div>
<div class="metric-label">Robustness</div>
</div>
<div class="metric-item">
<div class="metric-value">--</div>
<div class="metric-label">Launch Point</div>
</div>
</div>
</div>
<div class="scenario-card" data-scenario="stealth_mode" onclick="toggleScenario(this)">
<h3>🌙 Stealth Mode</h3>
<p>Optimized for night launches and minimal detection risk.</p>
<div class="metric-grid">
<div class="metric-item">
<div class="metric-value">--</div>
<div class="metric-label">Stealth Score</div>
</div>
<div class="metric-item">
<div class="metric-value">--</div>
<div class="metric-label">Launch Point</div>
</div>
</div>
</div>
</div>
</div>
<!-- RESULTS TAB -->
<div class="tab-content" id="results">
<h2>🎯 Detailed Optimization Results</h2>
<table class="comparison-table" id="results-table">
<thead>
<tr>
<th>Scenario</th>
<th>Launch Coordinates</th>
<th>Success Rate</th>
<th>Transit Time</th>
<th>Precision</th>
<th>Overall Score</th>
<th>Actions</th>
</tr>
</thead>
<tbody id="results-table-body">
<tr>
<td colspan="7" style="text-align: center; padding: 40px; color: #6c757d;">
Run optimization to see detailed results
</td>
</tr>
</tbody>
</table>
</div>
<!-- ANALYSIS TAB -->
<div class="tab-content" id="analysis">
<h2>📈 Analysis & Performance Charts</h2>
<div class="results-grid">
<div class="result-card">
<h3>Success Rate Comparison</h3>
<canvas id="success-chart" height="200"></canvas>
</div>
<div class="result-card">
<h3>Transit Time Analysis</h3>
<canvas id="time-chart" height="200"></canvas>
</div>
<div class="result-card">
<h3>Launch Point Distribution</h3>
<canvas id="distribution-chart" height="200"></canvas>
</div>
<div class="result-card">
<h3>Overall Performance Radar</h3>
<canvas id="radar-chart" height="200"></canvas>
</div>
</div>
</div>
</div>
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
<script>
// Initialize map
var map = L.map('map').setView([31.2, 34.1], 10);
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© OpenStreetMap contributors'
}).addTo(map);
// Global variables
var targetMarker = null;
var isSelectingTarget = false;
var optimizationResults = {};
var currentContainer = {};
var launchPointMarkers = [];
// Container presets
var containerPresets = {
'jerry_can_rope': {
name: '5L Jerry Can with Rope',
mass: 2.5, density: 500, stability: 9.1, rope: '5.0m',
wind_drift_factor: 0.015, leeway_coefficient: 0.02
},
'optimized_bottle': {
name: 'Optimized 2L Bottle',
mass: 1.25, density: 625, stability: 7.8, rope: 'None',
wind_drift_factor: 0.025, leeway_coefficient: 0.03
},
'standard_bottle': {
name: 'Standard 2L Bottle',
mass: 0.75, density: 375, stability: 6.5, rope: 'None',
wind_drift_factor: 0.035, leeway_coefficient: 0.035
},
'heavy_anchor': {
name: 'Heavy Container with Long Rope',
mass: 4.2, density: 650, stability: 9.5, rope: '15.0m',
wind_drift_factor: 0.012, leeway_coefficient: 0.018
}
};
// Scenario colors
var scenarioColors = {
'maximum_success': '#e74c3c',
'fastest_delivery': '#3498db',
'most_precise': '#27ae60',
'weather_robust': '#f39c12',
'stealth_mode': '#9b59b6'
};
// Tab management
function showTab(tabName) {
// Hide all tabs
document.querySelectorAll('.tab-content').forEach(tab => {
tab.classList.remove('active');
});
document.querySelectorAll('.tab').forEach(tab => {
tab.classList.remove('active');
});
// Show selected tab
document.getElementById(tabName).classList.add('active');
event.target.classList.add('active');
}
// Step management
function completeStep(stepId) {
document.getElementById(stepId).classList.remove('step-active');
document.getElementById(stepId).classList.add('step-completed');
// Activate next step
var stepOrder = ['step-target', 'step-container', 'step-search', 'step-optimize'];
var currentIndex = stepOrder.indexOf(stepId);
if (currentIndex < stepOrder.length - 1) {
document.getElementById(stepOrder[currentIndex + 1]).classList.add('step-active');
}
}
// Target selection
function enableTargetSelection() {
isSelectingTarget = true;
document.getElementById('map-mode').textContent = 'Click to set target';
map.getContainer().style.cursor = 'crosshair';
}
map.on('click', function(e) {
if (isSelectingTarget) {
setTarget(e.latlng.lat, e.latlng.lng);
isSelectingTarget = false;
map.getContainer().style.cursor = '';
document.getElementById('map-mode').textContent = 'View';
}
});
function setTarget(lat, lng) {
if (targetMarker) {
map.removeLayer(targetMarker);
}
targetMarker = L.marker([lat, lng], {
icon: L.icon({
iconUrl: 'data:image/svg+xml;base64,' + btoa(`
<svg xmlns="http://www.w3.org/2000/svg" width="30" height="30" viewBox="0 0 30 30">
<circle cx="15" cy="15" r="12" fill="#e74c3c" stroke="white" stroke-width="3"/>
<circle cx="15" cy="15" r="4" fill="white"/>
</svg>
`),
iconSize: [30, 30],
iconAnchor: [15, 15]
})
}).addTo(map);
var coordText = `${lat.toFixed(6)}, ${lng.toFixed(6)}`;
document.getElementById('target-coords').innerHTML = `Target: ${coordText}`;
document.getElementById('map-target-coords').textContent = coordText;
completeStep('step-target');
}
// Container management
function loadContainerPreset() {
var presetKey = document.getElementById('container-preset').value;
if (presetKey === 'custom') return;
var preset = containerPresets[presetKey];
currentContainer = preset;
document.getElementById('container-mass').textContent = preset.mass;
document.getElementById('container-density').textContent = preset.density;
document.getElementById('container-stability').textContent = preset.stability;
document.getElementById('container-rope').textContent = preset.rope;
completeStep('step-container');
}
function updateSearchDisplay() {
var radius = document.getElementById('search-radius').value;
document.getElementById('search-radius-display').textContent = radius + ' km';
}
// Optimization
function runFullOptimization() {
if (!targetMarker) {
alert('Please set a target destination first');
return;
}
var btn = document.getElementById('optimize-btn');
var status = document.getElementById('optimization-status');
var progress = document.getElementById('progress-container');
btn.disabled = true;
btn.textContent = '🔄 Optimizing...';
status.innerHTML = '<div class="status-indicator status-running">Running optimization across all scenarios...</div>';
progress.style.display = 'block';
// Simulate optimization process
simulateOptimization();
}
function simulateOptimization() {
var scenarios = ['maximum_success', 'fastest_delivery', 'most_precise', 'weather_robust', 'stealth_mode'];
var currentScenario = 0;
var progressBar = document.getElementById('progress-bar');
function optimizeNextScenario() {
if (currentScenario >= scenarios.length) {
completeOptimization();
return;
}
var scenarioKey = scenarios[currentScenario];
var progress = ((currentScenario + 1) / scenarios.length) * 100;
progressBar.style.width = progress + '%';
progressBar.textContent = `${Math.round(progress)}% - ${scenarioKey.replace('_', ' ')}`;
// Simulate scenario optimization
setTimeout(() => {
optimizationResults[scenarioKey] = generateMockResults(scenarioKey);
updateScenarioCard(scenarioKey);
currentScenario++;
optimizeNextScenario();
}, 1500 + Math.random() * 2000); // 1.5-3.5 seconds per scenario
}
optimizeNextScenario();
}
function generateMockResults(scenarioKey) {
var targetLat = targetMarker.getLatLng().lat;
var targetLon = targetMarker.getLatLng().lng;
// Generate realistic launch point southwest of target
var launchLat = targetLat - 0.1 - Math.random() * 0.1;
var launchLon = targetLon - 0.15 - Math.random() * 0.1;
var baseResults = {
'maximum_success': { success: 85, time: 8.2, precision: 72 },
'fastest_delivery': { success: 68, time: 4.1, precision: 58 },
'most_precise': { success: 78, time: 9.5, precision: 91 },
'weather_robust': { success: 73, time: 7.8, precision: 65 },
'stealth_mode': { success: 81, time: 5.2, precision: 69 }
};
var base = baseResults[scenarioKey];
return {
scenario: scenarioKey,
launch_coords: [launchLat, launchLon],
success_rate: base.success + (Math.random() - 0.5) * 10,
transit_time: base.time + (Math.random() - 0.5) * 2,
precision_score: base.precision + (Math.random() - 0.5) * 15,
composite_score: (base.success + base.precision + (100 - base.time * 5)) / 3
};
}
function updateScenarioCard(scenarioKey) {
var card = document.querySelector(`[data-scenario="${scenarioKey}"]`);
var result = optimizationResults[scenarioKey];
card.classList.add('optimized');
var badge = document.createElement('div');
badge.className = 'scenario-badge';
badge.textContent = '✓ OPTIMIZED';
card.appendChild(badge);
var metrics = card.querySelectorAll('.metric-value');
if (scenarioKey === 'maximum_success') {
metrics[0].textContent = result.success_rate.toFixed(1) + '%';
} else if (scenarioKey === 'fastest_delivery') {
metrics[0].textContent = result.transit_time.toFixed(1) + ' days';
} else if (scenarioKey === 'most_precise') {
metrics[0].textContent = result.precision_score.toFixed(0) + '/100';
} else {
metrics[0].textContent = result.composite_score.toFixed(0) + '/100';
}
metrics[1].textContent = `${result.launch_coords[0].toFixed(4)}, ${result.launch_coords[1].toFixed(4)}`;
}
function completeOptimization() {
var btn = document.getElementById('optimize-btn');
var status = document.getElementById('optimization-status');
var progress = document.getElementById('progress-container');
btn.disabled = false;
btn.textContent = '✅ Optimization Complete';
btn.classList.remove('primary');
btn.classList.add('success');
status.innerHTML = '<div class="status-indicator status-complete">✅ Optimization complete! Found optimal launch points for all scenarios.</div>';
progress.style.display = 'none';
completeStep('step-optimize');
// Add launch points to map
addLaunchPointsToMap();
// Update results table
updateResultsTable();
// Update charts
updateCharts();
// Show legend
document.getElementById('map-legend').style.display = 'block';
}
function addLaunchPointsToMap() {
// Clear existing markers
launchPointMarkers.forEach(marker => map.removeLayer(marker));
launchPointMarkers = [];
Object.keys(optimizationResults).forEach(scenarioKey => {
var result = optimizationResults[scenarioKey];
var coords = result.launch_coords;
var color = scenarioColors[scenarioKey];
var marker = L.marker([coords[0], coords[1]], {
icon: L.icon({
iconUrl: 'data:image/svg+xml;base64,' + btoa(`
<svg xmlns="http://www.w3.org/2000/svg" width="25" height="25" viewBox="0 0 25 25">
<circle cx="12.5" cy="12.5" r="10" fill="${color}" stroke="white" stroke-width="2"/>
<circle cx="12.5" cy="12.5" r="3" fill="white"/>
</svg>
`),
iconSize: [25, 25],
iconAnchor: [12.5, 12.5]
})
}).addTo(map);