... | ... |
@@ -35,6 +35,8 @@ var mapClass = { |
35 | 35 |
|
36 | 36 |
m.layers = {}; |
37 | 37 |
m.layers.tiles = MapTiles.new(m.device, m.group); |
38 |
+ if (m.device.role == 'MFD') |
|
39 |
+ m.layers.topo = MapTopo.new(m.device, m.group); |
|
38 | 40 |
m.layers.route = MapRoute.new(m.device, m.group); |
39 | 41 |
m.layers.navaids = MapNavaids.new(m.device, m.group); |
40 | 42 |
if (m.device.role == 'MFD') |
... | ... |
@@ -0,0 +1,95 @@ |
1 |
+var MapTopo = { |
|
2 |
+ new : func(device, group) { |
|
3 |
+ var m = { parents: [ MapTopo ] }; |
|
4 |
+ m.device = device; |
|
5 |
+ m.visibility = 0; |
|
6 |
+ m.group = group.createChild('map', 'topo') |
|
7 |
+ .setTranslation((m.device.data.mapview[0] + m.device.data.mapclip.left)/2, 400) |
|
8 |
+ .setRotation(m.device.data.orientation.airplane * D2R) |
|
9 |
+ .setVisible(m.visibility); |
|
10 |
+ m.radar = []; |
|
11 |
+ for (var dist = 0; dist < 10; dist += 1) { |
|
12 |
+ append(m.radar, []); |
|
13 |
+ for (var radial = 0; radial < 11; radial += 1) { |
|
14 |
+ append(m.radar[dist], m.arc((radial * 10) - 50, (dist * 35) + 10)); |
|
15 |
+ } |
|
16 |
+ } |
|
17 |
+ data.timers.topo_radar = maketimer(0, func { |
|
18 |
+ var (radial, dist) = [m.radial, m.dist]; |
|
19 |
+ var geo = greatCircleMove(data.hdg + ((radial * 10) - 50), |
|
20 |
+ m.delta_radar_dist_nm * dist + m.delta_radar_dist_nm/2); |
|
21 |
+ var _geodinfo = geodinfo(geo.lat, geo.lon, 10000); |
|
22 |
+ if (_geodinfo != nil) { |
|
23 |
+ var diff = _geodinfo[0] * units.altitude.from_m - data.alt; |
|
24 |
+ |
|
25 |
+ var color = [1, 0.5, 0.16, 1]; |
|
26 |
+ if (diff > 1000 * units.altitude.from_ft) |
|
27 |
+ color = [1, 0, 0, 1]; |
|
28 |
+ |
|
29 |
+ m.radar[dist][radial] |
|
30 |
+ .setColorFill(color) |
|
31 |
+ .setVisible(diff > 0); |
|
32 |
+ } |
|
33 |
+ if (m.radial < 10) # size(m.radar[m.dist]) - 1 |
|
34 |
+ m.radial += 1; |
|
35 |
+ elsif (m.dist < 9) { # size(m.radar) -1 |
|
36 |
+ m.dist += 1; |
|
37 |
+ m.radial = 0; |
|
38 |
+ } |
|
39 |
+ else { |
|
40 |
+ m.dist = 0; |
|
41 |
+ m.radial = 0; |
|
42 |
+ } |
|
43 |
+ }); |
|
44 |
+ m.device.data.orientation.radar = 0; |
|
45 |
+ m.dist = 0; |
|
46 |
+ m.radial = 0; |
|
47 |
+ m.delta_radar_dist_nm = m.device.data['range-nm'] / size(m.radar); |
|
48 |
+ return m; |
|
49 |
+ }, |
|
50 |
+ |
|
51 |
+ arc: func(radial, dist) { |
|
52 |
+ var from_deg = (radial - 5) * D2R; |
|
53 |
+ var to_deg = (radial + 5) * D2R; |
|
54 |
+ var (fs1, fc1) = [math.sin(from_deg), math.cos(from_deg)]; |
|
55 |
+ var dx1 = (math.sin(to_deg) - fs1) * dist; |
|
56 |
+ var dy1 = (math.cos(to_deg) - fc1) * dist; |
|
57 |
+ var (fs2, fc2) = [math.sin(to_deg), math.cos(to_deg)]; |
|
58 |
+ var dx2 = (math.sin(from_deg) - fs2) * (dist + 35); |
|
59 |
+ var dy2 = (math.cos(from_deg) - fc2) * (dist + 35); |
|
60 |
+ |
|
61 |
+ return me.group.createChild('path', sprintf('arc %-02i@%02i', radial, dist)) |
|
62 |
+ .moveTo(dist*fs1, -dist*fc1) |
|
63 |
+ .arcSmallCW(dist, dist, 0, dx1, -dy1) |
|
64 |
+ .lineTo((dist + 35)*fs2, -(dist + 35)*fc2) |
|
65 |
+ .arcSmallCW(dist + 35, dist + 35, 0, dx2, -dy2) |
|
66 |
+ .close() |
|
67 |
+ .setColorFill(1,0,0,0.75) |
|
68 |
+ .setVisible(0); |
|
69 |
+ }, |
|
70 |
+ |
|
71 |
+ setVisible : func (v) { |
|
72 |
+ if (me.visibility != v) { |
|
73 |
+ me.visibility = v; |
|
74 |
+ me.group |
|
75 |
+ .setRotation(me.device.data.orientation.airplane * D2R) |
|
76 |
+ .setVisible(v); |
|
77 |
+ } |
|
78 |
+ if (me.visibility) |
|
79 |
+ data.timers.topo_radar.start(); |
|
80 |
+ else |
|
81 |
+ data.timers.topo_radar.stop(); |
|
82 |
+ }, |
|
83 |
+ |
|
84 |
+ off : func { |
|
85 |
+ me.setVisible(0); |
|
86 |
+ me.group.removeAllChildren(); |
|
87 |
+ }, |
|
88 |
+ |
|
89 |
+ update : func { |
|
90 |
+ if (me.visibility) { |
|
91 |
+ me.group.setRotation(me.device.data.orientation.airplane * D2R); |
|
92 |
+ me.delta_radar_dist_nm = me.device.data['range-nm'] / size(me.radar); |
|
93 |
+ } |
|
94 |
+ }, |
|
95 |
+}; |
... | ... |
@@ -1126,6 +1126,9 @@ var softkeysClass = { |
1126 | 1126 |
TERRAIN: func { |
1127 | 1127 |
call(me.bindings.PFD.INSET.declutter, ['MAPTERRAIN', 'tiles', 3], me); |
1128 | 1128 |
}, |
1129 |
+ TOPO: func { |
|
1130 |
+ call(me.bindings.PFD.INSET.declutter, ['MAPTOPO', 'topo', 7], me); |
|
1131 |
+ }, |
|
1129 | 1132 |
NAVAIDS: { |
1130 | 1133 |
ALL: func { |
1131 | 1134 |
call(me.bindings.PFD.INSET.NAVAIDS.ALL, [ 'MAPNAVAIDS' ], me); |
... | ... |
@@ -10,6 +10,7 @@ files_to_load = [ |
10 | 10 |
'maps/navaids.nas', |
11 | 11 |
'maps/tiles.nas', |
12 | 12 |
'maps/tcas.nas', |
13 |
+ 'maps/topo.nas', |
|
13 | 14 |
'map.nas', # moves the maps |
14 | 15 |
'display.nas', |
15 | 16 |
'menu.nas', # manage windows |