topo display is now availabl...
|
1 |
var MapTopo = { |
2 |
new : func(device, group) { |
|
3 |
var m = { parents: [ MapTopo ] }; |
|
4 |
m.device = device; |
|
5 |
m.visibility = 0; |
|
faster topo rendering
|
6 |
m.dist_scale = 10; |
7 |
m.radial_scale = 11; |
|
8 |
m.group = group.createChild('group', 'topo') |
|
topo display is now availabl...
|
9 |
.setTranslation((m.device.data.mapview[0] + m.device.data.mapclip.left)/2, 400) |
10 |
.setRotation(m.device.data.orientation.airplane * D2R) |
|
11 |
.setVisible(m.visibility); |
|
faster topo rendering
|
12 |
for (var dist = 0; dist < m.dist_scale; dist += 1) { |
topo display is now availabl...
|
13 |
for (var radial = 0; radial < 11; radial += 1) { |
faster topo rendering
|
14 |
if (radial + dist) |
15 |
m.arc((radial * 10) - 50, (dist * 35) + 10); |
|
16 |
else |
|
17 |
m.path = m.arc((radial * 10) - 50, (dist * 35) + 10).parents[1]._node.getPath(); |
|
topo display is now availabl...
|
18 |
} |
19 |
} |
|
20 |
data.timers.topo_radar = maketimer(0, func { |
|
21 |
var (radial, dist) = [m.radial, m.dist]; |
|
22 |
var geo = greatCircleMove(data.hdg + ((radial * 10) - 50), |
|
23 |
m.delta_radar_dist_nm * dist + m.delta_radar_dist_nm/2); |
|
24 |
var _geodinfo = geodinfo(geo.lat, geo.lon, 10000); |
|
25 |
if (_geodinfo != nil) { |
|
26 |
var diff = _geodinfo[0] * units.altitude.from_m - data.alt; |
|
27 | ||
faster topo rendering
|
28 |
var color = 'rgba(255, 127, 40, 1)'; |
topo display is now availabl...
|
29 |
if (diff > 1000 * units.altitude.from_ft) |
faster topo rendering
|
30 |
color = 'rgba(255, 0, 0, 1)'; |
topo display is now availabl...
|
31 | |
faster topo rendering
|
32 |
setprop(m.path, radial + m.radial_scale * dist, 'fill', color); |
33 |
setprop(m.path, radial + m.radial_scale * dist, 'visible', diff > 0); |
|
topo display is now availabl...
|
34 |
} |
faster topo rendering
|
35 |
if (m.radial < m.radial_scale - 1) |
topo display is now availabl...
|
36 |
m.radial += 1; |
faster topo rendering
|
37 |
elsif (m.dist < m.dist_scale - 1) { |
topo display is now availabl...
|
38 |
m.dist += 1; |
39 |
m.radial = 0; |
|
40 |
} |
|
41 |
else { |
|
42 |
m.dist = 0; |
|
43 |
m.radial = 0; |
|
44 |
} |
|
45 |
}); |
|
46 |
m.device.data.orientation.radar = 0; |
|
47 |
m.dist = 0; |
|
48 |
m.radial = 0; |
|
faster topo rendering
|
49 |
m.delta_radar_dist_nm = m.device.data['range-nm'] / m.dist_scale; |
topo display is now availabl...
|
50 |
return m; |
51 |
}, |
|
52 | ||
53 |
arc: func(radial, dist) { |
|
54 |
var from_deg = (radial - 5) * D2R; |
|
55 |
var to_deg = (radial + 5) * D2R; |
|
56 |
var (fs1, fc1) = [math.sin(from_deg), math.cos(from_deg)]; |
|
57 |
var dx1 = (math.sin(to_deg) - fs1) * dist; |
|
58 |
var dy1 = (math.cos(to_deg) - fc1) * dist; |
|
59 |
var (fs2, fc2) = [math.sin(to_deg), math.cos(to_deg)]; |
|
60 |
var dx2 = (math.sin(from_deg) - fs2) * (dist + 35); |
|
61 |
var dy2 = (math.cos(from_deg) - fc2) * (dist + 35); |
|
62 | ||
63 |
return me.group.createChild('path', sprintf('arc %-02i@%02i', radial, dist)) |
|
64 |
.moveTo(dist*fs1, -dist*fc1) |
|
65 |
.arcSmallCW(dist, dist, 0, dx1, -dy1) |
|
66 |
.lineTo((dist + 35)*fs2, -(dist + 35)*fc2) |
|
67 |
.arcSmallCW(dist + 35, dist + 35, 0, dx2, -dy2) |
|
68 |
.close() |
|
69 |
.setColorFill(1,0,0,0.75) |
|
70 |
.setVisible(0); |
|
71 |
}, |
|
72 | ||
73 |
setVisible : func (v) { |
|
74 |
if (me.visibility != v) { |
|
75 |
me.visibility = v; |
|
76 |
me.group |
|
77 |
.setRotation(me.device.data.orientation.airplane * D2R) |
|
78 |
.setVisible(v); |
|
79 |
} |
|
80 |
if (me.visibility) |
|
81 |
data.timers.topo_radar.start(); |
|
82 |
else |
|
83 |
data.timers.topo_radar.stop(); |
|
84 |
}, |
|
85 | ||
86 |
off : func { |
|
87 |
me.setVisible(0); |
|
88 |
me.group.removeAllChildren(); |
|
89 |
}, |
|
90 | ||
91 |
update : func { |
|
92 |
if (me.visibility) { |
|
93 |
me.group.setRotation(me.device.data.orientation.airplane * D2R); |
|
faster topo rendering
|
94 |
me.delta_radar_dist_nm = me.device.data['range-nm'] / me.dist_scale; |
topo display is now availabl...
|
95 |
} |
96 |
}, |
|
97 |
}; |