-
Notifications
You must be signed in to change notification settings - Fork 3
/
ingest_viewer.js
3115 lines (2459 loc) · 127 KB
/
ingest_viewer.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
// ==============================================
// Safecast Ingest Viewer
// ==============================================
// Nick Dolezal/Safecast, 2017
// This code is released into the public domain.
// ==============================================
// =================================
// Requirements (Files):
// =================================
// 1. ingest_viewer_min.js (this file)
// =================================
// Use
// =================================
//
// 1. Prerequisites
// -------------------------------
// var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); // or whatever.
//
// 2. Instantiate
// -------------------------------
// var = new IngestViewer(map);
//
// Instantiate will auto-initialize and start polling.
// Ingest Viewer - Main
// Contains all useful instances of other objects and UI event handling.
// Messy and too broad but hey.
// NOTE: In most cases, null should be passed for "dataBinds".
// Only override this if you want to set custom styles or image/worker filepaths.
var IngestViewer = (function()
{
function IngestViewer(map)
{
this.mapRef = map;
this.isMobile = _IsPlatformMobile();
this.mks = null; // marker manager
this.failures = 0;
this.fail_max = (86400 * 365) / 600;
this.last_tx = 0;
this.enabled = true;
this.int_up = null;
this.dev_test = false;
this.Init();
}//IngestViewer
// =======================================================================================================
// Mandatory Initialization
// =======================================================================================================
IngestViewer.prototype.Init = function()
{
this.Init_DevTestMode();
this.Init_IngestMarkers();
//this.InitMarkersAsync();
this.SetEnabled(true);
//this.InitConnectionWatchdog();
};
IngestViewer.prototype.Init_DevTestMode = function()
{
var dev_test_str = _GetParam("dev_test");
if (dev_test_str != null && dev_test_str.length > 0)
{
this.dev_test = parseInt(dev_test_str) == 1;
if (this.dev_test)
{
console.log("IngestViewer: dev_test mode temporarily set from querystring. To return to normal (production) view, reload the page without dev_test=1 in the querystring.");
}//if
}//if
};
IngestViewer.prototype.Init_IngestMarkers = function()
{
//var rs = IngestIcon.RenderStyle.DoubleTriangle;
this.mks = new IngestMarkers(this.mapRef, window.devicePixelRatio, this.isMobile, "opc_pm02_5");//, rs);
};
IngestViewer.prototype.InitMarkersAsync = function()
{
//var pre = window.location.href.substring(0,5) == "https" ? "https://" : "http://";
//var url = pre + "safecast.org/tilemap/test2/ingest-test.json";
var url = this.GetJsonUrl();
this.GetJSONAsync(url);
};
IngestViewer.prototype.InitConnectionWatchdog = function()
{
setTimeout(function() {
this.ConnectionWatchdog();
}.bind(this), 10 * 60 * 1000);
};
IngestViewer.prototype.GetJsonUrl = function()
{
return !this.dev_test ? "https://s3-us-west-2.amazonaws.com/safecastdata-us-west-2/ingest/prd/json/view24h.json"
: "https://s3-us-west-2.amazonaws.com/safecastdata-us-west-2/ingest/prd/json/view24h_devtest.json";
};
// =======================================================================================================
// Event handlers - abstracted download methods
// =======================================================================================================
// Some network failures that break the auto-refresh do not appear to raise an event,
// so this serves as a failsafe for those cases.
//
IngestViewer.prototype.ConnectionWatchdog = function()
{
if (Date.now() - this.last_tx > 20 * 60 * 1000)
{
console.log("IngestViewer.prototype.ConnectionWatchdog: >20 mins since last connection attempt, restarting connection...");
this.InitMarkersAsync();
}//if
setTimeout(function() {
this.ConnectionWatchdog();
}.bind(this), 10 * 60 * 1000);
};
IngestViewer.prototype.GetJSONAsync = function(url)
{
// 2016-08-14 ND: Fix for not being able to disable via UI due to timer polling.
// This keeps timers running, but simply does a no-op.
/*
if (!this.enabled)
{
setTimeout(function() {
this.last_tx = Date.now();
this.GetJSONAsync(url);
}.bind(this), 60 * 1000);
return;
}//if
*/
var ss_now = "" + (parseInt(Date.now() * 0.001));
var url_nocache = url + "?t=" + ss_now;
var cb = function(response, userData)
{
var success = response != null && response.length > 0;
if (success)
{
var obj = null;
try
{
obj = JSON.parse(response);
}
catch (err)
{
console.log("IngestViewer: JSON parsing exception.");
}
if (obj != null)
{
// 2016-08-14 ND: Recheck enabled status due to HTTP GET latency, to make sure
// markers are not being added against user's preference.
if (this.enabled)
{
this.mks.AddSensorDataFromJson(obj);
this.mks.AddMarkersToMap();
}//if
}//if
else
{
success = false;
this.failures = this.failures + 1;
}//else
}//if
else
{
this.failures = this.failures + 1;
}//else
if (!success)
{
console.log("IngestViewer.GetJSONAsync: Error getting sensors from URL: %s", url);
}//if
var after_ms = (success ? 60 : 600) * 1000; // 1 min normally, 10 mins on failure
/*
if (this.failures < this.fail_max)
{
setTimeout(function() {
this.last_tx = Date.now();
this.GetJSONAsync(url);
}.bind(this), after_ms);
}//if
*/
}.bind(this);
_GetAsync_HTTP(url_nocache, null, null, cb, null);
};
// =======================================================================================================
// Event handlers - UI
// =======================================================================================================
IngestViewer.prototype.ClearGmapsListeners = function()
{
this.mks.ClearGmapsListeners();
};
IngestViewer.prototype.AddGmapsListeners = function()
{
this.mks.AddGmapsListeners(); // only needed if they are manually removed.
};
IngestViewer.prototype.RemoveAllMarkersFromMapAndPurgeData = function()
{
this.mks.RemoveAllMarkersFromMapAndPurgeData();
};
IngestViewer.prototype.GetMarkerCount = function()
{
return this.mks == null || this.mks.vals == null ? 0 : this.mks.vals.length;
};
IngestViewer.prototype.GetEnabled = function()
{
return this.enabled;
};
IngestViewer.prototype.SetEnabled = function(v)
{
if (v && this.int_up == null)
{
this.AddGmapsListeners();
var fx = function()
{
this.InitMarkersAsync();
}.bind(this);
fx();
this.int_up = setInterval(fx, 5 * 60 * 1000);
}//if
else if (!v && this.int_up != null)
{
clearInterval(this.int_up);
this.int_up = null;
this.RemoveAllMarkersFromMapAndPurgeData();
this.ClearGmapsListeners();
}//else
this.enabled = v;
};
IngestViewer.prototype.GetUnit = function()
{
return this.mks == null ? null : this.mks.GetUnit();
};
IngestViewer.prototype.GetUnits = function(cb)
{
return this.mks == null ? null : this.mks.GetUnits(cb);
};
IngestViewer.prototype.SetUnit = function(unit)
{
if (this.mks != null) this.mks.SetUnit(unit);
};
// =======================================================================================================
// Static/Class Methods
// =======================================================================================================
var _GetAsync_HTTP = function(url, responseType, responseHeader, fxCallback, userData)
{
var req = new XMLHttpRequest();
req.open("GET", url, true);
if (responseType != null)
{
if (responseType == "text\/plain; charset=x-user-defined")
{
req.overrideMimeType(responseType);
}//if
else
{
req.responseType = responseType; //"arraybuffer", "blob", "document", "json", and "text"
}//else
}//if
req.onreadystatechange = function () // why was this ==== ?
{
if (req.readyState === 4 && req.status == 200 && req.response != null)
{
if (responseHeader != null)
{
fxCallback(req.getResponseHeader(responseHeader), userData);
}//if
else
{
fxCallback(req.response, userData);
}//else
}//if
else if (req.readyState === 4)
{
// This attemps to trap Chrome's ERR_NETWORK_CHANGED
// and other network failures which cause the updates to stop.
console.log("IngestViewer _GetAsync_HTTP: req.readyState == 4, req.status == %d. Retrying.", req.status);
fxCallback(null, userData);
}//else if
};
req.send(null);
};
// returns value of querystring parameter "name"
var _GetParam = function(name)
{
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regexS = "[\\?&]" + name + "=([^&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec(window.location.href);
return results == null ? "" : results[1];
};
// http://stackoverflow.com/questions/11381673/detecting-a-mobile-browser
// returns true if useragent is detected as being a mobile platform, or "mobile=1" is set in querystring.
var _IsPlatformMobile = function()
{
var check = false;
var ovr_str = _GetParam("mobile");
if (ovr_str != null && ovr_str.length > 0)
{
check = parseInt(ovr_str) == 1;
}//if
else
{
(function(a,b){if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte|android|ipad|playbook|silk\-/i.test(a.substr(0,4)))check = true})(navigator.userAgent||navigator.vendor||window.opera);
if (!check) check = navigator.userAgent.match(/iPad/i);
if (!check) check = navigator.userAgent.match(/Android/i);
if (!check) check = navigator.userAgent.indexOf("iPad") > 0;
if (!check) check = navigator.userAgent.indexOf("Android") > 0;
}//else
return check;
};
return IngestViewer;
})();
var IngestWords = (function()
{
function IngestWords()
{
this.SortedWords = null;
this._WordsInit();
}
IngestWords.prototype.WordsFromNumber = function(number)
{
// If the length isn't precisely 2048, this won't work
if (IngestWords.Words2048.length != 2048)
{
return "not-2048";
}
number >>>= 0;
// Break the 32-bit uint down into 3 parts
var left = (number >> 22) & 0x000003ff;
var middle = (number >> 11) & 0x000007ff;
var right = number & 0x000007ff;
// Generate the string
return IngestWords.Words2048[left] + "-" + IngestWords.Words2048[middle] + "-" + IngestWords.Words2048[right];
};
// Look up a number from three simple words
IngestWords.prototype.WordsToNumber = function(what)
{
var result = 0 >>> 0;
var word = what.split("-");
if (word.length != 3)
{
// See if this is just a simple device ID
var i64 = parseInt(what);
if (!isNan(i64))
{
return { ok:true, x:i64 };
}//if
return { ok:false, x:0 };
}//if
var a;
a = this._WordToNumber(word[0]);
var left = a.x;
if (!a.ok)
{
return { ok:false, x:0 };
}//if
a = this._WordToNumber(word[1]);
var middle = a.x;
if (!a.ok)
{
return { ok:false, x:0 };
}//if
a = this._WordToNumber(word[2]);
var right = a.x;
if (!a.ok)
{
return { ok:false, x:0 };
}//if
result |= ((left )>>>0) << 22;
result |= ((middle)>>>0) << 11;
result |= ((right )>>>0);
return { ok:true, x:result };
};
IngestWords.prototype._WordToNumber = function(what)
{
var idx = 2049;
for (var i=0; i<this.SortedWords.length; i++)
{
if (IngestWords.Words2048[this.SortedWords[i]] >= what)
{
idx = i;
break;
}//if
}//for
if (idx < 2048 && IngestWords.Words2048[this.SortedWords[idx]] == what)
{
return { ok:true, x:this.SortedWords[idx] };
}//if
return { ok:false, x:0 };
};
IngestWords.prototype._WordsInit = function()
{
// Init the index array
this.SortedWords = new Uint32Array(2048);
for (var i=0; i<2048; i++)
{
this.SortedWords[i] = i;
}//for
// Sort the array
this.SortedWords = _SortWords(this.SortedWords, IngestWords.Words2048);
};
var _SortWords = function(src, ref)
{
src = src.sort(function(a, b)
{
return ref[a] > ref[b] ? 1
: ref[a] < ref[b] ? -1
: 0;
});
return src;
};
IngestWords.Words2048 =
[
"act","add","age","ago","aim","air","all","and","any","arm","art","ash","ask","bad","bag","ban","bar","bat","bay","bed","bee","beg","bet","bid","big","bit","bow","box","boy","bug","bus","buy","cab","can","cap","car","cat","cop","cow","cry","cue","cup","cut","dad","day","die","dig","dip","dog","dot","dry","due","ear","eat","egg","ego","end","era","etc","eye","fan","far","fat","fee","few","fit","fix",
"fly","fog","for","fun","fur","gap","gas","get","gun","gut","guy","gym","hat","hay","her","hey","him","hip","his","hit","hot","how","hug","huh","ice","its","jar","jaw","jet","job","joy","key","kid","kit","lab","lap","law","leg","let","lid","lie","lip","log","lot","low","mad","man","map","may","mix","mom","mud","net","new","nod","not","now","nut","oak","odd","off","oil","old","one","our","out","owe","own","pad","pan",
"pat","pay","pen","pet","pie","pig","pin","pit","pop","pot","put","rat","raw","red","rib","rid","rip","row","run","say","see","set","she","shy","sir","sit","six","ski","sky","son","spy","sum","sun","tag","tap","tax","tea","ten","the","tie","tip","toe","top","toy","try","two","use","van","war","way","web","who","why","win","wow","yes","yet","you","able","acid","aide","ally","also","amid","area","army","atop","aunt",
"auto","away","baby","back","bake","ball","band","bank","bare","barn","base","bath","beam","bean","bear","beat","beef","beer","bell","belt","bend","best","bias","bike","bill","bind","bird","bite","blue","boat","body","boil","bold","bolt","bomb","bond","bone","book","boom","boot","born","boss","both","bowl","buck","bulb","bulk","bull","burn","bury","bush","busy","cage","cake","call","calm","camp","card","care","cart",
"case","cash","cast","cave","cell","chef","chew","chin","chip","chop","cite","city","clay","clip","club","clue","coal","coat","code","coin","cold","come","cook","cool","cope","copy","cord","core","corn","cost","coup","crew","crop","cure","cute","dare","dark","data","date","dawn","dead","deal","dear","debt","deck","deem","deep","deer","deny","desk","diet","dirt","dish","dock","doll","door","dose","down","drag","draw",
"drop","drug","drum","duck","dumb","dump","dust","duty","each","earn","ease","east","easy","echo","edge","edit","else","even","ever","evil","exam","exit","face","fact","fade","fail","fair","fall","fame","fare","farm","fast","fate","feed","feel","file","fill","film","find","fine","fire","firm","fish","five","flag","flat","flee","flip","flow","fold","folk","food","foot","fork","form","four","free","from","fuel","full",
"fund","gain","game","gang","gate","gaze","gear","gene","gift","girl","give","glad","goal","goat","gold","golf","good","grab","gray","grin","grip","grow","half","hall","hand","hang","hard","harm","hate","haul","have","head","heal","hear","heat","heel","help","herb","here","hero","hers","hide","high","hike","hill","hint","hire","hold","home","hook","hope","horn","host","hour","huge","hunt","hurt","icon","idea","into",
"iron","item","jail","jazz","join","joke","jump","jury","just","keep","kick","kill","kind","king","kiss","knee","know","lack","lake","lamp","land","lane","last","late","lawn","lead","leaf","lean","leap","left","lend","lens","less","life","lift","like","limb","line","link","lion","list","live","load","loan","lock","long","look","loop","loss","lost","lots","loud","love","luck","lung","mail","main","make","mall","many",
"mark","mask","mass","mate","math","meal","mean","meat","meet","melt","menu","mere","mild","milk","mill","mind","mine","miss","mode","mood","moon","more","most","move","much","must","myth","nail","name","near","neat","neck","need","nest","news","next","nice","nine","none","noon","norm","nose","note","odds","okay","once","only","onto","open","ours","oven","over","pace","pack","page","pain","pair","pale","palm","pant",
"park","part","pass","past","path","peak","peel","peer","pick","pile","pill","pine","pink","pipe","plan","play","plea","plot","plus","poem","poet","poke","pole","poll","pond","pool","poor","pork","port","pose","post","pour","pray","pull","pump","pure","push","quit","race","rack","rage","rail","rain","rank","rare","rate","read","real","rear","rely","rent","rest","rice","rich","ride","ring","riot","rise","risk","road",
"rock","role","roll","roof","room","root","rope","rose","ruin","rule","rush","sack","safe","sail","sake","sale","salt","same","sand","save","scan","seal","seat","seed","seek","seem","self","sell","send","sexy","shed","ship","shoe","shop","shot","show","shut","side","sign","silk","sing","sink","site","size","skip","slam","slip","slot","slow","snap","snow","soak","soap","soar","sock","sofa","soft","soil","sole","some",
"song","soon","sort","soul","soup","spin","spit","spot","star","stay","stem","step","stir","stop","such","suck","suit","sure","swim","tail","take","tale","talk","tall","tank","tape","task","team","tear","teen","tell","tend","tent","term","test","text","than","that","them","then","they","thin","this","thus","tide","tile","till","time","tiny","tire","toll","tone","tool","toss","tour","town","trap","tray","tree","trim",
"trip","tube","tuck","tune","turn","twin","type","unit","upon","urge","used","user","vary","vast","very","view","vote","wage","wait","wake","walk","wall","want","warn","wash","wave","weak","wear","weed","week","well","west","what","when","whip","whom","wide","wife","wild","will","wind","wine","wing","wipe","wire","wise","wish","with","wolf","word","work","wrap","yard","yeah","year","yell","your","zone","true","about",
"above","actor","adapt","added","admit","adopt","after","again","agent","agree","ahead","aisle","alarm","album","alien","alike","alive","alley","allow","alone","along","alter","among","angle","ankle","apart","apple","apply","arena","argue","arise","armed","array","arrow","aside","asset","avoid","await","awake","award","aware","basic","beach","beast","begin","being","belly","below","bench","birth","black","blade",
"blame","blank","blast","blend","bless","blind","blink","block","blond","blood","board","boast","bonus","boost","booth","brain","brake","brand","brave","bread","break","brick","bride","brief","bring","broad","brown","brush","buddy","build","bunch","burst","buyer","cabin","cable","candy","cargo","carry","carve","catch","cause","cease","chain","chair","chaos","charm","chart","chase","cheat","check","cheek","cheer",
"chest","chief","child","chill","chunk","claim","class","clean","clear","clerk","click","cliff","climb","cling","clock","close","cloth","cloud","coach","coast","color","couch","could","count","court","cover","crack","craft","crash","crawl","crazy","cream","crime","cross","crowd","cruel","crush","curve","cycle","daily","dance","death","debut","delay","dense","depth","diary","dirty","donor","doubt","dough","dozen",
"draft","drain","drama","dream","dress","dried","drift","drill","drink","drive","drown","drunk","dying","eager","early","earth","eight","elbow","elder","elect","elite","empty","enact","enemy","enjoy","enter","entry","equal","equip","error","essay","event","every","exact","exist","extra","faint","faith","fatal","fault","favor","fence","fever","fewer","fiber","field","fifth","fifty","fight","final","first","fixed",
"flame","flash","fleet","flesh","float","flood","floor","flour","fluid","focus","force","forth","forty","forum","found","frame","fraud","fresh","front","frown","fruit","fully","funny","genre","ghost","giant","given","glass","globe","glory","glove","grace","grade","grain","grand","grant","grape","grasp","grass","grave","great","green","greet","grief","gross","group","guard","guess","guest","guide","guilt","habit",
"happy","harsh","heart","heavy","hello","hence","honey","honor","horse","hotel","house","human","humor","hurry","ideal","image","imply","index","inner","input","irony","issue","jeans","joint","judge","juice","juror","kneel","knife","knock","known","label","labor","large","laser","later","laugh","layer","learn","least","leave","legal","lemon","level","light","limit","liver","lobby","local","logic","loose","lover",
"lower","loyal","lucky","lunch","magic","major","maker","march","match","maybe","mayor","medal","media","merit","metal","meter","midst","might","minor","mixed","model","month","moral","motor","mount","mouse","mouth","movie","music","naked","nasty","naval","nerve","never","newly","night","noise","north","novel","nurse","occur","ocean","offer","often","onion","opera","orbit","order","other","ought","outer","owner",
"paint","panel","panic","paper","party","pasta","patch","pause","phase","phone","photo","piano","piece","pilot","pitch","pizza","place","plain","plant","plate","plead","point","porch","pound","power","press","price","pride","prime","print","prior","prize","proof","proud","prove","pulse","punch","purse","quest","quick","quiet","quite","quote","radar","radio","raise","rally","ranch","range","rapid","ratio","reach",
"react","ready","realm","rebel","refer","relax","reply","rider","ridge","rifle","right","risky","rival","river","robot","round","route","royal","rumor","rural","salad","sales","sauce","scale","scare","scene","scent","scope","score","screw","seize","sense","serve","seven","shade","shake","shall","shame","shape","share","shark","sharp","sheep","sheer","sheet","shelf","shell","shift","shirt","shock","shoot","shore",
"short","shout","shove","shrug","sight","silly","since","sixth","skill","skirt","skull","slave","sleep","slice","slide","slope","small","smart","smell","smile","smoke","snake","sneak","solar","solid","solve","sorry","sound","south","space","spare","spark","speak","speed","spell","spend","spill","spine","spite","split","spoon","sport","spray","squad","stack","staff","stage","stair","stake","stand","stare","start",
"state","steak","steam","steel","steep","steer","stick","stiff","still","stock","stone","store","storm","story","stove","straw","strip","study","stuff","style","sugar","suite","sunny","super","sweat","sweep","sweet","swell","swing","sword","table","taste","teach","thank","their","theme","there","these","thick","thigh","thing","think","third","those","three","throw","thumb","tight","tired","title","today","tooth",
"topic","total","touch","tough","towel","tower","trace","track","trade","trail","train","trait","treat","trend","trial","tribe","trick","troop","truck","truly","trunk","trust","truth","tumor","twice","twist","uncle","under","union","unite","unity","until","upper","upset","urban","usual","valid","value","video","virus","visit","vital","vocal","voice","voter","wagon","waist","waste","watch","water","weave","weigh",
"weird","whale","wheat","wheel","where","which","while","white","whole","whose","widow","woman","works","world","worry","worth","would","wound","wrist","write","wrong","yield","young","yours","youth","false","abroad","absorb","accent","accept","access","accuse","across","action","active","actual","adjust","admire","affect","afford","agency","agenda","almost","always","amount","animal","annual","answer","anyone",
"anyway","appear","around","arrest","arrive","artist","aspect","assert","assess","assign","assist","assume","assure","attach","attack","attend","author","ballot","banana","banker","barrel","basket","battle","beauty","become","before","behalf","behave","behind","belief","belong","beside","better","beyond","bitter","bloody","border","borrow","bottle","bounce","branch","breath","breeze","bridge","bright","broken",
"broker","bronze","brutal","bubble","bucket","bullet","bureau","butter","button","camera","campus","candle","canvas","carbon","career","carpet","carrot","casino","casual","cattle","center","change","charge","cheese","choice","choose","circle","client","clinic","closed","closet","coffee","collar","combat","comedy","commit","comply","cookie","corner","cotton","county","cousin","create","credit","crisis","cruise",
"custom","dancer","danger","deadly","dealer","debate","debris","decade","deeply","defeat","defend","define","degree","depart","depend","depict","deploy","deputy","derive","desert","design","desire","detail","detect","device","devote","differ","dining","dinner","direct","divide","doctor","domain","donate","double","drawer","driver","during","easily","eating","editor","effect","effort","either","eleven","emerge",
"empire","employ","enable","endure","energy","engage","engine","enough","enroll","ensure","entire","entity","equity","escape","estate","evolve","exceed","except","expand","expect","expert","export","expose","extend","extent","fabric","factor","fairly","family","famous","farmer","faster","father","fellow","fierce","figure","filter","finger","finish","firmly","fiscal","flavor","flight","flower","flying","follow",
"forest","forget","formal","format","former","foster","fourth","freely","freeze","friend","frozen","future","galaxy","garage","garden","garlic","gather","gender","genius","gifted","glance","global","golden","ground","growth","guitar","handle","happen","hardly","hazard","health","heaven","height","hidden","highly","hockey","honest","hunger","hungry","hunter","ignore","immune","impact","import","impose","income",
"indeed","infant","inform","injure","injury","inmate","insect","inside","insist","intact","intend","intent","invent","invest","invite","island","itself","jacket","jungle","junior","ladder","lately","latter","launch","lawyer","leader","league","legacy","legend","length","lesson","letter","likely","liquid","listen","little","living","locate","lovely","mainly","makeup","manage","manual","marble","margin","marine",
"market","master","matter","medium","member","memory","mentor","merely","method","middle","minute","mirror","mobile","modern","modest","modify","moment","monkey","mostly","mother","motion","motive","museum","mutter","mutual","myself","narrow","nation","native","nature","nearby","nearly","needle","nobody","normal","notice","notion","number","object","obtain","occupy","office","online","oppose","option","orange",
"origin","others","outfit","outlet","output","oxygen","palace","parade","parent","parish","partly","patent","patrol","patron","pencil","people","pepper","period","permit","person","phrase","pickup","pillow","planet","player","please","plenty","plunge","pocket","poetry","policy","poster","potato","powder","prefer","pretty","priest","profit","prompt","proper","public","purple","pursue","puzzle","rabbit","random",
"rarely","rather","rating","reader","really","reason","recall","recent","recipe","record","reduce","reform","refuse","regain","regard","regime","region","reject","relate","relief","remain","remark","remind","remote","remove","rental","repair","repeat","report","rescue","resign","resist","resort","result","resume","retail","retain","retire","return","reveal","review","reward","rhythm","ribbon","ritual","rocket",
"rubber","ruling","runner","safely","safety","salary","salmon","sample","saving","scared","scheme","school","scream","screen","script","search","season","second","secret","sector","secure","seldom","select","seller","senior","sensor","series","settle","severe","shadow","shorts","should","shrimp","signal","silent","silver","simple","simply","singer","single","sister","sleeve","slight","slowly","smooth","soccer",
"social","sodium","soften","softly","solely","source","speech","sphere","spirit","spread","spring","square","stable","stance","statue","status","steady","strain","streak","stream","street","stress","strict","strike","string","stroke","strong","studio","stupid","submit","subtle","suburb","sudden","suffer","summer","summit","supply","surely","survey","switch","symbol","system","tackle","tactic","talent","target",
"temple","tender","tennis","thanks","theory","thirty","though","thread","thrive","throat","ticket","timber","timing","tissue","toilet","tomato","tongue","toward","tragic","trauma","travel","treaty","tribal","tunnel","turkey","twelve","twenty","unfair","unfold","unique","unless","unlike","update","useful","vacuum","valley","vanish","vendor","verbal","versus","vessel","viewer","virtue","vision","visual","volume",
"voting","wander","warmth","wealth","weapon","weekly","weight","widely","window","winner","winter","wisdom","within","wonder","wooden","worker","writer","yellow"
];
return IngestWords;
})();
// RTLUT: contains color lookup table and returns RGB colors for a numeric value.
var IngestLUT = (function()
{
function IngestLUT(min, max, lut_id, scale_type_id)
{
this.min = min;
this.max = max;
this.lut_id = lut_id != null ? lut_id : 30;
this.scale_type_id = scale_type_id != null ? scale_type_id : 0;
var rgb = _GetRGBsForTableID(this.lut_id);
this.r = rgb.r;
this.g = rgb.g;
this.b = rgb.b;
this.n = this.r.length;
this.rdiff = 1.0 / (this.max - this.min);
this.nsb1 = parseFloat(this.n - 1.0);
}//LUT
IngestLUT.prototype.GetRgbForIdx = function(i)
{
return [this.r[i], this.g[i], this.b[i]];
};
var _ScaleNormValueLOG10 = function(x) // y-you're going to inline this, right senpai VM?
{
x = Math.log(x * 9.0 + 1.0) * 0.43429448190325176;
x = Math.log(x * 9.0 + 1.0) * 0.43429448190325176;
x = Math.log(x * 9.0 + 1.0) * 0.43429448190325176;
x = Math.log(x * 9.0 + 1.0) * 0.43429448190325176;
return x;
};
var _ScaleNormValueLN = function(x)
{
x = Math.log(x * 1.718281828459045 + 1.0);
x = Math.log(x * 1.718281828459045 + 1.0);
x = Math.log(x * 1.718281828459045 + 1.0);
return x;
};
var _ScaleNormValueNasaPm25 = function(x)
{
// https://upload.wikimedia.org/wikipedia/commons/4/4f/483897main_Global-PM2.5-map.JPG
if (x > 0.25) x = 0.25 + (x - 0.25) * 0.16666667; // [0...1] -> [0...0.375]
x *= 2.66666667; // [0...0.375] -> [0...1]
return x;
};
IngestLUT.prototype.GetIdxForValue = function(x, rsn)
{
x = (x - this.min) * this.rdiff;
if (x > 1.0) x = 1.0; else if (x < 0.0) x = 0.0;
switch (this.scale_type_id)
{
case IngestLUT.ScaleType.LOG10:
x = _ScaleNormValueLOG10(x);
break;
case IngestLUT.ScaleType.LN:
x = _ScaleNormValueLN(x);
break;
case IngestLUT.ScaleType.NasaPm25:
x = _ScaleNormValueNasaPm25(x);
break;
}//switch
if (x > 1.0) x = 1.0; else if (x < 0.0) x = 0.0;
var i = parseInt(x * this.nsb1);
return rsn > 0 ? (i >>> rsn) << rsn : i;
};
IngestLUT.prototype.GetRgbForValue = function(x, rsn)
{
var i = this.GetIdxForValue(x, rsn);
return [this.r[i], this.g[i], this.b[i]];
};
var _SplitRGBLUT = function(src)
{
var nc = src.length / 3;
var rc = src.substring(0, nc);
var gc = src.substring(nc, nc * 2);
var bc = src.substring(nc * 2, nc * 3);
return { rc:rc, gc:gc, bc:bc, nc:nc };
};
var _vhtoi_u08 = function(d,s) { for(var i=0;i<d.length; i++)d[i]=parseInt(("0x"+s.substring(i<<1,(i<<1)+2))); };
var _GetTypedArraysForHexStringLUT = function(src)
{
var rgbc = _SplitRGBLUT(src);
var n = rgbc.nc >>> 1;
var r = new Uint8Array(n);
var g = new Uint8Array(n);
var b = new Uint8Array(n);
_vhtoi_u08(r, rgbc.rc);
_vhtoi_u08(g, rgbc.gc);
_vhtoi_u08(b, rgbc.bc);
return { r:r, g:g, b:b };
};
var _GetRGBsForTableID = function(table_id)
{
var row = null;
var rgb = null;
for (var i=0; i<IngestLUT.LUTs.length; i++)
{
if (IngestLUT.LUTs[i][0] == table_id)
{
row = IngestLUT.LUTs[i];
break;
}//if
}//for
if (row != null)
{
rgb = _GetTypedArraysForHexStringLUT(row[13]);
}//if
return rgb;
};
IngestLUT.LUTs =
[
[13,14,"Cherenkov","GB",1,1,1,1,1,1,0,0.0,0.0,"0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003060A0D1114181B1F2226292D3034373B3E4245494C4F53565A5D6164686B6F7276797D8084878B8E9295999A9C9EA0A2A4A5A7A9ABADAFB1B2B4B6B8BABCBEBFC1C3C5C7C9CBCCCED0D2D4D6D8D9DBDDDFE1E3E5E6E8EAECEEF0F2F3F5F7F9FBFDFD0001030507090B0D0F11121416181A1C1E2022232527292B2D2F31333436383A3C3E4042444547494B4D4F51535556585A5C5E6062646667696B6D6F71737577797B7D7F81838587898B8D8F91939597999A9B9D9E9FA1A2A3A5A6A7A9AAABADAEAFB1B2B3B5B6B7B9BABBBDBEBFC1C2C3C5C6C7C9CACCCDCED0D1D2D4D5D6D8D9DADCDDDEE0E1E2E4E5E6E8E9EAECEDEEF0F1F2F4F5F6F8F9FAFCFDFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF66686B6E717477797C7F8285888A8D909396999B9EA1A4A7AAACAFB2B5B8BBBDC0C3C6C9CCCED1D4D7DADDDFE2E5E8EBEEF0F3F6F9FCFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"],
[20,5,"Blue Red Blended","FLIR",1,1,1,1,1,1,0,0.0,0.0,"0D0D0D0C0C0C0C0C0C0C0C0C0B0B0B0B0B0C0C0D0D0D0D0D0D0D0E0E0E0E0E0E0E0F0F10101010101111121313141415151516161718181818191A1C1D1E1F202021222324252627292A2B2C2E2F303133343637393A3B3D3E4042444647484A4C4F51535557595B5D5F61636567696B6D6F727577797C7E80828486898C8E9092959698999C9EA1A3A5A8AAADAFB1B3B5B7BABCBEC0C2C4C7C9CBCDCFD1D3D5D6D9DADCDDDFE1E2E4E6E7E9EAEBEDEEEFF0F1F1F2F3F3F4F5F6F7F7F8F8F8F8F8F7F7F6F6F5F5F5F4F4F4F3F3F2F2F2F1F0EEEDECEBE9E7E6E5E4E2E1DFDDDCDBDAD8D7D6D4D3D1CFCDCAC8C6C4C2C0BEBCBAB8B6B3B1AFADAAA8A6A3A2A09E3F3F404143444647494B4C4E4F5153545657595B5D5F61636567696B6D6F71737577797B7C7D7F80828486888A8C8E90929597999C9EA0A2A4A7A9ABADAFB1B3B5B7B9BBBDBFC1C3C5C7C9CBCDCED0D1D3D4D6D7D9DBDCDDDFE0E1E3E4E5E6E7E8E8E9E9EAEAEAEBEBECEDEDEEEEEEEFEFEFEFEEEEEDEDECECEBEBEAE9E9E8E7E7E6E6E5E5E3E2E1DFDEDCDBD9D8D7D5D4D2D0CFCFCDCBC8C7C5C3C0BEBCBAB8B5B3B1AFADABA9A6A4A2A19E9B9794928F8D8B89878583807E7C7A77757371706E6C6A68666462605E5C5A58565452504E4D4C4A484745444341403F3D3C3B3938373635333231302F2E2D2C2C2B29282726252423222120201F1E1E1D1D1D1DE1E2E3E4E5E7E9EAEBEDEEF0F1F3F4F5F6F7F7F8F9F9FAFAFAFAFBFBFCFCFCFDFDFDFDFDFDFDFCFCFBFAFAF9F8F7F6F6F5F4F4F3F2F1EFEEEDEBEAE8E7E4E2E1E0DDDCDAD9D7D6D4D1CFCDCBC9C7C4C2C0BDBAB7B5B3B1AEACA9A6A4A29F9C9A979593918F8C8A8783817F7D7B797674716F6C6A68666462605E5C5A575553504E4C4B494846454342403E3D3C3A3837353331302E2D2B2A28272625242321201F1E1D1C1B1A19181716151413121211111010100F0E0E0D0D0C0C0B0B0B0A0A0A0A0A090909080808080707070606060607070707070706060606070707070707070707070708080807070707070808080808080808080808090909090A0A0A"],
[30,0,"Cyan Halo","GB",1,1,1,1,1,1,0,0.0,0.0,"0108090A0C0E10101212131415161618181919191A1A1A1A191A1B1A191A1A181819181515151110090700070F171C202226282B2D2E323336373838383A3B3B3B3B3B3B3B3B393838383633302D2B2725211D170A001D273C43545A61696E787C85898F9499A1A3ABADB2B5B9BFC2C8CAD0D2D6D9DCE1E2E9EBF0F2F5F9FBFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF010707080A0B0C0C0D0D0D0D0E0E0E0F0F0F0F0F0F0F0F0F0F0F0F0F0F0E0E0E0E0D0D0C0B0B0A0905040009131E242B2E383B41464A52555E60676B70767982848C90969CA0A7AAB5B8BFC3C8D0D5DDE0E9EDF3FAFFFCFBF2F0EBE7E2DDDBD4D2CCCAC5C0BBB6B4ACAAA3A09C97948986807C75706B646157534740382C2605000000000000000000000000000000000000000000000000000000000000000000000000000000000000000B19242A3539444951555960626A6D777B8085889092999CA2A6AAB4B7BFC1C8CCD0D6D9E0E2EAEFF7FBFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF010A0C0F13171D1F26272B30363B3D46484F53595E636D707A7D878C91999EA9ADBABFC7CED4DFE4EFF4FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEF7F2EAE3DDD3CFC4C0B7B3AEA6A19A978C88807B77716F66645E58514B48413F37342F2A26201D120D0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080A14171F24292F333E414A4E545A5E6669737680858A91949D9FA8ACB3BABFC6CAD3D7DEE2E8EEF2FD"],
[32,8,"Jet","MATLAB", 1,1,1,1,1,1,0,0.0,0.0,"000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000103080C0F12181C1F232A2D3033393C3F42484C4F52585C5F646A6D70737A7D8083898C8F92989C9FA2A8ACAFB4BABDC0C3CACDD0D3D9DCDFE2E8ECEFF4FAFCFDFEFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFEFEFDFCF9F3F0EDEAE4DFDCD8D2CFCCC9C3C0BDBAB3B0ADAAA49F9C98928F8C8882807F7F00000000000000000000000000000000000000000000000000000000000001040A0D1013191C1F22282C2F32383C3F444A4D50535A5D6063696C6F72787C7F848A8E90949A9DA0A3A9ACAFB2B8BCBFC2C8CCCFD4DADDE0E3EAEDF0F3F9FBFDFEFEFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFEFEFDFBF8F2EFECE9E3E0DDDAD3D0CDCAC4BFBCB8B2AFACA8A29F9C9993908D8A837F7C77716E6C68625F5C5953504D4A43403D3A342F2C28221F1C18120F0C090401000000000000000000000000000000000000000000000000000000000000000000008F8F9092989C9FA2A8ACAFB4BABDC0C3CACDD0D3D9DCDFE2E8ECEFF4FAFCFDFEFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFEFEFDFCF9F3F0EDEAE4DFDCD8D2CFCCC9C3C0BDBAB3B0ADAAA49F9C98928F8C88827F7C7973706D6A63605D5A544F4C48423F3C38322F2C2923201D1A130F0C0802010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"],
[34,16,"Glowbow","FLIR",1,1,1,1,1,1,0,0.0,0.0,"00000306090C0F1315181B1E2225282C303336393B3E4144474B4F53585D6266696C6F7376797C808386898D909396999DA1A4A6A9ADB1B4B7BABCBFC2C6C9CBCBCCCDCFCFD0D0D0D1D2D3D3D4D6D7D7D8D9DADADADCDDDEDFE0E1E1E1E2E4E5E5E6E6E7E8E9EAECECECEDEDEEEFF0F1F2F3F4F4F5F5F5F7F8F9F9FAFAFBFCFCFCFCFCFDFDFCFCFCFCFCFCFCFCFCFDFDFDFDFDFDFDFDFDFDFDFCFCFCFCFCFCFCFCFCFCFCFDFDFDFDFDFDFDFDFDFDFDFDFCFCFCFCFCFCFCFCFDFDFDFDFDFDFDFCFCFCFCFDFDFDFDFDFDFDFCFCFCFCFDFDFDFDFDFDFCFCFCFCFCFCFCFCFDFDFDFCFCFCFCFDFDFCFCFCFCFCFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFCFCFCFCFDFE00000001010101010101020304040404040506060607080808080809090A0A0B0B0C0C0D0D0D0D0E0F0F0F0F0F0F10111111111112131414141414151515161718191A1C1D1E1E1E2021222324262728292B2C2C2C2E2F30313334353637393A3A3B3C3D3E404143434445454748494A4B4D4E4E4F51535353545657595A5A5B5E60626466686A6C6E7072747677797C7F80828486888A8C8D9092949597999B9D9EA1A3A5A7AAACADAFB1B3B5B7B9BBBDBFC0C2C4C7C9CACCCED1D3D5D7D9DADADADBDCDCDDDEDEDFDFDFDFE0E1E2E3E4E4E5E5E5E5E7E7E7E9EAEAEAEAECEDEDEDEEEFEFF0F0F1F1F1F2F3F4F4F5F5F5F6F7F7F8F9F9FAFAFBFCFDFDFEFEFE00000000000000020203030304040506070708090B0B0B0B0B0C0E0E0E0F111313131314141415171717181818191A1B1C1D1E1E1E1F2020202021222224252523222221212020201F1E1D1D1C1C1B1B1A19181818171615141414131312111111100E0E0E0D0C0C0C0C0B0B0A090806060606060504030303010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000105080C1013171C2124272C3034373B4043464A4E53585D6063676B6F74787C7F83868A8E93979A9EA2A7ABAFB4B8BCBFC2C7CBCFD3D7DBDFE4E8ECEFF2F7FBFE"]
];
IngestLUT.ScaleType =
{
LN: 0,
LIN: 1,
LOG10: 2,
NasaPm25: 3
};
return IngestLUT;
})();
// ICO: Renders marker icon to ivar "this.url" as base64 png.
// Can be retained in cache as rendering pngs is slow.
// This is completely ignorant of retina displays.
var IngestIcon = (function()
{
function IngestIcon(width, height, deg, val_rgba, online_rgba, min_rgba, max_rgba, render_style)//, fxCallback)
{
this.width = width;
this.height = height;
this.deg = deg;
this.val_rgba = val_rgba;
this.online_rgba = online_rgba;
this.shd_r = 0.0; // unsupported, but must be 0.0 for legacy calcs
this.min_rgba = min_rgba;
this.max_rgba = max_rgba;
this.rstyle = render_style;
this.last_use = Date.now();
this.url = null;
//this.Render(fxCallback);
}//IngestIcon
IngestIcon.prototype.IsStale = function()
{
return Date.now() - this.last_use > 30.0 * 60.0 * 1000.0;
};
IngestIcon.prototype.UpdateLastUse = function()
{
this.last_use = Date.now();
};
var _ceq_rgba = function(a, b)
{
return (a==null && b==null) || (a!=null && b!=null && a.r==b.r && a.g==b.g && a.b==b.b && a.a==b.a);
};
IngestIcon.prototype.CompareToParams = function(width, height, deg, val_rgba, online_rgba, min_rgba, max_rgba, render_style)
{
return this.width == width
&& this.height == height
&& this.deg == deg
&& _ceq_rgba(this.val_rgba, val_rgba)
&& _ceq_rgba(this.online_rgba, online_rgba)
&& _ceq_rgba(this.min_rgba, min_rgba)
&& _ceq_rgba(this.max_rgba, max_rgba)
&& this.rstyle == render_style;
};
IngestIcon.prototype.RenderComplete = function(fxCallback)
{
if (fxCallback != null)
{
fxCallback(this.url);
}//if
};
var _RenderStatusCircle = function(ctx, ox, oy, outer_r, rgba, scale, is_online)
{
var c_green = "rgba(" + rgba.r + ", " + rgba.g + ", " + rgba.b + ", " + rgba.a + ")";
if (!is_online)
{
var min_angle = 0.0;
var max_angle = 2.0 * Math.PI;
var steps = 6.0;
var step_size = (max_angle - min_angle) / steps;
for (var i=0; i<steps; i++)
{
var start_angle = parseFloat(i) * step_size;
var end_angle = start_angle + step_size * 0.75;
ctx.beginPath(); // stroke thick black outline
ctx.arc(ox, oy, outer_r, start_angle, end_angle);
ctx.strokeStyle = "rgba(0,0,0," + rgba.a + ")";
ctx.lineWidth = Math.max(3.5 * scale, 3.5);
ctx.stroke();
ctx.beginPath(); // stroke thinner green inner arc
ctx.arc(ox, oy, outer_r, start_angle, end_angle);
ctx.strokeStyle = c_green;
ctx.lineWidth = Math.max(1.5 * scale, 1.5);
ctx.stroke();
// By default, looks a bit dark due to antialiasing with black,
// so stroke green 2x more at decreasing widths.
ctx.beginPath(); // repeat green stroke
ctx.arc(ox, oy, outer_r, start_angle, end_angle);
ctx.strokeStyle = c_green;
ctx.lineWidth = Math.max(1.0 * scale, 1.0);
ctx.stroke();
ctx.beginPath(); // repeat green stroke
ctx.arc(ox, oy, outer_r, start_angle, end_angle);
ctx.strokeStyle = c_green;
ctx.lineWidth = Math.max(0.5 * scale, 0.5);
ctx.stroke();
}//for
}//if
else
{
// ------------------------ outer ring -------------------------------
ctx.beginPath(); // stroke thick black outline
ctx.arc(ox, oy, outer_r, 0, 2 * Math.PI);
ctx.strokeStyle = "rgba(0,0,0," + rgba.a + ")";
ctx.lineWidth = Math.max(3.5 * scale, 3.5);
ctx.stroke();
ctx.beginPath(); // stroke thinner green inner arc
ctx.arc(ox, oy, outer_r, 0, 2 * Math.PI);
ctx.strokeStyle = c_green;
ctx.lineWidth = Math.max(1.5 * scale, 1.5);
ctx.stroke();
// By default, looks a bit dark due to antialiasing with black,
// so stroke green 2x more at decreasing widths.
ctx.beginPath(); // repeat green stroke
ctx.arc(ox, oy, outer_r, 0, 2 * Math.PI);
ctx.strokeStyle = c_green;
ctx.lineWidth = Math.max(1.0 * scale, 1.0);
ctx.stroke();
ctx.beginPath(); // repeat green stroke
ctx.arc(ox, oy, outer_r, 0, 2 * Math.PI);
ctx.strokeStyle = c_green;
ctx.lineWidth = Math.max(0.5 * scale, 0.5);
ctx.stroke();
}//else
};
IngestIcon.prototype.Render = function(fxCallback)
{
if (this.rstyle == IngestIcon.RenderStyle.Dot)
{
this.RenderDot();
this.RenderComplete(fxCallback);
/*
setTimeout(function() {
this.RenderComplete(fxCallback);
}.bind(this), 1);
*/
}//if
else if (this.rstyle == IngestIcon.RenderStyle.Chevron)
{
this.RenderChevron();
this.RenderComplete(fxCallback);
/*
setTimeout(function() {
this.RenderComplete(fxCallback);
}.bind(this), 1);
*/
}//else if
else
{
this.RenderDoubleTriangle(fxCallback);
}//else
};
IngestIcon.prototype.RenderDot = function()
{
var c = document.createElement("canvas");
var w_add = (this.shd_r - (this.width >> 1)) * 2;
var h_add = (this.shd_r - (this.height >> 1)) * 2;
var w_px = this.width + Math.max(0, w_add);
var h_px = this.height + Math.max(0, h_add); // ignore, shd_r is always 0 here.
c.width = w_px;
c.height = h_px;
var ctx = c.getContext("2d");
var r = ((this.width < this.height ? this.width : this.height) >> 1) - 1; // radius
var ox = w_px >> 1; // offset to center
var oy = h_px >> 1;
if (r <= 0) r = 1;
var scale = w_px / 20.0;
var outer_r = r - 1.0 * scale; // buffer for antialiasing
if (scale > 1.0) outer_r -= scale; // wtf
var inner_r = outer_r - 4.0 * scale; // 4px diff is ultimately about 1 visual pixel spacing
if (w_px <= 12) inner_r = outer_r - 3.0 * scale;
//var c_fill = "rgba(" + this.val_rgba.r + ", " + this.val_rgba.g + ", " + this.val_rgba.b + ", " + this.val_rgba.a + ")";
var c_fill = _make_css_rgba(this.val_rgba);
// ------------------------ inner dot -------------------------------
ctx.beginPath(); // fill with variable color
ctx.arc(ox, oy, inner_r, 0, 2 * Math.PI);
ctx.fillStyle = c_fill;
ctx.fill();
ctx.beginPath(); // stroke black outline
ctx.arc(ox, oy, inner_r, 0, 2 * Math.PI);
//ctx.strokeStyle = "rgba(0,0,0," + this.val_rgba.a + ")";
ctx.strokeStyle = "rgba(0,0,0," + _get_effective_alpha(this.val_rgba) + ")";
ctx.lineWidth = w_px > 12 ? 1.5 * scale : 0.75 * scale;
ctx.stroke();
_RenderStatusCircle(ctx, ox, oy, outer_r, this.online_rgba, scale, this.online_rgba.r == 0);
this.url = c.toDataURL("image/png");
};
IngestIcon.prototype.RenderChevron = function()
{
var c = document.createElement("canvas");
var w_add = (this.shd_r - (this.width >> 1)) * 2;
var h_add = (this.shd_r - (this.height >> 1)) * 2;
var w_px = this.width + Math.max(0, w_add);
var h_px = this.height + Math.max(0, h_add); // ignore, shd_r is always 0 here.
c.width = w_px;
c.height = h_px;
var ctx = c.getContext("2d");
var r = ((this.width < this.height ? this.width : this.height) >> 1) - 1; // radius
var ox = w_px >> 1; // offset to center
var oy = h_px >> 1;
if (r <= 0) r = 1;
var scale = w_px / 20.0;
var outer_r = r - 1.0 * scale; // buffer for antialiasing
if (scale > 1.0) outer_r -= scale; // wtf
var inner_r = outer_r - 4.0 * scale; // 4px diff is ultimately about 1 visual pixel spacing
if (w_px <= 12) inner_r = outer_r - 3.0 * scale;
//var c_fill = "rgba(" + this.val_rgba.r + ", " + this.val_rgba.g + ", " + this.val_rgba.b + ", " + this.val_rgba.a + ")";
var c_fill = _make_css_rgba(this.val_rgba);
_RenderStatusCircle(ctx, ox, oy, outer_r, this.online_rgba, scale, this.online_rgba.r == 0);
// ---------------------- chevron ----------------------------
oy = Math.max(0, h_add) >> 1;
oy += 4.0 * scale;
var length = w_px - 4.0 * scale * 2.0;
var degrees0 = 180.0 - 30.0;
var degrees1 = 180.0 + 30.0;
var dx,dy,x0,y0,x1,y1;
// not sure why deg - 90 is needed...
degrees0 = (degrees0 - 90.0) * 0.01745329251994329576923690768489; // ->rad
degrees1 = (degrees1 - 90.0) * 0.01745329251994329576923690768489; // ->rad
dx = Math.cos(degrees0) * length;
dy = Math.sin(degrees0) * length;
x0 = ox + dx;
y0 = oy + dy;
dx = Math.cos(degrees1) * length;
dy = Math.sin(degrees1) * length;
x1 = ox + dx;
y1 = oy + dy;
ctx.beginPath();
//ctx.strokeStyle = "rgba(0,0,0," + this.val_rgba.a + ")";
ctx.strokeStyle = "rgba(0,0,0," + _get_effective_alpha(this.val_rgba) + ")";
ctx.lineWidth = scale * 8.0 * 0.75;
ctx.moveTo(x0, y0); // bottom-right corner
ctx.lineTo(ox, oy + scale * 4.0 * 0.5); // top-center
ctx.lineTo(x1, y1); // bottom-left corner
ctx.stroke();
var linediff = ((scale * 8.0 * 0.75) - (scale * 8.0 * 0.5)) * 0.5;
// inner filled color chevron
ctx.beginPath();
ctx.strokeStyle = c_fill;
ctx.lineWidth = scale * 8.0 * 0.5;
ctx.moveTo(x0 - linediff, y0 - linediff); // bottom-right corner
ctx.lineTo(ox, oy + scale * 4.0 * 0.5); // top-center
ctx.lineTo(x1 + linediff, y1 - linediff); // bottom-left corner
ctx.stroke();
this.url = c.toDataURL("image/png");
};
var _make_css_rgba = function(rgba)
{
if (rgba == null) return "rgba(0,0,0,0)";