-
Notifications
You must be signed in to change notification settings - Fork 4
/
script.js
3328 lines (2993 loc) · 115 KB
/
script.js
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
// -*- mode: javascript; indent-tabs-mode: nil; c-basic-offset: 8 -*-
"use strict";
// Define our global variables
var OLMap = null;
var StaticFeatures = new ol.Collection();
var SiteCircleFeatures = new ol.Collection();
var PlaneIconFeatures = new ol.Collection();
var PlaneTrailFeatures = new ol.Collection();
var MyFeatures = new ol.Collection(); // AKISSACK Ref: AK9U
var MaxRangeFeatures = new ol.Collection(); // AKISSACK Ref: AK8A
var MidRangeFeatures = new ol.Collection(); // AKISSACK Ref: AK8A
var MinRangeFeatures = new ol.Collection(); // AKISSACK Ref: AK8A
var SleafordRangeFeatures = new ol.Collection(); // AKISSACK Ref: AK8Z
var Planes = {};
var PlanesOrdered = [];
var PlaneFilter = {};
var SelectedPlane = null;
var SelectedAllPlanes = false;
var FollowSelected = false;
var IsDarkMap = false;
var AllwaysShowPermanentLabels = false;
// --------------------------------------------------------------------------------------
// AKISSACK - Variables -----------------------------------------------------------------
// --------------------------------------------------------------------------------------
var acsntext = " "; // Default label for label data - Ref: AK7C
var SelectedMilPlanes = false; // Allow selection of all planes of interest Ref: AK9G
// --------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------- AKISSACK
var SpecialSquawks = {
'7500': { cssClass: 'squawk7500', markerColor: 'rgb(255, 85, 85)', text: 'Aircraft Hijacking' },
'7600': { cssClass: 'squawk7600', markerColor: 'rgb(0, 255, 255)', text: 'Radio Failure' },
'7700': { cssClass: 'squawk7700', markerColor: 'rgb(255, 255, 0)', text: 'General Emergency' }
};
var CenterLat, CenterLon, ZoomLvl, MapType; // Get current map settings
var Dump1090Version = "unknown version";
var RefreshInterval = 1000;
var PlaneRowTemplate = null;
var TrackedAircraft = 0;
var TrackedAircraftPositions = 0;
var TrackedHistorySize = 0;
var MaxRange = 0; // AKISSACK Range display Ref: AK9T
var CurMaxRange = 0; // AKISSACK Range display Ref: AK9T
var CurMinRange = 999; // AKISSACK Range display Ref: AK9T
var MaxRngRange = []; // AKISSACK Range plot Ref: AK8B
var MaxRngLat = []; // AKISSACK Range plot Ref: AK8B
var MaxRngLon = []; // AKISSACK Range plot Ref: AK8B
var MidRngRange = []; // AKISSACK Range plot Ref: AK8B
var MidRngLat = []; // AKISSACK Range plot Ref: AK8B
var MidRngLon = []; // AKISSACK Range plot Ref: AK8B
var MinRngRange = []; // AKISSACK Range plot Ref: AK8B
var MinRngLat = []; // AKISSACK Range plot Ref: AK8B
var MinRngLon = []; // AKISSACK Range plot Ref: AK8B
var lastSidebarWidth = 0; // AKISSACK mapsize Ref: AKDD
var SitePosition = null;
var ReceiverClock = null;
var LastReceiverTimestamp = 0;
var StaleReceiverCount = 0;
var FetchPending = null;
var MessageCountHistory = [];
var MessageRate = 0;
var NBSP = "\u00a0";
var layers;
var layerGroup;
function checkSidebarWidthChange() { // AKISSACK mapsize Ref: AKDD
var newSidebarWidth = 0;
newSidebarWidth = $("#sidebar_container").width();
if (lastSidebarWidth != newSidebarWidth) {
//console.log("The sidebar was resized");
updateMapSize();
lastSidebarWidth = newSidebarWidth;
}
}
function processReceiverUpdate(data) {
// Loop through all the planes in the data packet
var now = data.now;
var acs = data.aircraft;
// Detect stats reset
if (MessageCountHistory.length > 0 && MessageCountHistory[MessageCountHistory.length - 1].messages > data.messages) {
MessageCountHistory = [
{
time: MessageCountHistory[MessageCountHistory.length - 1].time,
messages: 0,
},
];
}
// Note the message count in the history
MessageCountHistory.push({ time: now, messages: data.messages });
// .. and clean up any old values
if (now - MessageCountHistory[0].time > 30) MessageCountHistory.shift();
for (var j = 0; j < acs.length; j++) {
var ac = acs[j];
var hex = ac.hex;
var squawk = ac.squawk;
var plane = null;
// Do we already have this plane object in Planes? If not make it.
if (Planes[hex]) {
plane = Planes[hex];
} else {
plane = new PlaneObject(hex);
plane.filter = PlaneFilter;
plane.tr = PlaneRowTemplate.cloneNode(true);
if (hex[0] === "~") { // Non-ICAO address
plane.tr.cells[0].textContent = hex.substring(1);
$(plane.tr).css("font-style", "italic");
} else {
plane.tr.cells[0].textContent = hex;
}
// set flag image if available
if (ShowFlags && plane.icaorange.flag_image !== null) {
$("img", plane.tr.cells[1]).attr(
"src",
FlagPath + plane.icaorange.flag_image
);
$("img", plane.tr.cells[1]).attr("title", plane.icaorange.country);
} else {
$("img", plane.tr.cells[1]).css("display", "none");
}
plane.tr.addEventListener(
"click",
function (h, evt) {
if (evt.srcElement instanceof HTMLAnchorElement) {
evt.stopPropagation();
return;
}
if (!$("#map_container").is(":visible")) {
showMap();
}
selectPlaneByHex(h, false);
adjustSelectedInfoBlockPosition();
evt.preventDefault();
}.bind(undefined, hex)
);
plane.tr.addEventListener(
"dblclick",
function (h, evt) {
if (!$("#map_container").is(":visible")) {
showMap();
}
selectPlaneByHex(h, true);
adjustSelectedInfoBlockPosition();
evt.preventDefault();
}.bind(undefined, hex)
);
Planes[hex] = plane;
PlanesOrdered.push(plane);
}
// Call the function update
plane.updateData(now, ac);
}
}
function fetchData() {
if (FetchPending !== null && FetchPending.state() == "pending") {
// don't double up on fetches, let the last one resolve
return;
}
FetchPending = $.ajax({
url: EndpointDump1090 + "data/aircraft.json",
timeout: 5000,
cache: false,
dataType: "json",
});
FetchPending.done(function (data) {
var now = data.now;
processReceiverUpdate(data);
// update timestamps, visibility, history track for all planes - not only those updated
for (var i = 0; i < PlanesOrdered.length; ++i) {
var plane = PlanesOrdered[i];
plane.updateTick(now, LastReceiverTimestamp);
}
selectNewPlanes();
refreshTableInfo();
refreshSelected();
if (ReceiverClock) {
var rcv = new Date(now * 1000);
ReceiverClock.render(
rcv.getUTCHours(),
rcv.getUTCMinutes(),
rcv.getUTCSeconds()
);
}
// Check for stale receiver data
if (LastReceiverTimestamp === now) {
StaleReceiverCount++;
if (StaleReceiverCount > 5) {
$("#update_error_detail").text(
"The data from dump1090 hasn't been updated in a while. Maybe dump1090 is no longer running?"
);
$("#update_error").css("display", "block");
}
} else {
StaleReceiverCount = 0;
LastReceiverTimestamp = now;
$("#update_error").css("display", "none");
}
});
FetchPending.fail(function (jqxhr, status, error) {
$("#update_error_detail").text(
"AJAX call failed (" +
status +
(error ? ": " + error : "") +
"). Maybe dump1090 is no longer running?"
);
$("#update_error").css("display", "block");
});
}
var PositionHistorySize = 0;
function initialize() {
// Set page basics
document.title = PageName;
MaxRange = 0; // AKISSACK Display range Ref: AK9T
// $("#infoblock_name").text(PageName); AKISSACK - Ref: AK9W
$("#infoblock_name").text("");
PlaneRowTemplate = document.getElementById("plane_row_template");
$("#timestamps").css("display", "none"); // AKISSACK remove clocks
$("#loader").removeClass("hidden");
// Set up map/sidebar splitter
$("#sidebar_container").resizable({ handles: { w: "#splitter" } });
// Set up aircraft information panel
$("#selected_infoblock").draggable({ containment: "parent" });
// Set up event handlers for buttons
$("#toggle_sidebar_button").click(toggleSidebarVisibility);
$("#expand_sidebar_button").click(expandSidebar);
$("#show_map_button").click(showMap);
// Set initial element visibility
$("#show_map_button").hide();
$("#show_range_admin_buttons").hide();
setColumnVisibility();
// Initialize other controls
initializeUnitsSelector();
// Set up altitude filter button event handlers and validation options
$("#altitude_filter_form").submit(onFilterByAltitude);
$("#altitude_filter_form").validate({
errorPlacement: function (error, element) {
return true;
},
rules: {
minAltitude: { number: true, min: -99999, max: 99999, },
maxAltitude: { number: true, min: -99999, max: 99999, },
},
});
$("#altitude_filter_reset_button").click(onResetAltitudeFilter);
// Force map to redraw if sidebar container is resized - use a timer to debounce
var mapResizeTimeout;
$("#sidebar_container").on("resize", function () {
clearTimeout(mapResizeTimeout);
mapResizeTimeout = setTimeout(updateMapSize, 10);
});
// Get receiver metadata, reconfigure using it, then continue with initialization
$.ajax({
url: EndpointDump1090 + "data/receiver.json",
timeout: 5000,
cache: false,
dataType: "json",
})
.done(function (data) {
if (typeof data.lat !== "undefined") {
SiteShow = true;
SiteLat = data.lat;
SiteLon = data.lon;
DefaultCenterLat = data.lat;
DefaultCenterLon = data.lon;
console.log("...SiteLat/SiteLon: %d/%d", SiteLat, SiteLon);
}
Dump1090Version = data.version;
RefreshInterval = data.refresh;
PositionHistorySize = data.history;
})
.fail(function () {
console.log("...ajax failed");
})
.always(function () {
initialize_MaxRng();
initialize_map();
start_load_history();
});
}
function initialize_MaxRng() {
console.log("initialize_MaxRng");
// AKISSACK Range plot - Now able to read from local (or session) storage if available Ref: AK8C
if (TypeOfStorageSession == 'Session') {
if (sessionStorage.getItem("MaxRngLon") && sessionStorage.getItem("MaxRngLat") && sessionStorage.getItem("MaxRngRange")) {
console.log("Loading max range from session storage");
MaxRngLat = JSON.parse(sessionStorage.getItem("MaxRngLat"));
MaxRngLon = JSON.parse(sessionStorage.getItem("MaxRngLon"));
MaxRngRange = JSON.parse(sessionStorage.getItem("MaxRngRange"));
} else {
//console.log("Setting up max range");
for (var j = 0; j < 360; j++) {
MaxRngRange[j] = 0;
MaxRngLat[j] = SiteLat;
MaxRngLon[j] = SiteLon;
}
}
if (sessionStorage.getItem("MidRngLon") && sessionStorage.getItem("MidRngLat") && sessionStorage.getItem("MidRngRange")) {
//console.log("Loading mid range");
MidRngLat = JSON.parse(sessionStorage.getItem("MidRngLat"));
MidRngLon = JSON.parse(sessionStorage.getItem("MidRngLon"));
MidRngRange = JSON.parse(sessionStorage.getItem("MidRngRange"));
} else {
for (var j = 0; j < 360; j++) {
MidRngRange[j] = 0;
MidRngLat[j] = SiteLat;
MidRngLon[j] = SiteLon;
}
}
if (sessionStorage.getItem("MinRngLon") && sessionStorage.getItem("MinRngLat") && sessionStorage.getItem("MinRngRange")) {
//console.log("Loading min range");
MinRngLat = JSON.parse(sessionStorage.getItem("MinRngLat"));
MinRngLon = JSON.parse(sessionStorage.getItem("MinRngLon"));
MinRngRange = JSON.parse(sessionStorage.getItem("MinRngRange"));
} else {
for (var j = 0; j < 360; j++) {
MinRngRange[j] = 0;
MinRngLat[j] = SiteLat;
MinRngLon[j] = SiteLon;
}
}
} else {
if (localStorage.getItem("MaxRngLon") && localStorage.getItem("MaxRngLat") && localStorage.getItem("MaxRngRange")) {
console.log("Loading max range from local storage");
MaxRngLat = JSON.parse(localStorage.getItem("MaxRngLat"));
MaxRngLon = JSON.parse(localStorage.getItem("MaxRngLon"));
MaxRngRange = JSON.parse(localStorage.getItem("MaxRngRange"));
} else {
//console.log("Setting up max range");
for (var j = 0; j < 360; j++) {
MaxRngRange[j] = 0;
MaxRngLat[j] = SiteLat;
MaxRngLon[j] = SiteLon;
}
}
if (localStorage.getItem("MidRngLon") && localStorage.getItem("MidRngLat") && localStorage.getItem("MidRngRange")) {
//console.log("Loading mid range");
MidRngLat = JSON.parse(localStorage.getItem("MidRngLat"));
MidRngLon = JSON.parse(localStorage.getItem("MidRngLon"));
MidRngRange = JSON.parse(localStorage.getItem("MidRngRange"));
} else {
for (var j = 0; j < 360; j++) {
MidRngRange[j] = 0;
MidRngLat[j] = SiteLat;
MidRngLon[j] = SiteLon;
}
}
if (localStorage.getItem("MinRngLon") && localStorage.getItem("MinRngLat") && localStorage.getItem("MinRngRange")) {
//console.log("Loading min range");
MinRngLat = JSON.parse(localStorage.getItem("MinRngLat"));
MinRngLon = JSON.parse(localStorage.getItem("MinRngLon"));
MinRngRange = JSON.parse(localStorage.getItem("MinRngRange"));
} else {
for (var j = 0; j < 360; j++) {
MinRngRange[j] = 0;
MinRngLat[j] = SiteLat;
MinRngLon[j] = SiteLon;
}
}
}
}
var CurrentHistoryFetch = null;
var PositionHistoryBuffer = [];
function start_load_history() {
if (PositionHistorySize > 0 && window.location.hash != "#nohistory") {
$("#loader_progress").attr("max", PositionHistorySize);
console.log("Starting to load history (" + PositionHistorySize + " items)");
load_history_item(0);
} else {
end_load_history();
}
}
function load_history_item(i) {
if (i >= PositionHistorySize) {
end_load_history();
return;
}
// Ref: AK9Y -- console.log("Loading history #" + i);
$("#loader_progress").attr("value", i);
$.ajax({
url: EndpointDump1090 + "data/history_" + i + ".json",
timeout: 5000,
cache: false,
dataType: "json",
})
.done(function (data) {
PositionHistoryBuffer.push(data);
load_history_item(i + 1);
})
.fail(function (jqxhr, status, error) {
// No more history
end_load_history();
});
}
function end_load_history() {
$("#loader").addClass("hidden");
console.log("Done loading history");
if (PositionHistoryBuffer.length > 0) {
var now,
last = 0;
// Sort history by timestamp
console.log("Sorting history");
PositionHistoryBuffer.sort(function (x, y) {
return x.now - y.now;
});
// Process history
for (var h = 0; h < PositionHistoryBuffer.length; ++h) {
now = PositionHistoryBuffer[h].now;
// Ref: AK9Y -- console.log("Applying history " + h + "/" + PositionHistoryBuffer.length + " at: " + now);
processReceiverUpdate(PositionHistoryBuffer[h]);
// update track
// Ref: AK9Y -- console.log("Updating tracks at: " + now);
for (var i = 0; i < PlanesOrdered.length; ++i) {
var plane = PlanesOrdered[i];
plane.updateTrack(now - last + 1);
}
last = now;
}
// Final pass to update all planes to their latest state
console.log("Final history cleanup pass");
for (var i = 0; i < PlanesOrdered.length; ++i) {
var plane = PlanesOrdered[i];
plane.updateTick(now);
}
LastReceiverTimestamp = last;
}
PositionHistoryBuffer = null;
console.log("Completing initialisation.");
refreshTableInfo();
refreshSelected();
reaper();
// Setup our timer to poll from the server.
window.setInterval(fetchData, RefreshInterval);
window.setInterval(reaper, 60000);
lastSidebarWidth = $("#sidebar_container").width(); // AKISSACK mapsize Ref: AKDD
// And kick off one refresh immediately.
fetchData();
}
// Make a LineString with 'points'- number points
// that is a closed circle on the sphere such that the
// great circle distance from 'center' to each point is
// 'radius' meters
function make_geodesic_circle(center, radius, points) {
var angularDistance = radius / 6378137.0;
var lon1 = center[0] * Math.PI / 180.0;
var lat1 = center[1] * Math.PI / 180.0;
var geom;
for (var i = 0; i <= points; ++i) {
var bearing = i * 2 * Math.PI / points;
var lat2 = Math.asin(Math.sin(lat1) * Math.cos(angularDistance) +
Math.cos(lat1) * Math.sin(angularDistance) * Math.cos(bearing));
var lon2 = lon1 + Math.atan2(Math.sin(bearing) * Math.sin(angularDistance) * Math.cos(lat1),
Math.cos(angularDistance) - Math.sin(lat1) * Math.sin(lat2));
lat2 = lat2 * 180.0 / Math.PI;
lon2 = lon2 * 180.0 / Math.PI;
if (!geom) {
geom = new ol.geom.LineString([[lon2, lat2]]);
} else {
geom.appendCoordinate([lon2, lat2]);
}
}
return geom;
}
// Initalizes the map and starts up our timers to call various functions
function initialize_map() {
// Load stored map settings if present
CenterLat = Number(localStorage["CenterLat"]) || DefaultCenterLat;
CenterLon = Number(localStorage["CenterLon"]) || DefaultCenterLon;
ZoomLvl = Number(localStorage["ZoomLvl"]) || DefaultZoomLvl;
// Set SitePosition, initialize sorting
if (
SiteShow &&
typeof SiteLat !== "undefined" &&
typeof SiteLon !== "undefined"
) {
SitePosition = [SiteLon, SiteLat];
sortByDistance();
} else {
SitePosition = null;
PlaneRowTemplate.cells[9].style.display = "none"; // hide distance column
document.getElementById("distance").style.display = "none"; // hide distance header
sortByAltitude();
}
// Maybe hide flag info
if (!ShowFlags) {
PlaneRowTemplate.cells[1].style.display = "none"; // hide flag column
document.getElementById("flag").style.display = "none"; // hide flag header
document.getElementById("infoblock_country").style.display = "none"; // hide country row
}
// Initialize OL6
var layers = createBaseLayers();
// --------------------------------------------------------------
// AKISSACK - ADD LAYERS ---------------------- ref: AK4A starts
// --------------------------------------------------------------
// Defining Light Styles
var aarDayStyle = new ol.style.Style({
stroke: new ol.style.Stroke({color: "rgba(128,128,255, 0.5)", width: 1,}),
fill: new ol.style.Fill({color: "rgba(0,0,255, 0.05)", }),
});
var tacanDayStyle = new ol.style.Style({
stroke: new ol.style.Stroke({color: "rgba(0,0,102,0.2)", width: 3, }),
});
var matzDayStyle = new ol.style.Style({
fill: new ol.style.Fill({color: "rgba(0,0,255, 0.05)", }),
stroke: new ol.style.Stroke({color: "rgba(128,0,0, 0.5)", width: 0.75, }),
});
var ctaDayStyle = new ol.style.Style({
fill: new ol.style.Fill({color: "rgba(0, 127,0, 0.03)", }),
stroke: new ol.style.Stroke({color: "rgba(0,64,0, 0.2)", width: 1, }),
});
var airwaysDayStyle = new ol.style.Style({
fill: new ol.style.Fill({color: "rgba(0, 102,0, 0.07)", }),
stroke: new ol.style.Stroke({color: "rgba(0, 64,0, 0.5)", width: 0.2, }),
});
var corridorDayStyle = new ol.style.Style({
fill: new ol.style.Fill({color: "rgba(102, 0,0, 0.07)", }),
stroke: new ol.style.Stroke({color: "rgba(255, 0,0, 0.5)", width: 0.2, }),
});
var ukDayStyle = new ol.style.Style({
stroke: new ol.style.Stroke({color: "rgba(0,102,0, 0.2)", width: 3, }),
});
// Defining Dark Styles
var aarNightStyle = new ol.style.Style({
stroke: new ol.style.Stroke({color: "rgba(128,128,255, 0.5)", width: 1, }),
fill: new ol.style.Fill({color: "rgba(128,128,255, 0.05)", }),
});
var tacanNightStyle = new ol.style.Style({
stroke: new ol.style.Stroke({color: "rgba(128,128,255,0.2)", width: 3, }),
});
var matzNightStyle = new ol.style.Style({
fill: new ol.style.Fill({color: "rgba(128,128,255, 0.05)", }),
stroke: new ol.style.Stroke({color: "rgba(255,128,128, 0.5)", width: 0.75,}),
});
var ctaNightStyle = new ol.style.Style({
fill: new ol.style.Fill({color: "rgba(128, 255,128, 0.03)", }),
stroke: new ol.style.Stroke({color: "rgba(128,255,128, 0.2)", width: 1, }),
});
var airwaysNightStyle = new ol.style.Style({
fill: new ol.style.Fill({color: "rgba(128, 255,128, 0.07)", }),
stroke: new ol.style.Stroke({color: "rgba(128,255,128, 0.5)", width: 0.2, }),
});
var corridorNightStyle = new ol.style.Style({
fill: new ol.style.Fill({color: "rgba(255,128,128, 0.07)", }),
stroke: new ol.style.Stroke({color: "rgba(255, 0,0, 0.5)", width: 0.2,}),
});
var ukNightStyle = new ol.style.Style({
stroke: new ol.style.Stroke({color: "rgba(64,255,64, 0.2)", width: 3, }),
});
if (ShowUKCivviLayers) {
var vordmeLayer = new ol.layer.Vector({
name: "vordme",
type: "overlay",
title: "VOR/DME",
source: new ol.source.Vector({
url: "layers/UK_VOR+DME+NDB+TACAN.geojson",
format: new ol.format.GeoJSON({
defaultDataProjection: "EPSG:4326",
projection: "EPSG:3857",
}),
}),
style: (function () {
var style = new ol.style.Style({
image: new ol.style.Icon({
src: "layers/img/vor+ndb.png",
}),
text: new ol.style.Text({
text: "field-1",
scale: 1,
offsetX: 1,
offsetY: -11,
fill: new ol.style.Fill({
color: "#009900",
}),
}),
});
var styles = [style];
return function (feature, resolution) {
style.getText().setText(feature.get("field_2"));
return styles;
};
})(),
});
vordmeLayer.setVisible(false);
//UK_NavigationPoints.geojson
var navPointsLayer = new ol.layer.Vector({
name: "navigation",
type: "overlay",
title: "Nav Points",
source: new ol.source.Vector({
url: "layers/UK_NavigationPoints.geojson",
format: new ol.format.GeoJSON({
defaultDataProjection: "EPSG:4326",
projection: "EPSG:3857",
}),
}),
style: (function () {
var style = new ol.style.Style({
image: new ol.style.Icon({
src: "layers/img/point.png",
}),
text: new ol.style.Text({
text: "field-1",
scale: 0.75,
offsetX: -1,
offsetY: 10,
fill: new ol.style.Fill({
color: "#009900",
}),
}),
});
var styles = [style];
return function (feature, resolution) {
style.getText().setText(feature.get("field_2"));
return styles;
};
})(),
});
navPointsLayer.setVisible(false);
var airwaysLayer = new ol.layer.Vector({
name: "airways",
type: "overlay",
title: "Airways",
source: new ol.source.Vector({
url: "layers/UK_Airways.geojson",
format: new ol.format.GeoJSON({
defaultDataProjection: "EPSG:4326",
projection: "EPSG:3857",
}),
}),
style: airwaysDayStyle,
});
airwaysLayer.setVisible(false);
var airwaysMRCLayer = new ol.layer.Vector({
name: "airwaysMRC",
type: "overlay",
title: "Radar Corridors",
source: new ol.source.Vector({
url: "layers/UK_Mil_RC.geojson",
format: new ol.format.GeoJSON({
defaultDataProjection: "EPSG:4326",
projection: "EPSG:3857",
}),
}),
style: corridorDayStyle,
});
airwaysMRCLayer.setVisible(false);
var ukCTALayer = new ol.layer.Vector({
name: "ukcta",
type: "overlay",
title: "CTA/TMA",
source: new ol.source.Vector({
url: "layers/UK_AT_Areas.geojson",
format: new ol.format.GeoJSON({
defaultDataProjection: "EPSG:4326",
projection: "EPSG:3857",
}),
}),
style: ctaDayStyle,
});
ukCTALayer.setVisible(false);
var atzLayer = new ol.layer.Vector({
name: "atz",
type: "overlay",
title: "CTR",
source: new ol.source.Vector({
url: "layers/UK_ATZ.geojson",
format: new ol.format.GeoJSON({
defaultDataProjection: "EPSG:4326",
projection: "EPSG:3857",
}),
}),
style: new ol.style.Style({
fill: new ol.style.Fill({
color: "rgba(0,255,0, 0.03)",
}),
stroke: new ol.style.Stroke({
color: "rgba(0, 192, 0, 0.5)",
width: 1,
}),
}),
});
var airportLayer = new ol.layer.Vector({
name: "airports",
type: "overlay",
title: "Airports",
source: new ol.source.Vector({
url: "layers/UK_Civi_Airports_named.geojson",
format: new ol.format.GeoJSON({
defaultDataProjection: "EPSG:4326",
projection: "EPSG:3857",
}),
}),
style: (function () {
var style = new ol.style.Style({
stroke: new ol.style.Stroke({
color: "rgba(0,0,255,1)",
width: 1.5,
}),
text: new ol.style.Text({
text: "name",
scale: 1,
offsetX: 1,
offsetY: -10,
fill: new ol.style.Fill({
color: "#666699",
}),
}),
});
var styles = [style];
return function (feature, resolution) {
if (ShowAirfieldNames && ZoomLvl > 7.5) {
style.getText().setText(feature.get("name_1"));
}else style.getText().setText("");
return styles;
};
})(),
});
var ukairspaceLayer = new ol.layer.Vector({
name: "ukair",
type: "overlay",
title: "UK Airspace",
source: new ol.source.Vector({
url: "layers/UK_Airspace.geojson",
format: new ol.format.GeoJSON({
defaultDataProjection: "EPSG:4326",
projection: "EPSG:3857",
}),
}),
style: ukDayStyle,
});
ukairspaceLayer.setVisible(false);
layers.push(
new ol.layer.Group({
title: "UK",
layers: [
ukairspaceLayer,
navPointsLayer,
airwaysMRCLayer,
vordmeLayer,
airwaysLayer,
ukCTALayer,
atzLayer,
airportLayer,
],
})
);
} // End
// --------------------------------------------------------------
// AKISSACK - ADD LAYERS ---------------------- ref: AK4A ends
// --------------------------------------------------------------
// --------------------------------------------------------------
// AKISSACK - ADD LAYERS ---------------------- ref: AK5A starts
// --------------------------------------------------------------
if (ShowUKMilLayers) {
// LAYERS for UK Military
var matzafLayer= new ol.layer.Vector({
name: "matzaf",
type: "overlay",
title: "Airfields",
source: new ol.source.Vector({
url: "layers/UK_Mil_Airfield_runways_named.geojson",
format: new ol.format.GeoJSON({
defaultDataProjection: "EPSG:4326",
projection: "EPSG:3857",
}),
}),
style: (function () {
var style = new ol.style.Style({
stroke: new ol.style.Stroke({
color: "rgba(192,0,0,1)",
width: 1.5,
}),
text: new ol.style.Text({
text: "name",
scale: 1,
offsetX: 1,
offsetY: -10,
fill: new ol.style.Fill({
color: "#666699",
}),
}),
});
var styles = [style];
return function (feature, resolution) {
if (ShowAirfieldNames && ZoomLvl > 7.5) {
style.getText().setText(feature.get("name_1"));
}else style.getText().setText("");
return styles;
};
})(),
});
var awacLayer = new ol.layer.Vector({
name: "awac",
type: "overlay",
title: "AWACS Zones",
source: new ol.source.Vector({
url: "layers/UK_Mil_AWACS_Orbits.geojson",
format: new ol.format.GeoJSON({
defaultDataProjection: "EPSG:4326",
projection: "EPSG:3857",
}),
}),
style: new ol.style.Style({
fill: new ol.style.Fill({
color: "rgba(0, 255,0, 0.05)",
}),
stroke: new ol.style.Stroke({
color: "rgba(0, 255,0, 0.5)",
width: 0.75,
}),
}),
});
awacLayer.setVisible(false);
var dangerLayer = new ol.layer.Vector({
name: "danger",
type: "overlay",
title: "Danger Areas",
source: new ol.source.Vector({
url: "layers/UK_Danger_Areas.geojson",
format: new ol.format.GeoJSON({
defaultDataProjection: "EPSG:4326",
projection: "EPSG:3857",
}),
}),
style: new ol.style.Style({
fill: new ol.style.Fill({
color: "rgba(255, 0,0, 0.05)",
}),
stroke: new ol.style.Stroke({
color: "rgba(255, 0,0, 0.5)",
width: 0.75,
}),
}),
});
dangerLayer.setVisible(false);
var AARLayer = new ol.layer.Vector({
name: "aar",
type: "overlay",
title: "AAR Areas",
source: new ol.source.Vector({
url: "layers/UK_Mil_AAR_Zones.geojson",
format: new ol.format.GeoJSON({
defaultDataProjection: "EPSG:4326",
projection: "EPSG:3857",
}),
}),
style: aarDayStyle,
});
AARLayer.setVisible(false);
var matzLayer = new ol.layer.Vector({
name: "matz",
type: "overlay",
title: "MATZ",
source: new ol.source.Vector({
url: "layers/UK_MATZ-2023.geojson",
format: new ol.format.GeoJSON({
defaultDataProjection: "EPSG:4326",
projection: "EPSG:3857",
}),
}),
style: matzDayStyle,
});
var ukmilLayer = new ol.layer.Vector({
name: "ukmil",
type: "overlay",
title: "TACAN Routes",
source: new ol.source.Vector({
url: "layers/UK_Military_TACAN_Routes.geojson",
format: new ol.format.GeoJSON({
defaultDataProjection: "EPSG:4326",
projection: "EPSG:3857",
}),
}),
style: tacanDayStyle,
});
ukmilLayer.setVisible(false);
layers.push(
new ol.layer.Group({
title: "UK Military",
layers: [ukmilLayer, awacLayer, AARLayer, dangerLayer, matzLayer, matzafLayer],
})
);
}
// --------------------------------------------------------------
// AKISSACK - ADD LAYERS ---------------------- ref: AK5A ends
// --------------------------------------------------------------
var iconsLayer = new ol.layer.Vector({
name: "ac_positions",
type: "overlay",
title: "Aircraft positions",
source: new ol.source.Vector({
features: PlaneIconFeatures,
}),
});
if (ShowSleafordRange) {