Reparse JSON flightdata

Aus AirSpaceWatch & More
Zur Navigation springen Zur Suche springen
 1 var tooltip0 = msg.payload[17];
 2 var tooltip = msg.payload[0];
 3 if (msg.payload[1] == 1) {
 4         icon0 = "plane";
 5         }
 6         else if (msg.payload[1] == 3) {
 7         icon0 = "helicopter";
 8         icolor0 = "#933ff";
 9         }
10         else if (msg.payload[1] == 8) {
11         icon0 = "plane";
12         }
13         else if (msg.payload[1] == 13) {
14         icon0 = "uav";
15         }
16         else {
17         icon0 = "arrow";
18         }
19 if (msg.payload[10] === 1800) {
20         icolor0 = "#999999";
21         }
22         else if (msg.payload[6] < 1000){
23         icolor0 = "orange";
24         }
25         else if (msg.payload[6] > 1500){
26             icolor0 = "green";
27         }
28         else {
29             icolor0= "blue";
30         }
31 msg.payload = { 
32       "name": msg.payload[0],
33       "type": msg.payload[1],
34       "date": msg.payload[2],
35       "age": msg.payload[3],
36       "lat": msg.payload[4], 
37       "lon": msg.payload[5],
38       "height": msg.payload[6],
39       "speed": msg.payload[9],
40       "bearing": msg.payload[10],
41       "vert-speed": msg.payload[11],
42       "turn-rate": msg.payload[12],
43       "relay": msg.payload[16],
44       "tooltip": tooltip,
45       "battery": msg.payload[18],
46       "label": tooltip0[0]+"<br>"+msg.payload[6]+" m",
47       "icon": icon0,
48       "iconColor": icolor0,
49       "lineColor":"#e69900",
50       "popped": false,
51       // if layer is defined here, icon disappears on update
52       "layer":"Glider"
53 }
54 return msg