1
0
Fork 0
fgdata/Nasal/canvas/map/aircraftpos.controller
Gijs de Rooy a9576e8c8d Canvas Navigational Display:
- get rid of global variables and use instance variables
- identified all important drawing routines and move them into *.draw files
- changed to dynamic loading of *.draw *.model and *.layer files
- implemented poor-man's controller hash to move use-case specific conditionals out of the draw files, and back into the instantiation, i.e. Gijs' EFIS class
- started identifying stuff that is not specific to drawing, but to what is to be drawn, i.e. Model stuff - such as positioned queries, moved those out into *.model files
- some more work on supporting more than a single ND MFD instance per aircraft
- renamed a handful of SVG identifiers to avoid naming conflicts and to simplify usage of SVG IDs as member fields
- moved all of the setlistener setup out of the fdm-initialized stub right into the ctor of the Efis class (actually that's controller stuff...)
- initial MapStructure framework
- aircraft-agnostic NavDisplay class
- preparations for deprecating map.nas
- additions to canvas.map
- preparations for making NDStyles configurable via XML
2013-12-01 13:36:23 +01:00

41 lines
993 B
Text

# Class things:
var parents = [Map.Controller];
var __self__ = caller(0)[0];
Map.Controller.add("Aircraft position", __self__);
Map.df_controller = __self__;
var new = func(map) {
var m = {
parents: [__self__],
map: map,
_pos: nil, _time: nil,
};
m.timer = maketimer(0, m, update_pos);
m.timer.start();
return m;
};
var del = func(map) {
if (map != me.map) die();
me.timer.stop();
};
# Controller methods
var update_pos = func {
var (lat,lon) = (var pos = geo.aircraft_position()).latlon();
var time = systime();
me.map.setPos(lat, lon, getprop("/orientation/heading-deg"));
if (me._pos == nil)
me._pos = geo.Coord.new(pos);
else {
var dist = me._pos.direct_distance_to(pos);
# 2 NM until we update again
if (dist < 2 * NM2M) return;
# Update at most every 4 seconds to avoid escessive stutter:
elsif (time - me._time < 4) return;
}
#print("update aircraft position");
var (x,y,z) = pos.xyz();
me._pos.set_xyz(x,y,z);
me._time = time;
me.map.update();
};