I'm using this TUT.lcontroller. It is copied from APT.lcontroller, and searchCmd() is the only change. TUT.symbol is the same than APT.symbol.
- Code: Select all
# See: http://wiki.flightgear.org/MapStructure
# Class things:
var name = 'TUT';
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_style: {
line_width: 3,
scale_factor: 1,
debug: 1,
color_default: [0,0.6,0.85],
label_font_color:[0,0.6,0.85],
label_font_size: 28,
text_offset: [17,35],
svg_path: nil
},
});
var a_instance = nil;
var new = func(layer) {
var m = {
parents: [__self__],
layer: layer,
map: layer.map,
listeners: [],
};
m.addVisibilityListener();
return m;
};
var del = func() {
#print(name,".lcontroller.del()");
foreach (var l; me.listeners)
removelistener(l);
};
var searchCmd = func {
#print("Running query:", name);
var range = me.map.getRange();
if (range == nil) return;
return [
geo.Coord.new().set_latlon(45.83490744, 9.08522898),
geo.Coord.new().set_latlon(45.87612889, 9.14321644)
];
};
(The coordinates are hard-coded just for debugging)
Then, I run this code to load the TUT layer:
- Code: Select all
var temp = {};
temp.dlg = canvas.Window.new([600,400],"dialog");
temp.canvas = temp.dlg.createCanvas().setColorBackground(1,1,1,0.5);
temp.root = temp.canvas.createGroup();
var TestMap = temp.root.createChild("map");
TestMap.setController("Aircraft position");
TestMap.setRange(25);
TestMap.setTranslation(
temp.canvas.get("view[0]")/2,
temp.canvas.get("view[1]")/2
);
var r = func(name,vis=1,zindex=nil) return caller(0)[0];
foreach(var type; [r('TUT'),r('APT'), r('APS') ] )
TestMap.addLayer(factory: canvas.SymbolLayer, type_arg: type.name, visible: type.vis, priority: type.zindex,);
This code throws this error:
- Code: Select all
Fatal error in Nasal call: Can not convert to 'Positioned": not a derived hash:
at ...../geo.nas (line 382)
called from: .../MapStructure.nas line 1045
...
Must searchCmd() return an array of FGPositioned objects? Can I create a FGPositioned object in Nasal? Is there any way for searchCmd() to return an array of Coords? Am I extending the wrong Layer (MultiSymbolLayer)?
Thanks!