-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
466 lines (399 loc) · 21.1 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-166018299-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config', 'UA-166018299-1');
</script>
<meta charset="utf-8" />
<title>Thermals Heatmap</title>
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<!-- Bootstrap -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.4.1/js/bootstrap.bundle.min.js"></script>
<!-- Bootstrap date picker -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/css/bootstrap-datepicker.min.css" integrity="sha512-mSYUmp1HYZDFaVKK//63EcZq4iFWFjxSL+Z3T/aCt4IO9Cejm03q3NKKYN6pFQzY0SBOr8h+eCIAZHPXcpZaNw==" crossorigin="anonymous" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/js/bootstrap-datepicker.min.js" integrity="sha512-T/tUfKSV1bihCnd+MxKD0Hm1uBBroVYBOYSk1knyvQ9VyZJpc/ALb4P0r6ubwVPSGB2GvjeoMAJJImBG12TiaQ==" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/js/toastr.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/css/toastr.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/dropzone/5.7.0/min/dropzone.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/dropzone/5.7.0/min/dropzone.min.css">
<link rel="stylesheet" href="css/mapbox.css">
<link rel="stylesheet" href="css/heatmap.css">
<link rel="stylesheet" href="css/application.css">
<script src="https://api.mapbox.com/mapbox-gl-js/v1.6.1/mapbox-gl.js"></script>
<link href="https://api.mapbox.com/mapbox-gl-js/v1.6.1/mapbox-gl.css" rel="stylesheet" />
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/moment.min.js"></script>
<!-- moment-range -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment-range/4.0.2/moment-range.js" integrity="sha512-XKgbGNDruQ4Mgxt7026+YZFOqHY6RsLRrnUJ5SVcbWMibG46pPAC97TJBlgs83N/fqPTR0M89SWYOku6fQPgyw==" crossorigin="anonymous"></script>
<script src="https://d3js.org/d3.v5.min.js"></script>
<link rel="stylesheet" href="js/vis/vis.min.css">
<script src="https://use.fontawesome.com/86327f356b.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lodash.min.js"></script>
<script src="https://api.tiles.mapbox.com/mapbox.js/plugins/turf/v2.0.0/turf.min.js" charset="utf-8"></script>
<script src="js/vis/vis.min.js"></script>
<script src="js/common.js"></script>
<script src="js/heatmap.js"></script>
<script src="js/application.js"></script>
<script src="js/interface.js"></script>
<script src="js/airspace.js"></script>
<script src="js/private.js"></script>
<script src="js/infringedAirspaceMarkers.js"></script>
<script src="js/metadata.js"></script>
<script src="js/datePicker.js"></script>
</head>
<body>
<div id="map"></div>
<div id="s1"></div>
<!---------- Information overlay ---------->
<div class="map-overlay top">
<div class="map-overlay-inner">
<div class="container">
<div class="one-line">
<div class="row">
<div class="col-sm-2">
<div class="item">Date</div>
</div>
<div class="col-sm-9">
<!--- Date Selector-->
<div id="date-picker-div">
<div id="datepicker" class="input-group date" data-date-format="mm-dd-yyyy">
<input class="form-control" type="text" readonly />
<span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></span>
</div>
</div>
</div>
</div>
<img id="up-down-arrow" src="images/left.png" alt="Reduce box" class="down-arrow" />
</div>
<div id="reducible" class="d-none">
<div class="row">
<div class="col-sm-6">
<div class="item">Analyse du:</div>
</div>
<div class="col-sm-6">
<div id="start-date" class="item"></div>
</div>
</div>
<div class="row">
<div class="col-sm-6">
<div class="item">Durée calcul:</div>
</div>
<div class="col-sm-6">
<div id="duration" class="item"></div>
</div>
</div>
<div class="row">
<div class="col-sm-6">
<div class="item">Nb Vols:</div>
</div>
<div class="col-sm-6">
<div id="flights-count" class="item"></div>
</div>
</div>
<div class="row">
<div class="col-sm-6">
<div class="item">Nb Thermiques:</div>
</div>
<div class="col-sm-6">
<div id="thermals-count" class="item"></div>
</div>
</div>
</div>
</div>
</div>
<!---------- Flight selection ---------->
<div class="element">
<button class="circle-button" id="flight-button"><img src="images/plane.png" alt="Glider" /></button>
<div class="map-overlay-inner container d-none" id="flight-container">
<div class="one-line">
<h6 class="font-weight-bold">Trace de vol Netcoupe</h6>
<img src="images/left.png" alt="Boxing down" class="left-arrow" />
</div>
<div class="row">
<div class="col-sm-8">
<div class="input-group input-group-sm mb-3">
<div class="input-group-prepend">
<span class="input-group-text" id="lbl-id" data-toggle="tooltip" title="">ID</span>
</div>
<input type="number" class="form-control" placeholder="#" aria-label="Username" aria-describedby="basic-addon1" id="lbl-flight-id" />
</div>
</div>
<div class="col-sm-4">
<button type="button" class="btn btn-outline-dark btn-sm" id="btn-get-flight">Go</button>
</div>
</div>
<!-- Upload form-->
<h6 class="font-weight-bold">Fichier .igc</h6>
<div class="row">
<div class="col-sm-8">
<DIV id="dropzone">
<form class="dropzone needsclick" id="igc-upload">
<div class="dz-message needsclick">
Déplacez un fichier .igc ici ou clickez...
<p class="foot-note">Les fichiers ne sont pas stockés, le traitement se fait entierement en mémoire.</p>
</div>
</form>
</DIV>
</div>
</div>
<!-- Flight navigator toggle button -->
<div class="row" id="switch-navigator-container">
<div class="col-sm-12">
<div class="custom-control custom-switch">
<input type="checkbox" class="custom-control-input d-none" id="switch-navigator" checked>
<label class="custom-control-label" for="switch-navigator">Afficher graph altitude + navigateur</label>
</div>
</div>
</div>
</div>
</div>
<!---------- Vario selection ---------->
<div class="element">
<button class="circle-button" id="vario-button"><img src="images/customisation.png" alt="Customize" /></button>
<div class="map-overlay-inner d-none" id="vario-container">
<div class="one-line">
<h6 class="font-weight-bold">Vario (m/s)</h6>
<img src="images/left.png" alt="Boxing down" class="left-arrow" />
</div>
<label id="vario-label"></label>
<input id="slider" type="range" min="0" max="5" step="0.1" value="1.0" />
<!---------- Altitude selelection ----------->
<h6 class="font-weight-bold">Altitude départ Vario (m)</h6>
<label id="label-altitude-in"></label>
<input id="slider-altitude-in" type="range" min="0" max="5000" step="100" value="0" />
</div>
</div>
<!---------- Layers selection ---------->
<div class="element">
<button class="circle-button" id="layers-button"><img src="images/layers.png" alt="Use layers" /></button>
<div class="map-overlay-inner d-none" id="layers-container">
<div class="one-line">
<h6 class="font-weight-bold">Layers</h6>
<img src="images/left.png" alt="Boxing down" class="left-arrow" />
</div>
<!-- Airspace toggle button -->
<div class="row" id="switch-airspace-container">
<div class="col-sm-12">
<div class="custom-control custom-switch">
<input type="checkbox" class="custom-control-input d-none" id="switch-airspace">
<label class="custom-control-label" for="switch-airspace" data-toggle="tooltip-airspace">Espace Aérien <a href="https://github.com/planeur-net/airspace" target="_blank">france.txt</a></label>
</div>
</div>
</div>
</div>
</div>
<!---------- Extra Features: require authentication ---------->
<div class="element">
<button class="circle-button d-none" id="xtra-features-button"><img src="images/lock-24px.svg" alt="Extra Features" /></button>
<div class="map-overlay-inner d-none" id="xtra-features-container">
<div class="one-line">
<h6 class="font-weight-bold">Extra Features</h6>
<img src="images/left.png" alt="Boxing down" class="left-arrow" />
</div>
<!-- Airspace infringement toggle button -->
<div class="row" id="xtra-features-container">
<div class="col-sm-2">
<input class="form-check-input" type="checkbox" value="" id="chk-show-infringed-only">
</div>
<div class="col-sm-10">
<label class="form-check-label" for="defaultCheck1">Show infringed Airspace only</label>
</div>
</div>
</div>
</div>
</div>
<!-- -------- Flight timeline --------- -->
<div class="map-overlay map-overlay-timeline fixed-bottom bottom d-none" id="flight-timeline">
<button class="circle-button d-none" id="timeline-button"><img src="images/graph.png" alt="Timeline" /></button>
<div class="map-overlay-inner">
<div class="container">
<div class="row harmonize-line">
<div class="col-sm-auto">Time:</div>
<div class="col-sm-auto thick-base" id="current-track-time"></div>
<div class="col-sm-auto">Alt (m):</div>
<div class="col-sm-auto thick-base" id="current-track-altitude"></div>
<!-- Thermal time filter and tolerance -->
<div class="custom-control custom-checkbox col-sm-auto" id="feature-heatmap-time-filter">
<input type="checkbox" class="custom-control-input d-none" id="chk-time-filter">
<label class="custom-control-label" for="chk-time-filter">Filtrer la Heatmap sur l'heure</label>
</div>
<div class="col-sm-3 d-none" id="div-time-filter-tolerance">
<div class="input-group input-group-sm input-time-filter-tolerance">
<div class="input-group-prepend">
<span class="input-group-text" id="lbl-time-delta" data-toggle="tooltip" title="">+/- (min)</span>
</div>
<input type="number" class="form-control" aria-describedby="basic-addon1" id="time-delta" min="15" max="600" value="30" />
</div>
</div>
</div>
<div id="commands" class="commands">
<img src="images/delete.png" alt="Close" class="cross" />
<img src="images/left.png" alt="Boxing down" class="left-arrow" />
</div>
<div class="row">
<div class="col-sm-12">
<div id="visualization"></div>
</div>
</div>
</div>
</div>
</div>
<div class="container spinner-container d-none" id="airspace-spinner">
<button class="btn btn-primary" type="button" disabled>
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
<span class="">Loading Airspace ...</span>
</button>
</div>
<div class="container spinner-container d-none" id="map-spinner">
<button class="btn btn-secondary" type="button" disabled>
<span class="spinner-grow spinner-grow-sm" role="status" aria-hidden="true"></span>
<span id="map-spinner-text">Loading...</span>
</button>
</div>
<script>
var heatmapGeojsonData;
var targetDate = null;
var varioFilterValue = 1;
var altInFilterValue = 0;
var heatmapTimeFilterToleranceValue = 30;
var isHeatmapTimeFilterOn = false;
var isAirspaceShown = false;
var isAuthenticated = false;
var xApiKey = null;
var isShowInfringedAirspaceOnly = false;
var map;
var timelineVisGraph2d; // The vis graph2d hosting the timeline
var timelineData; // The timeline graph data derived from the timelineGeojsonTrack
var timelineGeojsonTrack; // The interactive track data
var gliderIconPoint;
var lastGraphTimeChangeEvent;
var $labelTrackTime;
var $labelTrackAltitude;
// --- Query string parameters ---
// Parse querystring parameters to extract desired day
// Expected date format = yyyy_mm_dd example: 2020_02_05
var queryString = window.location.search;
targetDayParam = null;
volIdParams = null;
if (queryString) {
var urlParams = new URLSearchParams(queryString);
targetDayParam = urlParams.get('day');
volIdParams = urlParams.get('volId');
apiKey = getXApiKeyformUrlParams(urlParams);
if (volIdParams) {
volIdParams = $.map(volIdParams.split(","), $.trim);
}
if (apiKey) {
checkAuthentication(apiKey);
}
}
// --- Apply queystring parameters ---
// Target day
if (targetDayParam) {
targetDate = targetDayParam;
getFilenamesForTargetDate(targetDate);
}
Dropzone.autoDiscover = false;
// ---------- Launch initialisation ----------
setupAirspace(); // Setup the airspace
discoverAvailableDays();
// ---------- Document loaded ----------
$(function () {
// --- Get needed DOM elements ---
$labelTrackTime = $("#current-track-time");
$labelTrackAltitude = $("#current-track-altitude");
// ----- Setup heatmap -----
// Wait for available days discovery to have terminated
(async () => {
console.log("Waiting for available days to be retrieved ...");
while (!_selectedDayFilenames) // define the condition as you like
await new Promise(resolve => setTimeout(resolve, 250));
launchInitMap(); // Days and filenames available. Continue init ...
})();
/**
* launchInitMap
* Will continue Init after available dates have been retrieved
*/
function launchInitMap() {
initHeatMap();
loadMetadata();
}
setupDropZone(); // Setup the dropzone upload
// --- Filter Heatmap on time ---
$('#chk-time-filter').on('change',
function () {
if ($("#chk-time-filter").is(':checked')) {
// Filter is ON
isHeatmapTimeFilterOn = true;
$('#div-time-filter-tolerance').removeClass('d-none');
graphTimeChangeHandler(lastGraphTimeChangeEvent); // Update filter = turn ON
} else {
// Filter is OFF
isHeatmapTimeFilterOn = false;
$('#div-time-filter-tolerance').addClass('d-none');
//Apply filter
filterBy(varioFilterValue, altInFilterValue); // Update filter = turn OFF
}
});
$('#time-delta').on('change',
function () {
heatmapTimeFilterToleranceValue = parseInt($('#time-delta').val());
graphTimeChangeHandler(lastGraphTimeChangeEvent); // Update filter = turn ON
});
// ----- Apply Querystring parameters -----
// Netcoupe volId
if (volIdParams) {
volIdParams.forEach(e => {
if (parseInt(e)) {
loadFlight(e); // Load flight
}
});
}
});
// --- Load the Flight from the Netcoupe ---
function loadFlight(flightId, geojsontrack) {
// Check that the flight is not already there
// Check already done if the flight was uploaded from an igc file
if (isNetcoupeFlight(flightId)) {
checkFlightCanBeAdded(flightId);
}
// The track was not provided: get it from the REST API
if (!geojsontrack) {
var requestUrl = HeatmapRestAPIEndpoint + "/netcoupe/" + flightId;
$.ajax({
url: requestUrl,
type: 'GET',
context: document.body,
success: function (result) {
// Get result metadata
geojsontrack = result;
addTrackToMap(geojsontrack, flightId);
},
error: function (result) {
console.log(result);
if (result.status == 404) {
toastr["error"]("Le vol n'éxiste pas !", "Vol Netcoupe #" + flightId);
} else {
toastr["error"]("Probleme au chargement du vol !", "Vol Netcoupe #" + flightId);
}
}
});
if (isShowInfringedAirspaceOnly) getAirspaceForNetcoupeFlight(flightId);
} else {
addTrackToMap(geojsontrack, flightId);
}
}
</script>
</body>
</html>