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, |
|
19 |
}; |
|
20 |
m.changeZoom(); |
|
separates maps code
|
21 | |
22 |
m.visibility = m.device.role == 'MFD'; |
|
massive code reorganisation ...
|
23 |
|
24 |
m.group = m.device.display.display.createGroup() |
|
25 |
.set('clip', |
|
26 |
'rect(' |
|
27 |
~ m.device.data.mapclip.top ~',' |
|
28 |
~ m.device.data.mapclip.right ~',' |
|
29 |
~ m.device.data.mapclip.bottom ~',' |
|
30 |
~ m.device.data.mapclip.left ~')') |
|
31 |
.setCenter( |
|
32 |
(m.device.data.mapclip.right + m.device.data.mapclip.left) / 2, |
|
33 |
(m.device.data.mapclip.bottom + m.device.data.mapclip.top) / 2); |
|
34 | ||
separates maps code
|
35 |
m.layers = {}; |
36 |
m.layers.tiles = MapTiles.new(m.device, m.group); |
|
37 |
m.layers.navaids = MapNavaids.new(m.device, m.group); |
|
massive code reorganisation ...
|
38 | |
39 |
# m.device.display.display.createGroup().createChild('path') |
|
40 |
# .setColor(1,0,0) |
|
41 |
# .setColorFill(1,0,0) |
|
42 |
# .setStrokeLineWidth(2) |
|
43 |
# .moveTo( |
|
44 |
# m.device.data.mapclip.left + (m.device.data.mapclip.right-m.device.data.mapclip.left)/2, |
|
45 |
# m.device.data.mapclip.top +50) |
|
46 |
# .vertTo( |
|
47 |
# m.device.data.mapclip.bottom -50) |
|
48 |
# .close() |
|
49 |
# .moveTo( |
|
50 |
# m.device.data.mapclip.left +50, |
|
51 |
# m.device.data.mapclip.top + (m.device.data.mapclip.bottom-m.device.data.mapclip.top)/2) |
|
52 |
# .horizTo( |
|
53 |
# m.device.data.mapclip.right-50) |
|
54 |
# .close(); |
|
55 | ||
56 |
return m; |
|
57 |
}, |
|
58 |
changeZoom : func (d = 0) { |
|
59 |
me.device.data.zoom = math.max(2, math.min(19, me.device.data.zoom + d)); |
|
60 |
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); |
|
61 |
me.device.data['range-factor'] = math.pow(2,13 - me.device.data.zoom) * 1.6875; |
|
62 |
}, |
|
63 |
update : func { |
|
64 |
if (me.device.data.orientation.text == 'NORTH UP') { |
|
65 |
me.device.data.orientation.map = 0; |
|
66 |
me.device.data.orientation.airplane = data.hdg; |
|
67 |
} |
|
68 |
elsif (me.device.data.orientation.text == 'TRK UP') { |
|
69 |
if (data.wow) { |
|
70 |
me.device.data.orientation.map = -data.hdg; |
|
71 |
me.device.data.orientation.airplane = data.hdg; |
|
72 |
} |
|
73 |
else { |
|
74 |
var track = getprop('/orientation/track-deg'); |
|
75 |
me.device.data.orientation.map = -track; |
|
76 |
me.device.data.orientation.airplane = data.hdg; |
|
77 |
} |
|
78 |
} |
|
79 |
elsif (me.device.data.orientation.text == 'DTK UP') { |
|
80 |
me.device.data.orientation.map = 0; |
|
81 |
me.device.data.orientation.airplane = 0; |
|
82 |
} |
|
83 |
elsif (me.device.data.orientation.text == 'HDG UP') { |
|
84 |
me.device.data.orientation.map = -data.hdg; |
|
85 |
me.device.data.orientation.airplane = data.hdg; |
|
86 |
} |
|
87 | ||
88 |
me.group.setRotation(me.device.data.orientation.map * D2R); |
|
89 | ||
separates maps code
|
90 |
foreach (var l; keys(me.layers)) |
91 |
me.layers[l].update(); |
|
implements the ND from Extra...
|
92 |
}, |
93 |
setVisible : func (v) { |
|
separates maps code
|
94 |
me.visibility = v; |
95 |
foreach (var l; keys(me.layers)) |
|
96 |
me.layers[l].setVisible(v); |
|
navaids displayed with corre...
|
97 |
}, |
adds Map on MFD
|
98 |
}; |