massive code reorganisation ...
|
1 |
var mapClass = { |
2 |
new : func (device) { |
|
3 |
var m = { parents : [ mapClass ] }; |
|
4 |
m.device = device; |
|
5 | ||
6 |
m.device.data.mapview = [ |
|
7 |
m.device.display.display.get('view[0]'), |
|
8 |
m.device.display.display.get('view[1]') |
|
9 |
]; |
|
10 |
m.device.data.mapsize = [ |
|
11 |
m.device.display.display.get('size[0]'), |
|
12 |
m.device.display.display.get('size[1]') |
|
13 |
]; |
|
14 |
m.device.data.zoom = 10; |
|
15 |
m.device.data.orientation = { |
|
16 |
text: 'NORTH UP', |
|
17 |
map: 0, |
|
18 |
airplane: data.hdg, |
|
display orientation type on ...
|
19 |
fontsize: m.device.role == 'MFD' ? 16 : 12, |
massive code reorganisation ...
|
20 |
}; |
21 |
m.changeZoom(); |
|
separates maps code
|
22 | |
23 |
m.visibility = m.device.role == 'MFD'; |
|
massive code reorganisation ...
|
24 |
|
25 |
m.group = m.device.display.display.createGroup() |
|
26 |
.set('clip', |
|
27 |
'rect(' |
|
28 |
~ m.device.data.mapclip.top ~',' |
|
29 |
~ m.device.data.mapclip.right ~',' |
|
30 |
~ m.device.data.mapclip.bottom ~',' |
|
31 |
~ m.device.data.mapclip.left ~')') |
|
32 |
.setCenter( |
|
33 |
(m.device.data.mapclip.right + m.device.data.mapclip.left) / 2, |
|
34 |
(m.device.data.mapclip.bottom + m.device.data.mapclip.top) / 2); |
|
35 | ||
separates maps code
|
36 |
m.layers = {}; |
37 |
m.layers.tiles = MapTiles.new(m.device, m.group); |
|
adds route display on map
|
38 |
m.layers.route = MapRoute.new(m.device, m.group); |
separates maps code
|
39 |
m.layers.navaids = MapNavaids.new(m.device, m.group); |
add TCAS
|
40 |
m.layers.tcas = MapTcas.new(m.device, m.group); |
massive code reorganisation ...
|
41 | |
display orientation type on ...
|
42 |
m.mapOrientation = m.device.display.display.createGroup('MapOrientation') |
43 |
.setVisible(m.visibility); |
|
44 |
m.mapOrientation.createChild('path', 'MapOrientation-bg') |
|
45 |
.rect( |
|
46 |
m.device.data.mapclip.right - size(m.device.data.orientation) * (m.device.data.orientation.fontsize + 2), |
|
47 |
m.device.data.mapclip.top + 2, |
|
48 |
size(m.device.data.orientation) * (m.device.data.orientation.fontsize + 2), |
|
49 |
m.device.data.orientation.fontsize + 2) |
|
50 |
.setColor(1,1,1) |
|
51 |
.setColorFill(0,0,0); |
|
52 |
m.mapOrientation_text = m.mapOrientation.createChild('text', 'MapOrientation-text') |
|
53 |
.setFontSize(m.device.data.orientation.fontsize) |
|
54 |
.setFont('LiberationFonts/LiberationMono-Regular.ttf') |
|
55 |
.setTranslation( |
|
56 |
m.device.data.mapclip.right - size(m.device.data.orientation) * (m.device.data.orientation.fontsize + 2), |
|
57 |
m.device.data.mapclip.top + m.device.data.orientation.fontsize + 2) |
|
58 |
.setColor(1,1,1) |
|
59 |
.setColorFill(1,1,1) |
|
60 |
.setText(m.device.data.orientation.text); |
|
61 | ||
massive code reorganisation ...
|
62 |
# m.device.display.display.createGroup().createChild('path') |
63 |
# .setColor(1,0,0) |
|
64 |
# .setColorFill(1,0,0) |
|
65 |
# .setStrokeLineWidth(2) |
|
66 |
# .moveTo( |
|
67 |
# m.device.data.mapclip.left + (m.device.data.mapclip.right-m.device.data.mapclip.left)/2, |
|
68 |
# m.device.data.mapclip.top +50) |
|
69 |
# .vertTo( |
|
70 |
# m.device.data.mapclip.bottom -50) |
|
71 |
# .close() |
|
72 |
# .moveTo( |
|
73 |
# m.device.data.mapclip.left +50, |
|
74 |
# m.device.data.mapclip.top + (m.device.data.mapclip.bottom-m.device.data.mapclip.top)/2) |
|
75 |
# .horizTo( |
|
76 |
# m.device.data.mapclip.right-50) |
|
77 |
# .close(); |
|
78 | ||
79 |
return m; |
|
80 |
}, |
|
81 |
changeZoom : func (d = 0) { |
|
82 |
me.device.data.zoom = math.max(2, math.min(19, me.device.data.zoom + d)); |
|
83 |
me.device.data['range-nm'] = me.device.display.display.get('view[1]') / 2 * 84.53 * math.cos(data.lat) / math.pow(2, me.device.data.zoom); |
|
adjust scale factor for comp...
|
84 |
me.device.data['range-factor'] = math.pow(2,13 - me.device.data.zoom) * 1.45; |
massive code reorganisation ...
|
85 |
}, |
86 |
update : func { |
|
87 |
if (me.device.data.orientation.text == 'NORTH UP') { |
|
88 |
me.device.data.orientation.map = 0; |
|
89 |
me.device.data.orientation.airplane = data.hdg; |
|
90 |
} |
|
91 |
elsif (me.device.data.orientation.text == 'TRK UP') { |
|
92 |
if (data.wow) { |
|
93 |
me.device.data.orientation.map = -data.hdg; |
|
94 |
me.device.data.orientation.airplane = data.hdg; |
|
95 |
} |
|
96 |
else { |
|
97 |
var track = getprop('/orientation/track-deg'); |
|
98 |
me.device.data.orientation.map = -track; |
|
99 |
me.device.data.orientation.airplane = data.hdg; |
|
100 |
} |
|
101 |
} |
|
102 |
elsif (me.device.data.orientation.text == 'DTK UP') { |
|
fix desired track map rotati...
|
103 |
var desired = getprop('/instrumentation/gps/wp/wp[1]/desired-course-deg'); |
104 |
me.device.data.orientation.map = -desired; |
|
105 |
me.device.data.orientation.airplane = data.hdg; |
|
massive code reorganisation ...
|
106 |
} |
107 |
elsif (me.device.data.orientation.text == 'HDG UP') { |
|
108 |
me.device.data.orientation.map = -data.hdg; |
|
109 |
me.device.data.orientation.airplane = data.hdg; |
|
110 |
} |
|
111 | ||
112 |
me.group.setRotation(me.device.data.orientation.map * D2R); |
|
113 | ||
display orientation type on ...
|
114 |
me.mapOrientation_text |
115 |
.setText(me.device.data.orientation.text); |
|
116 | ||
separates maps code
|
117 |
foreach (var l; keys(me.layers)) |
118 |
me.layers[l].update(); |
|
implements the ND from Extra...
|
119 |
}, |
120 |
setVisible : func (v) { |
|
separates maps code
|
121 |
me.visibility = v; |
122 |
foreach (var l; keys(me.layers)) |
|
123 |
me.layers[l].setVisible(v); |
|
display orientation type on ...
|
124 |
me.mapOrientation.setVisible(v); |
navaids displayed with corre...
|
125 |
}, |
adds Map on MFD
|
126 |
}; |