-
Notifications
You must be signed in to change notification settings - Fork 34
/
GNSS-Radar.html
955 lines (892 loc) · 37.6 KB
/
GNSS-Radar.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
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
<!------------------------------------------------------------------------------
* Copyright (C) 2014 Taro Suzuki <[email protected]>
* This script uses the following libraries :
* satellite.js :https://github.com/shashwatak/satellite-js
* highcharts.js: http://www.highcharts.com/
* Sylvester.js: http://sylvester.jcoglan.com/
* TLE is downloaded from http://www.celestrak.com/
*------------------------------------------------------------------------------>
<!DOCTYPE html>
<html>
<head>
<title>GNSS Radar</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<meta charset="UTF-8">
<meta name="twitter:card" content="photo" />
<meta name="twitter:site" content="@Taro_Suzuki" />
<meta name="twitter:domain" content="www.taroz.net/GNSS-Radar.html" />
<meta name="twitter:creator" content="@Taro_Suzuki" />
<meta name="twitter:title" content="GNSS-Radar" />
<meta name="twitter:image:src" content="http://www.taroz.net/img/diary/gnssradar.jpg" />
<style type="text/css">
html, body,
#box1{
margin: 0;
width: 100%;
height: 100%;
}
#map {
float: left;
margin: 0;
width: 55%;
height: 100%;
}
#box2{
float: left;
margin: 0;
width: 45%;
height: 100%;
}
#nsatchart {
margin: 0;
width: 98%;
height: 40%;
}
#skychart {
float: right;
margin: 0;
width: 100%;
height: 60%;
}
</style>
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script type="text/javascript" src='http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js'></script>
<script type="text/javascript" src="gnssradar/lib/highchartsv4/highcharts.js"></script>
<script type="text/javascript" src="gnssradar/lib/highchartsv4/modules/exporting.js"></script>
<script type="text/javascript" src="gnssradar/lib/highchartsv4/highcharts-more.js"></script>
<script type="text/javascript" src="gnssradar/lib/satellite/satellite.js"></script>
<script type="text/javascript" src="gnssradar/lib/sylvester/sylvester.js"></script>
</head>
<body>
<div id="box1">
<div id="map"></div>
<div id="box2">
<div id="nsatchart"></div>
<div id="skychart"></div>
</div>
</div>
<script type="text/javascript">
var map;
var orglat, orglon, orgllh;
var orgmarker;
var elemask, offhr, dop;
var tint;
var maxntimes = 200;
var ntimes;
var tind = 0;
var time, times = new Array(maxntimes);
var utcoffset; // min.
var gpsazels = new Array(maxntimes);
var gloazels = new Array(maxntimes);
var galazels = new Array(maxntimes);
var bdsazels = new Array(maxntimes);
var qzsazels = new Array(maxntimes);
var sbsazels = new Array(maxntimes);
var gpsllhs = new Array(maxntimes);
var glollhs = new Array(maxntimes);
var galllhs = new Array(maxntimes);
var bdsllhs = new Array(maxntimes);
var qzsllhs = new Array(maxntimes);
var sbsllhs = new Array(maxntimes);
var qzsmarkers = new Array(7);
var gpsmarkers = new Array(32);
var glomarkers = new Array(24);
var galmarkers = new Array(27);
var bdsmarkers = new Array(35);
var sbsmarkers = new Array(23);
var qzstles = new Array(7);
var gpstles = new Array(32);
var glotles = new Array(24);
var galtles = new Array(27);
var bdstles = new Array(35);
var sbstles = new Array(23);
var iconqz, icongps, icongal, iconglo, iconbds, iconsbs, icon;
var visstate = { "GPS": true, "GLONASS": true, "Galileo": true, "BeiDou": true, "QZSS": true, "SBAS": true };
var skyplts = {};
var nsatplts = {};
var skychart,nsatchart;
var D2R = Math.PI / 180;
var R2D = 180 / Math.PI;
// get TLE from celestrak.com
var xmlHttp = new XMLHttpRequest();
xmlHttp.open("GET", "gnssradar/celestrak.txt", false);
xmlHttp.send(null);
var tledl = xmlHttp.responseText;
// get satellite list from taroz.net
var xmlHttp = new XMLHttpRequest();
xmlHttp.open("GET", "gnssradar/satlist.txt", false);
xmlHttp.send(null);
var satlistdl = xmlHttp.responseText;
var sats = satlistdl.split("\n");
var nsats = sats.length;
// parse TLE
var tles = parse_tle(tledl);
// sort TLE
for (var i = 0; i < nsats; i++) {
var fields = sats[i].split(",");
if (fields[2] in tles) {
var sptle = tles[fields[2]].split(",");
// switch satellite type in satlist
switch (fields[0]) {
case "1": // GPS
gpstles[Number(fields[1]) - 1] = { "name": sptle[0], "line1": sptle[1], "line2": sptle[2] };
break;
case "2": // SBAS
sbstles[Number(fields[1]) - 120] = { "name": sptle[0], "line1": sptle[1], "line2": sptle[2] };
break;
case "3": // GLONASS
glotles[Number(fields[1]) - 1] = { "name": sptle[0], "line1": sptle[1], "line2": sptle[2] };
break;
case "4": // Galileo
galtles[Number(fields[1]) - 1] = { "name": sptle[0], "line1": sptle[1], "line2": sptle[2] };
break;
case "5": // QZSS
qzstles[Number(fields[1]) - 193] = { "name": sptle[0], "line1": sptle[1], "line2": sptle[2] };
break;
case "6": // BeiDou
bdstles[Number(fields[1]) - 1] = { "name": sptle[0], "line1": sptle[1], "line2": sptle[2] };
break;
}
}
}
// add initialize event
google.maps.event.addDomListener(window, 'load', initialize);
// initialization function
function initialize() {
// get number of time intervals to display
ntimes = getKey("ntimes", 24);
if (ntimes>maxntimes) ntimes = maxntimes;
// get number of time intervals to display
tint = getKey("tint", 30);
tint = tint*60*1000; // ms
// get elevation mask (default: 10 degree)
elemask = getKey("elemask", 10);
// get location (default: Tokyo)
orglat = getKey("lat", 35.7);
orglon = getKey("lon", 139.8);
orgllh = {
"latitude": orglat/180*Math.PI,
"longitude": orglon/180*Math.PI,
"height": 0
}
// offset hour
offhr = getKey("offhr", 0);
// Google Earth options
var myOptions = {
zoom: 3,
center: new google.maps.LatLng(orglat, orglon),
navigationControl: false,
mapTypeControl: false,
streetViewControl: false,
mapTypeId: google.maps.MapTypeId.SATELLITE
};
map = new google.maps.Map(document.getElementById('map'), myOptions);
// Load satellite icons
iconqzs = new google.maps.MarkerImage('./gnssradar/icon/QZSS.png',
new google.maps.Size(100, 68),
new google.maps.Point(0,0),
new google.maps.Point(40, 25));
icongps = new google.maps.MarkerImage('./gnssradar/icon/GPS.png',
new google.maps.Size(100, 73),
new google.maps.Point(0,0),
new google.maps.Point(50, 41));
iconglo = new google.maps.MarkerImage('./gnssradar/icon/GLONASS.png',
new google.maps.Size(90, 49),
new google.maps.Point(0, 0),
new google.maps.Point(39, 26));
icongal = new google.maps.MarkerImage('./gnssradar/icon/GALILEO.png',
new google.maps.Size(110, 55),
new google.maps.Point(0, 0),
new google.maps.Point(71, 34));
iconbds = new google.maps.MarkerImage('./gnssradar/icon/BeiDou.png',
new google.maps.Size(100, 85),
new google.maps.Point(0, 0),
new google.maps.Point(45, 48));
iconsbs = new google.maps.MarkerImage('./gnssradar/icon/SBAS.png',
new google.maps.Size(100, 70),
new google.maps.Point(0, 0),
new google.maps.Point(47, 37));
icon = new google.maps.MarkerImage('./gnssradar/icon/transparence.png',
new google.maps.Size(3, 3),
new google.maps.Point(0, 0),
new google.maps.Point(1, 1));
// Display satellite icons at default position
var latlon = new google.maps.LatLng(0.0,0.0);
for (var i = 0; i < 32; i++) {
gpsmarkers[i] = new google.maps.Marker({ position: latlon, map: map, icon: icon });
gpsmarkers[i].setMap(map);
}
for (var i = 0; i < 7; i++) {
qzsmarkers[i] = new google.maps.Marker({ position: latlon, map: map, icon: icon });
qzsmarkers[i].setMap(map);
}
for (var i = 0; i < 24; i++) {
glomarkers[i] = new google.maps.Marker({ position: latlon, map: map, icon: icon });
glomarkers[i].setMap(map);
}
for (var i = 0; i < 27; i++) {
galmarkers[i] = new google.maps.Marker({ position: latlon, map: map, icon: icon });
galmarkers[i].setMap(map);
}
for (var i = 0; i < 35; i++) {
bdsmarkers[i] = new google.maps.Marker({ position: latlon, map: map, icon: icon });
bdsmarkers[i].setMap(map);
}
for (var i = 0; i < 23; i++) {
sbsmarkers[i] = new google.maps.Marker({ position: latlon, map: map, icon: icon });
sbsmarkers[i].setMap(map);
}
// original position
var latlon = new google.maps.LatLng(orglat, orglon);
orgmarker = new google.maps.Marker({
position: latlon, map: map,
icon: "./gnssradar/icon/rangerstation.png",
shadow: "./gnssradar/icon/rangerstation.shadow.png",
draggable: true
});
var title = "Observer (Drag and drop me!)\nLat:" + orglat + "\nLon:" + orglon;
orgmarker.setTitle(title);
// get current time
var time = new Date();
utcoffset = time.getTimezoneOffset();
time.setHours(time.getHours() + offhr); // add offset hour
// generate time
for (var i = 0; i < ntimes; i++) {
times[i] = new Date(time.getTime());
time.setMinutes(time.getMinutes() + tint / 1000 / 60);
}
for (var i = 0; i < ntimes; i++) {
run_compute_satllh(i); // compute satellites locations
run_compute_satazel(i); // compute satellites azels
}
run_set_sat_gmap(tind); // set satellites on gmap
run_visible_sat_gmap(); // visible satellites on gmap
run_gen_skyplotdata(tind); // generate plot data
run_gen_nsatplotdata();
dop = compute_dop(tind); // compute dop
// draw chart
skychartdraw(skyplts);
nsatchartdraw(nsatplts, times, orgllh, elemask);
// add marker drag and drop event
google.maps.event.addListener(orgmarker, 'dragend', function (ev) {
// get new location
orglat = ev.latLng.lat();
orglon = ev.latLng.lng();
orgllh = {
"latitude": orglat * D2R,
"longitude": orglon * D2R,
"height": 0
}
var title = "Observer (Drag and drop me!)\nLat:" + orglat + "\nLon:" + orglon;
orgmarker.setTitle(title);
map.panTo(ev.latLng); // pan to new location
for (var i = 0; i < ntimes; i++) {
run_compute_satazel(i); // re-compute azels
}
run_gen_skyplotdata(tind); // re-generate plot data
run_gen_nsatplotdata();
dop = compute_dop(tind); // re-compute dop
// draw chart
skychartdraw(skyplts);
nsatchartdraw(nsatplts, times, orgllh, elemask);
});
}
// run compute_satllh(ind)
function run_compute_satllh(ind) {
gpsllhs[ind] = compute_satllh(gpstles, times[ind]);
glollhs[ind] = compute_satllh(glotles, times[ind]);
galllhs[ind] = compute_satllh(galtles, times[ind]);
bdsllhs[ind] = compute_satllh(bdstles, times[ind]);
qzsllhs[ind] = compute_satllh(qzstles, times[ind]);
sbsllhs[ind] = compute_satllh(sbstles, times[ind]);
}
// run set_sat_gmap()
function run_set_sat_gmap(ind) {
gpsmarkers = set_sat_gmap(gpsllhs[ind], gpstles, gpsmarkers, 1);
glomarkers = set_sat_gmap(glollhs[ind], glotles, glomarkers, 1);
galmarkers = set_sat_gmap(galllhs[ind], galtles, galmarkers, 1);
bdsmarkers = set_sat_gmap(bdsllhs[ind], bdstles, bdsmarkers, 1);
qzsmarkers = set_sat_gmap(qzsllhs[ind], qzstles, qzsmarkers, 193);
sbsmarkers = set_sat_gmap(sbsllhs[ind], sbstles, sbsmarkers, 120);
}
// run visible_sat_gmap()
function run_visible_sat_gmap() {
visible_sat_gmap(1, "gps");
visible_sat_gmap(1, "glo");
visible_sat_gmap(1, "gal");
visible_sat_gmap(1, "bds");
visible_sat_gmap(1, "qzs");
visible_sat_gmap(1, "sbs");
}
// run compute_satazel()
function run_compute_satazel(ind) {
gpsazels[ind] = compute_satazel(orgllh, gpsllhs[ind]);
gloazels[ind] = compute_satazel(orgllh, glollhs[ind]);
galazels[ind] = compute_satazel(orgllh, galllhs[ind]);
bdsazels[ind] = compute_satazel(orgllh, bdsllhs[ind]);
qzsazels[ind] = compute_satazel(orgllh, qzsllhs[ind]);
sbsazels[ind] = compute_satazel(orgllh, sbsllhs[ind]);
}
// run gen_skyplotdata()
function run_gen_skyplotdata(ind) {
var gpsplt = gen_skyplotdata(gpsazels[ind], 1);
var gloplt = gen_skyplotdata(gloazels[ind], 1);
var galplt = gen_skyplotdata(galazels[ind], 1);
var bdsplt = gen_skyplotdata(bdsazels[ind], 1);
var qzsplt = gen_skyplotdata(qzsazels[ind], 193);
var sbsplt = gen_skyplotdata(sbsazels[ind], 120);
skyplts = { gps: gpsplt, glo: gloplt, gal: galplt, bds: bdsplt, qzs: qzsplt, sbs: sbsplt };
}
// run gen_nsatplotdata()
function run_gen_nsatplotdata() {
var gpsplt = gen_nsatplotdata(gpsazels);
var gloplt = gen_nsatplotdata(gloazels);
var galplt = gen_nsatplotdata(galazels);
var bdsplt = gen_nsatplotdata(bdsazels);
var qzsplt = gen_nsatplotdata(qzsazels);
var sbsplt = gen_nsatplotdata(sbsazels);
nsatplts = { gps: gpsplt, glo: gloplt, gal: galplt, bds: bdsplt, qzs: qzsplt, sbs: sbsplt };
}
// get additonal inputs
function getKey(key, def) {
var str = location.search.substring(1);
if (str) {
var x = str.split("&");
for (var i = 0; i < x.length; i++) {
var y = x[i].split("=");
if (y[0] == key) return Number(y[1]);
}
return def;
} else {
return def;
}
}
// parse TLE data
function parse_tle(tleall) {
var tles = {};
var tlesplit = tleall.split("\n");
var ntle = Math.floor(tlesplit.length / 3);
for (var i = 0; i < ntle; i++) {
var satnames = tlesplit[3 * i + 1].split(" ");
tles[satnames[1]] = tlesplit[3 * i] + "," + tlesplit[3 * i + 1] + "," + tlesplit[3 * i + 2];
}
return tles;
}
// compute gmst
function date2gmst(date) {
var y = date.getUTCFullYear();
var m = date.getUTCMonth() + 1;
var d = date.getUTCDate();
var w = date.getUTCDay();
var hr = date.getUTCHours();
var min = date.getUTCMinutes();
var sec = date.getUTCSeconds();
return satellite.gstime_from_date(y, m, d, hr, min, sec);
}
// compute gmst
function date2utc(date) {
var y = date.getUTCFullYear();
var m = date.getUTCMonth() + 1;
var d = date.getUTCDate();
var w = date.getUTCDay();
var hr = date.getUTCHours();
var min = date.getUTCMinutes();
var sec = date.getUTCSeconds();
return Date.UTC(y, m, d, hr, min, sec);
}
// compute satellite geodetic location
function compute_satllh(tles, time) {
var llhs = new Array(tles.length);
for (var i = 0; i < tles.length; i++) {
if (tles[i]) {
// compute satellite position from TLE
llhs[i] = _compute_satllh(tles[i]["line1"], tles[i]["line2"], time);
}
}
return llhs;
}
function _compute_satllh(tle1, tle2, date) {
var satrec = satellite.twoline2satrec(tle1, tle2);
var y = date.getUTCFullYear();
var m = date.getUTCMonth() + 1;
var d = date.getUTCDate();
var w = date.getUTCDay();
var hr = date.getUTCHours();
var min = date.getUTCMinutes();
var sec = date.getUTCSeconds();
var gmst = satellite.gstime_from_date(y, m, d, hr, min, sec);
var sateci = satellite.propagate(satrec, y, m, d, hr, min, sec);
return satellite.eci_to_geodetic(sateci["position"], gmst);
}
// compute satellite azimuth and elevation
function compute_satazel(orgllh, llhs) {
var azels = new Array(llhs.length);
for (var i = 0; i < llhs.length; i++) {
if (llhs[i]) {
// azimuth and elevation angle
azels[i] = _compute_satazel(orgllh, llhs[i]);
}
}
return azels;
}
function _compute_satazel(orgllh, satllh) {
var satecf = satellite.geodetic_to_ecf(satllh);
var azel = satellite.ecf_to_look_angles(orgllh, satecf);
azel["azimuth"] = azel["azimuth"] / Math.PI * 180; // degree
azel["elevation"] = azel["elevation"] / Math.PI * 180; // degree
return azel;
}
// set satellite marker on gmap
function set_sat_gmap(llhs, tles, markers, prnoffset) {
for (var i = 0; i < tles.length; i++) {
markers[i].exist = false;
if (tles[i]) {
_set_sat_gmap(llhs[i]["latitude"] * R2D, llhs[i]["longitude"] * R2D, tles[i]["name"], i + prnoffset, markers[i]);
markers[i].exist = true;
}
}
return markers;
}
function _set_sat_gmap(lat, lon, svname, prn, marker) {
var latlon = new google.maps.LatLng(lat, lon);
marker.setPosition(latlon);
// tooltip
var title = svname + "\nPRN:" + prn + "\nLat:" + lat + "\nLon:" + lon;
marker.setTitle(title);
}
// generate skychart plot data
function gen_skyplotdata(azels,offi) {
var plt = [];
for (var i = 0; i < azels.length; i++) {
if (azels[i]) {
if (azels[i]["elevation"] > elemask) {
var az = Math.round(azels[i]["azimuth"] * 10) / 10;
var el = Math.round(azels[i]["elevation"] * 10) / 10;
plt[plt.length] = { name: (i + offi).toString(), x: az, y: el };
}
}
}
return plt;
}
// generate nsatchart plot data
function gen_nsatplotdata(azels) {
var plt = [];
for (var j = 0; j < ntimes; j++) {
var nsat = 0;
for (var i = 0; i < azels[j].length; i++) {
if (azels[j][i]) {
if (azels[j][i]["elevation"] > elemask) {
nsat++;
}
}
}
plt[plt.length] = { x: j, y: nsat };
}
return plt;
}
function check_azel(azels, azs, els) {
for (var i = 0; i < azels.length; i++) {
if (azels[i]) {
if (azels[i]["elevation"] > elemask) {
azs[azs.length] = azels[i]["azimuth"] * D2R;
els[els.length] = azels[i]["elevation"] * D2R;
}
}
}
return [azs, els];
}
// compute DOP
function compute_dop(ind) {
var azs = [];
var els = [];
var tmp;
// check number of available satellites
if (visstate["GPS"]) {
tmp = check_azel(gpsazels[ind], azs, els); azs = tmp[0]; els = tmp[1];
}
if (visstate["GLONASS"]) {
tmp = check_azel(gloazels[ind], azs, els); azs = tmp[0]; els = tmp[1];
}
if (visstate["Galileo"]) {
tmp = check_azel(galazels[ind], azs, els); azs = tmp[0]; els = tmp[1];
}
if (visstate["BeiDou"]) {
tmp = check_azel(bdsazels[ind], azs, els); azs = tmp[0]; els = tmp[1];
}
if (visstate["QZSS"]) {
tmp = check_azel(qzsazels[ind], azs, els); azs = tmp[0]; els = tmp[1];
}
if (visstate["SBAS"]) {
tmp = check_azel(sbsazels[ind], azs, els); azs = tmp[0]; els = tmp[1];
}
var nsat = azs.length;
if (nsat < 4) return { "hdop": 999, "vdop": 999, "pdop": 999 };
var G = Matrix.Zero(nsat, 4);
for (var i = 0; i < nsat; i++)
{
G.elements[i][0] = Math.cos(els[i]) * Math.sin(azs[i]); // East
G.elements[i][1] = Math.cos(els[i]) * Math.cos(azs[i]); // North
G.elements[i][2] = Math.sin(els[i]); // Up
G.elements[i][3] = 1;
}
var D = (G.transpose().multiply(G)).inverse();
var out = {};
out["hdop"] = Math.sqrt(D.elements[0][0] + D.elements[1][1]);
out["vdop"] = Math.sqrt(D.elements[2][2]);
out["pdop"] = Math.sqrt(D.elements[0][0] + D.elements[1][1] + D.elements[2][2]);
return out;
}
// display or non-display satellite icons on gmap
function visible_sat_gmap(view, sysstr) {
var markers;
var iconsat;
switch (sysstr) {
case "GPS":
case "gps":
markers = gpsmarkers;
iconsat = icongps;
break;
case "GLONASS":
case "glo":
markers = glomarkers;
iconsat = iconglo;
break;
case "Galileo":
case "gal":
markers = galmarkers;
iconsat = icongal;
break;
case "BeiDou":
case "bds":
markers = bdsmarkers;
iconsat = iconbds;
break;
case "QZSS":
case "qzs":
markers = qzsmarkers;
iconsat = iconqzs;
break;
case "SBAS":
case "sbs":
markers = sbsmarkers;
iconsat = iconsbs;
break;
}
for (var i = 0; i < markers.length; i++) {
if (markers[i].exist) {
if (view)
markers[i].setIcon(iconsat);
else
markers[i].setIcon(icon); // transparence
}
}
}
// nsat chart setting
function nsatchartdraw(nsatplts, times, llh, elemask) {
var col = ['rgba(0,128,0,0.5)', 'rgba(255,170,0,0.5)', 'rgba(255,0,255,0.5)', 'rgba(255,0,0,0.5)', 'rgba(0,0,255,0.5)', 'rgba(0,128,128,0.5)'];
var coldark = ['rgba(0,78,0,0.8)', 'rgba(225,140,0,0.8)', 'rgba(205,0,205,0.8)', 'rgba(205,0,0,0.8)', 'rgba(0,0,205,0.8)', 'rgba(0,100,100,0.8)'];
var cat = [];
for (var i = 0; i < ntimes; i++)
cat[i] = Highcharts.dateFormat('%H:%M', times[i] - utcoffset * 60 * 1000);
var plotdata = {
chart: {
type: 'column',
renderTo: 'nsatchart'
},
credits: {
enabled: false
},
title: {
text: 'GNSS Radar <a href="gnssradar_e.html" target="_blank"><span style="font-size: large">help</span></a>',
style: {
fontSize: 'xx-large'
},
useHTML: true
},
subtitle: {
style: {
fontSize: 'medium'
}
},
xAxis: {
type: 'datetime',
gridLineWidth: 0,
tickmarkPlacement: 'on',
categories: cat
},
yAxis: {
gridLineWidth: 0,
min: 0,
title: {
text: 'Number of satellite'
},
stackLabels: {
enabled: true,
style: {
fontWeight: 'bold',
color: 'gray'
}
}
},
legend: {
enabled: false
},
tooltip: {
formatter: function () {
return this.x + '<br/>' +
'<b>' + this.series.name + ': ' + this.y + '</b>';
},
positioner: function () {
return { x: 50, y: 50 };
}
},
exporting: {
scale: 1,
sourceHeight: 400,
sourceWidth: 800,
filename: 'nsat'
},
plotOptions: {
column: {
stacking: 'normal',
pointPadding: 0,
groupPadding: 0,
borderWidth: 0,
point: {
events: {
click: function () {
for (var i = 0; i < 6; i++) {
nsatchart.series[i].data[tind].update({ color: col[i] }, true, false);
nsatchart.series[i].data[this.x].update({ color: coldark[i] }, true, false);
}
tind = this.x;
run_set_sat_gmap(tind); // set satellites on gmap
run_gen_skyplotdata(tind); // generate plot data
dop = compute_dop(tind); // compute dop
skychartdraw(skyplts);
}
}
}
}
},
series: [{
name: 'GPS',
color: col[0]
}, {
name: 'GLONASS',
color: col[1]
}, {
name: 'Galileo',
color: col[2]
}, {
name: 'BeiDou',
color: col[3]
}, {
name: 'QZSS',
color: col[4]
}, {
name: 'SBAS',
color: col[5]
}]
} // plotdata
// set subtitle
var time = new Date();
var y = time.getFullYear();
var m = time.getMonth() + 1;
var d = time.getDate();
var H = time.getHours();
var M = time.getMinutes();
var lt = "Time: " + y + "/" + m + "/" + d + " " + H + ":" + M;
var ele = "Mask:" + elemask.toString() + " deg";
var dopstr = "HDOP:" + dop["hdop"].toFixed(1) + ", PDOP:" + dop["pdop"].toFixed(1);
plotdata["subtitle"]["text"] = lt + "<br> " + ele + ", " + dopstr;
// set plot data
plotdata["series"][0]["data"] = nsatplts["gps"];
plotdata["series"][1]["data"] = nsatplts["glo"];
plotdata["series"][2]["data"] = nsatplts["gal"];
plotdata["series"][3]["data"] = nsatplts["bds"];
plotdata["series"][4]["data"] = nsatplts["qzs"];
plotdata["series"][5]["data"] = nsatplts["sbs"];
// chart generation
nsatchart = new Highcharts.Chart(plotdata);
for (var i = 0; i < 6; i++)
nsatchart.series[i].data[tind].update({ color: coldark[i] }, true, false);
}
// sky chart setting
function skychartdraw(skyplts) {
var labels = {
"0": "N", "45": "NE", "90": "E", "135": "SE",
"180": "S", "225": "SW", "270": "W", "315": "NW"
}
var plotdata = {
chart: {
renderTo: "skychart",
polar: true
},
credits: {
enabled: false
},
legend: {
title: {
style: {
fontSize: '14px'
}
},
itemStyle: {
fontSize: '12px'
}
},
title: {
text: ''
},
subtitle: {
text: ''
},
tooltip: {
pointFormat: 'PRN: <b>{point.name}</b><br>EL: <b>{point.y}</b>deg<br>AZ: <b>{point.x}</b>deg',
hideDelay: 0
},
pane: {
startAngle: 0,
endAngle: 360
},
xAxis: {
tickInterval: 45,
min: 0,
max: 360,
labels: {
formatter: function () { return labels[this.value] },
style: {
fontSize: 'medium'
}
}
},
yAxis: {
min: 0,
max: 90,
minorTickInterval: 10,
tickInterval: 30,
reversed: true,
labels: { enabled: false }
},
exporting: {
scale: 1,
sourceHeight: 800,
sourceWidth: 600,
filename: 'skyplot'
},
plotOptions: {
bubble: {
minSize: 30,
maxSize: 30,
dataLabels: {
enabled: true,
formatter: function () { return this.point.name },
y: 4,
style: {
fontWeight: 'bold',
fontSize: 'medium'
}
},
tooltip: {
followPointer: false,
followTouchMove: false,
hideDelay: 0
},
events: {
show: function () {
var name = this.name.split("(");
visible_sat_gmap(1, name[0]);
visstate[name[0]] = true;
dop = compute_dop(tind); // re-compute dop
var sp = nsatchart.options.subtitle["text"].split("<br>");
var newtext = sp[0] + "<br>" + "Mask:" + elemask.toString() + " deg" +
", HDOP:" + dop["hdop"].toFixed(1) + ", PDOP:" + dop["pdop"].toFixed(1);
nsatchart.setTitle(this.title, { text: newtext });
nsatchart.series[this.index].show();
},
hide: function () {
var name = this.name.split("(");
visible_sat_gmap(0, name[0]);
visstate[name[0]] = false;
dop = compute_dop(tind); // re-compute dop
var sp = nsatchart.options.subtitle["text"].split("<br>");
var newtext = sp[0] + "<br>" + "Mask:" + elemask.toString() + " deg" +
", HDOP:" + dop["hdop"].toFixed(1) + ", PDOP:" + dop["pdop"].toFixed(1);
nsatchart.setTitle(this.title, { text: newtext });
nsatchart.series[this.index].hide();
}
}
}
},
series: [
{
type: 'bubble',
color: '#008000',
pointPlacement: 'between'
},
{
type: 'bubble',
color: '#FFAA00',
pointPlacement: 'between'
},
{
type: 'bubble',
color: '#FF00FF',
pointPlacement: 'between'
},
{
type: 'bubble',
color: '#FF0000',
pointPlacement: 'between'
},
{
type: 'bubble',
color: '#0000FF',
pointPlacement: 'between'
},
{
type: 'bubble',
color: '#008080',
pointPlacement: 'between'
}
]
} // plotdata
var gps = skyplts["gps"];
var glo = skyplts["glo"];
var gal = skyplts["gal"];
var bds = skyplts["bds"];
var qzs = skyplts["qzs"];
var sbs = skyplts["sbs"];
// set plot data
plotdata["series"][0]["data"] = gps;
plotdata["series"][1]["data"] = glo;
plotdata["series"][2]["data"] = gal;
plotdata["series"][3]["data"] = bds;
plotdata["series"][4]["data"] = qzs;
plotdata["series"][5]["data"] = sbs;
// set legend name
plotdata["series"][0]["name"] = "GPS(" + gps.length.toString() + ")";
plotdata["series"][1]["name"] = "GLONASS(" + glo.length.toString() + ")";
plotdata["series"][2]["name"] = "Galileo(" + gal.length.toString() + ")";
plotdata["series"][3]["name"] = "BeiDou(" + bds.length.toString() + ")";
plotdata["series"][4]["name"] = "QZSS(" + qzs.length.toString() + ")";
plotdata["series"][5]["name"] = "SBAS(" + sbs.length.toString() + ")";
// set initial visible state
plotdata["series"][0]["visible"] = visstate["GPS"];
plotdata["series"][1]["visible"] = visstate["GLONASS"];
plotdata["series"][2]["visible"] = visstate["Galileo"];
plotdata["series"][3]["visible"] = visstate["BeiDou"];
plotdata["series"][4]["visible"] = visstate["QZSS"];
plotdata["series"][5]["visible"] = visstate["SBAS"];
// set legend title
var nsat = gps.length+glo.length+gal.length+bds.length+qzs.length+sbs.length;
plotdata["legend"]["title"]["text"] =
'GNSS (' + nsat.toString() + ') ' +
'<span style="color: #666; font-weight: normal; font-size: 14px">click to hide</span>';
// chart generation
skychart = new Highcharts.Chart(plotdata);
}
</script>
</body>
</html>