zkv1000 / Nasal / map.nas /
Newer Older
138 lines | 5.626kb
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
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 ...
Sébastien MARQUE authored on 2017-05-21
19
            fontsize: m.device.role == 'MFD' ? 16 : 12,
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
20
        };
21
        m.changeZoom();
separates maps code
Sébastien MARQUE authored on 2017-05-11
22

            
23
        m.visibility = m.device.role == 'MFD';
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
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
Sébastien MARQUE authored on 2017-05-11
36
        m.layers = {};
37
        m.layers.tiles = MapTiles.new(m.device, m.group);
topo display is now availabl...
Sébastien MARQUE authored on 2020-06-14
38
        if (m.device.role == 'MFD')
39
            m.layers.topo = MapTopo.new(m.device, m.group);
adds route display on map
Sébastien MARQUE authored on 2017-05-11
40
        m.layers.route = MapRoute.new(m.device, m.group);
separates maps code
Sébastien MARQUE authored on 2017-05-11
41
        m.layers.navaids = MapNavaids.new(m.device, m.group);
removes traffic from PFD ins...
Sébastien MARQUE authored on 2020-06-14
42
        if (m.device.role == 'MFD')
43
            m.layers.tcas = MapTcas.new(m.device, m.group);
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
44

            
display orientation type on ...
Sébastien MARQUE authored on 2017-05-21
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

            
close issue with misplacing ...
Sébastien MARQUE authored on 2020-06-22
65
        data.lat = getprop('/position/latitude-deg');
66
        m.changeZoom();
67

            
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
68
#        m.device.display.display.createGroup().createChild('path')
69
#            .setColor(1,0,0)
70
#            .setColorFill(1,0,0)
71
#            .setStrokeLineWidth(2)
72
#            .moveTo(
73
#                m.device.data.mapclip.left + (m.device.data.mapclip.right-m.device.data.mapclip.left)/2,
74
#                m.device.data.mapclip.top +50)
75
#            .vertTo(
76
#                m.device.data.mapclip.bottom -50)
77
#            .close()
78
#            .moveTo(
79
#                m.device.data.mapclip.left +50,
80
#                m.device.data.mapclip.top + (m.device.data.mapclip.bottom-m.device.data.mapclip.top)/2)
81
#            .horizTo(
82
#                m.device.data.mapclip.right-50)
83
#            .close();
84

            
85
        return m;
86
    },
poweroff improved
Sébastien MARQUE authored on 2020-05-16
87
    off: func {
88
        me.mapOrientation.setVisible(0);
89
        foreach (var layer; keys(me.layers)) {
90
            me.layers[layer].off();
91
            delete(me.layers, layer);
92
        }
93
    },
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
94
    changeZoom : func (d = 0) {
95
        me.device.data.zoom = math.max(2, math.min(19, me.device.data.zoom + d));
close issue with misplacing ...
Sébastien MARQUE authored on 2020-06-22
96
        me.device.data['range-nm'] = me.device.display.display.get('view[1]') / 2 * 84.53 * math.cos(data.lat * D2R) / math.pow(2, me.device.data.zoom);
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
97
    },
98
    update : func {
99
        if (me.device.data.orientation.text == 'NORTH UP') {
100
            me.device.data.orientation.map = 0;
101
            me.device.data.orientation.airplane = data.hdg;
102
        }
103
        elsif (me.device.data.orientation.text == 'TRK UP') {
104
            if (data.wow) {
105
                me.device.data.orientation.map = -data.hdg;
106
                me.device.data.orientation.airplane = data.hdg;
107
            }
108
            else {
109
                var track = getprop('/orientation/track-deg');
110
                me.device.data.orientation.map = -track;
111
                me.device.data.orientation.airplane = data.hdg;
112
            }
113
        }
114
        elsif (me.device.data.orientation.text == 'DTK UP') {
fix desired track map rotati...
Sébastien MARQUE authored on 2017-05-11
115
            var desired = getprop('/instrumentation/gps/wp/wp[1]/desired-course-deg');
116
            me.device.data.orientation.map = -desired;
117
            me.device.data.orientation.airplane = data.hdg;
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
118
        }
119
        elsif (me.device.data.orientation.text == 'HDG UP') {
120
            me.device.data.orientation.map = -data.hdg;
121
            me.device.data.orientation.airplane = data.hdg;
122
        }
123

            
124
        me.group.setRotation(me.device.data.orientation.map * D2R);
125

            
display orientation type on ...
Sébastien MARQUE authored on 2017-05-21
126
        me.mapOrientation_text
127
            .setText(me.device.data.orientation.text);
128

            
separates maps code
Sébastien MARQUE authored on 2017-05-11
129
        foreach (var l; keys(me.layers))
130
            me.layers[l].update();
implements the ND from Extra...
Sébastien MARQUE authored on 2017-04-17
131
    },
132
    setVisible : func (v) {
separates maps code
Sébastien MARQUE authored on 2017-05-11
133
        me.visibility = v;
134
        foreach (var l; keys(me.layers))
135
            me.layers[l].setVisible(v);
display orientation type on ...
Sébastien MARQUE authored on 2017-05-21
136
        me.mapOrientation.setVisible(v);
navaids displayed with corre...
Sébastien MARQUE authored on 2017-04-18
137
    },
adds Map on MFD
Sébastien MARQUE authored on 2017-03-20
138
};