2014-05-25 18:11:13 +00:00
|
|
|
# See: http://wiki.flightgear.org/MapStructure
|
|
|
|
# TODO: this layer doesn't make sense to support for AI/MP traffic, because we don't currently have access to flightplan/routing info
|
|
|
|
# that also applies to other layers like WPT or even navaid layers that handle station tuning based on local radio settings
|
|
|
|
#
|
|
|
|
# Class things:
|
|
|
|
var name = 'RTE';
|
|
|
|
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) 0; # TODO: create model objects instead?
|
|
|
|
append(m.listeners, setlistener(layer.options.active_node, func m.layer.update() ));
|
|
|
|
m.addVisibilityListener();
|
|
|
|
|
|
|
|
return m;
|
|
|
|
};
|
|
|
|
var del = func() {
|
|
|
|
foreach (var l; me.listeners)
|
|
|
|
removelistener(l);
|
|
|
|
};
|
|
|
|
|
|
|
|
var searchCmd = func {
|
|
|
|
# FIXME: do we return the current route even if it isn't active?
|
|
|
|
printlog(_MP_dbg_lvl, "Running query: ", name);
|
|
|
|
var plans = []; # TODO: multiple flightplans?
|
|
|
|
|
|
|
|
# http://wiki.flightgear.org/Nasal_Flightplan
|
|
|
|
var fp = flightplan();
|
|
|
|
var fpSize = fp.getPlanSize();
|
2014-06-07 02:12:39 +00:00
|
|
|
if (!getprop(me.layer.options.active_node)) fpSize = 0;
|
2014-05-25 18:11:13 +00:00
|
|
|
var coords = [];
|
|
|
|
for (var i=0; i<fpSize; i += 1) {
|
|
|
|
var leg = fp.getWP(i);
|
2014-06-07 02:12:39 +00:00
|
|
|
coords ~= leg.path();
|
2014-05-25 18:11:13 +00:00
|
|
|
}
|
|
|
|
append(plans, coords);
|
|
|
|
return plans;
|
|
|
|
};
|
|
|
|
|