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); |
|
topo display is now availabl...
|
38 |
if (m.device.role == 'MFD') |
39 |
m.layers.topo = MapTopo.new(m.device, m.group); |
|
adds route display on map
|
40 |
m.layers.route = MapRoute.new(m.device, m.group); |
separates maps code
|
41 |
m.layers.navaids = MapNavaids.new(m.device, m.group); |
removes traffic from PFD ins...
|
42 |
if (m.device.role == 'MFD') |
43 |
m.layers.tcas = MapTcas.new(m.device, m.group); |
|
massive code reorganisation ...
|
44 | |
display orientation type on ...
|
45 |
m.mapOrientation = m.device.display.display.createGroup('MapOrientation') |
46 |
.setVisible(m.visibility); |
|
47 |
m.mapOrientation.createChild('path', 'MapOrientation-bg') |
|
48 |
.rect( |
|
49 |
m.device.data.mapclip.right - size(m.device.data.orientation) * (m.device.data.orientation.fontsize + 2), |
|
50 |
m.device.data.mapclip.top + 2, |
|
51 |
size(m.device.data.orientation) * (m.device.data.orientation.fontsize + 2), |
|
52 |
m.device.data.orientation.fontsize + 2) |
|
53 |
.setColor(1,1,1) |
|
54 |
.setColorFill(0,0,0); |
|
55 |
m.mapOrientation_text = m.mapOrientation.createChild('text', 'MapOrientation-text') |
|
56 |
.setFontSize(m.device.data.orientation.fontsize) |
|
57 |
.setFont('LiberationFonts/LiberationMono-Regular.ttf') |
|
58 |
.setTranslation( |
|
59 |
m.device.data.mapclip.right - size(m.device.data.orientation) * (m.device.data.orientation.fontsize + 2), |
|
60 |
m.device.data.mapclip.top + m.device.data.orientation.fontsize + 2) |
|
61 |
.setColor(1,1,1) |
|
62 |
.setColorFill(1,1,1) |
|
63 |
.setText(m.device.data.orientation.text); |
|
64 | ||
massive code reorganisation ...
|
65 |
# m.device.display.display.createGroup().createChild('path') |
66 |
# .setColor(1,0,0) |
|
67 |
# .setColorFill(1,0,0) |
|
68 |
# .setStrokeLineWidth(2) |
|
69 |
# .moveTo( |
|
70 |
# m.device.data.mapclip.left + (m.device.data.mapclip.right-m.device.data.mapclip.left)/2, |
|
71 |
# m.device.data.mapclip.top +50) |
|
72 |
# .vertTo( |
|
73 |
# m.device.data.mapclip.bottom -50) |
|
74 |
# .close() |
|
75 |
# .moveTo( |
|
76 |
# m.device.data.mapclip.left +50, |
|
77 |
# m.device.data.mapclip.top + (m.device.data.mapclip.bottom-m.device.data.mapclip.top)/2) |
|
78 |
# .horizTo( |
|
79 |
# m.device.data.mapclip.right-50) |
|
80 |
# .close(); |
|
81 | ||
82 |
return m; |
|
83 |
}, |
|
poweroff improved
|
84 |
off: func { |
85 |
me.mapOrientation.setVisible(0); |
|
86 |
foreach (var layer; keys(me.layers)) { |
|
87 |
me.layers[layer].off(); |
|
88 |
delete(me.layers, layer); |
|
89 |
} |
|
90 |
}, |
|
massive code reorganisation ...
|
91 |
changeZoom : func (d = 0) { |
92 |
me.device.data.zoom = math.max(2, math.min(19, me.device.data.zoom + d)); |
|
93 |
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...
|
94 |
me.device.data['range-factor'] = math.pow(2,13 - me.device.data.zoom) * 1.45; |
massive code reorganisation ...
|
95 |
}, |
96 |
update : func { |
|
97 |
if (me.device.data.orientation.text == 'NORTH UP') { |
|
98 |
me.device.data.orientation.map = 0; |
|
99 |
me.device.data.orientation.airplane = data.hdg; |
|
100 |
} |
|
101 |
elsif (me.device.data.orientation.text == 'TRK UP') { |
|
102 |
if (data.wow) { |
|
103 |
me.device.data.orientation.map = -data.hdg; |
|
104 |
me.device.data.orientation.airplane = data.hdg; |
|
105 |
} |
|
106 |
else { |
|
107 |
var track = getprop('/orientation/track-deg'); |
|
108 |
me.device.data.orientation.map = -track; |
|
109 |
me.device.data.orientation.airplane = data.hdg; |
|
110 |
} |
|
111 |
} |
|
112 |
elsif (me.device.data.orientation.text == 'DTK UP') { |
|
fix desired track map rotati...
|
113 |
var desired = getprop('/instrumentation/gps/wp/wp[1]/desired-course-deg'); |
114 |
me.device.data.orientation.map = -desired; |
|
115 |
me.device.data.orientation.airplane = data.hdg; |
|
massive code reorganisation ...
|
116 |
} |
117 |
elsif (me.device.data.orientation.text == 'HDG UP') { |
|
118 |
me.device.data.orientation.map = -data.hdg; |
|
119 |
me.device.data.orientation.airplane = data.hdg; |
|
120 |
} |
|
121 | ||
122 |
me.group.setRotation(me.device.data.orientation.map * D2R); |
|
123 | ||
display orientation type on ...
|
124 |
me.mapOrientation_text |
125 |
.setText(me.device.data.orientation.text); |
|
126 | ||
separates maps code
|
127 |
foreach (var l; keys(me.layers)) |
128 |
me.layers[l].update(); |
|
implements the ND from Extra...
|
129 |
}, |
130 |
setVisible : func (v) { |
|
separates maps code
|
131 |
me.visibility = v; |
132 |
foreach (var l; keys(me.layers)) |
|
133 |
me.layers[l].setVisible(v); |
|
display orientation type on ...
|
134 |
me.mapOrientation.setVisible(v); |
navaids displayed with corre...
|
135 |
}, |
adds Map on MFD
|
136 |
}; |