1
0
Fork 0
fgdata/Nasal/canvas/map/WPT.lcontroller
Philosopher f0d44ae8fe Lots lots more MapStructure changes
Fix the main bugs, add features and convert most of the layers.
Move/refactor some things as well. Add a canvas map dialog next to the
built-in one -- it's not 100% functional but it's quite close actually.

As before, the excitement has been taking place at our team clone.
https://gitorious.org/fg/canvas-hackers-fgdata/commits/0b4cc84
(topics/canvas-map-dialog branch this time, current HEAD in above URL.)
2014-05-25 14:27:11 -05:00

65 lines
1.5 KiB
Text

# See: http://wiki.flightgear.org/MapStructure
# Class things:
var name = 'WPT'; # for waypoints
var parents = [SymbolLayer.Controller];
var __self__ = caller(0)[0];
SymbolLayer.Controller.add(name, __self__);
SymbolLayer.add(name, {
parents: [MultiSymbolLayer],
type: name, # Symbol type
df_controller: __self__, # controller to use by default -- this one
df_options: { # default configuration options
active_node: "/autopilot/route-manager/active",
current_wp_node: "/autopilot/route-manager/current-wp",
}
});
var new = func(layer) {
var m = {
parents: [__self__],
layer: layer,
map: layer.map,
listeners: [],
};
layer.searcher._equals = func(l,r) l.equals(r);
append(m.listeners, setlistener(layer.options.active_node, func m.layer.update() ));
m.addVisibilityListener();
return m;
};
var del = func() {
#print(name~"VOR.lcontroller.del()");
foreach (var l; me.listeners)
removelistener(l);
};
var WPT_model = {
new: func(fp, idx) {
var m = { parents:[WPT_model], idx:idx };
var wp = fp.getWP(idx);
m.name = wp.wp_name;
var alt = wp.alt_cstr;
if (alt != 0)
m.name ~= "\n"~alt;
var n = wp.path()[0];
(m.lat,m.lon) = (n.lat,n.lon);
return m;
},
equals: func(other) {
# this is set on symbol init, so use this for equality...
me.name == other.name
},
};
var searchCmd = func {
printlog(_MP_dbg_lvl, "Running query: "~name);
var fp = flightplan();
var fpSize = fp.getPlanSize();
var result = [];
for (var i = 1; i < fpSize; i+=1)
append(result, WPT_model.new(fp, i));
return result;
};