1
0
Fork 0

Fix elevation bug for jetways

Thanks to Martin Herweg (d-laser)
This commit is contained in:
Torsten Dreyer 2015-10-11 22:32:25 +02:00
parent db0d8e1622
commit dd3390b3af
2 changed files with 40 additions and 11 deletions

View file

@ -288,7 +288,7 @@ var scenery = [];
var UPDATE_PERIOD = 0;
var LOAD_PERIOD = 10;
var LOAD_DISTANCE = 50; # in nautical miles
var LOAD_JETWAY_PERIOD = 0.05;
var LOAD_JETWAY_PERIOD = 0.25;
var NUMBER_OF_JETWAYS = 1000; # approx max number of jetways loadable in FG
var runtime_files = NUMBER_OF_JETWAYS / LOAD_PERIOD * LOAD_JETWAY_PERIOD;
runtime_files = int(runtime_files) == runtime_files ? runtime_files : int(runtime_files) + 1;
@ -735,9 +735,22 @@ var load_airport_jetways = func(airport)
var airline = jetway.getNode("airline", 1).getValue() or "None";
var lat = jetway.getNode("latitude-deg", 1).getValue() or return;
var lon = jetway.getNode("longitude-deg", 1).getValue() or return;
var elev = jetway.getNode("elevation-m", 1).getValue() or 0;
var alt = geo.elevation(lat, lon) + elev;
# elevation offset from XML will be ignored!
#var elev = jetway.getNode("elevation-m", 1).getValue() or 0;
var heading = jetway.getNode("heading-deg", 1).getValue() or 0;
# probe the terrain where the jetway-wheels are
var ep = geo.Coord.new();
ep.set_latlon(lat, lon);
#geo.put_model("Aircraft/ufo/Models/sign.ac", ep);
#print_debug ("before lat:" ~ ep.lat() ~ " lon:" ~ ep.lon() );
ep.apply_course_distance(360-heading, -12.0);
#print_debug ("after lat:" ~ ep.lat() ~ " lon:" ~ ep.lon() );
#geo.put_model("Aircraft/ufo/Models/cursor.ac", ep);
var alt = geo.elevation(ep.lat(), ep.lon()) ;
print_debug ("probed elevation under wheels:" ~ alt);
var init_extend = jetway.getNode("initial-position/jetway-extension-m", 1).getValue() or 0;
var init_heading = jetway.getNode("initial-position/jetway-heading-deg", 1).getValue() or 0;
var init_pitch = jetway.getNode("initial-position/jetway-pitch-deg", 1).getValue() or 0;

View file

@ -403,13 +403,29 @@ var export = func
print("jetway definitions for airport " ~ airport ~ " exported to " ~ file);
}
};
var convert_stg = func
{
fgcommand("dialog-show", props.Node.new({ "dialog-name": "file-select" }));
setprop("/sim/gui/dialogs/file-select/path", "");
filedialog_listener = setlistener("/sim/gui/dialogs/file-select/path", func(n)
# var report = func(n) { print("file ", n.getValue(), " selected") }
var convert_stg = func()
{
var selector = gui.FileSelector.new(
convert_stg2, # callback function
"choose stg file", # dialog title
"open", # button text
["*.stg",], # pattern for displayed files
"/", # start dir
"input.stg"); # default file name
selector.open();
# selector.close();
}
var convert_stg2 = func(n)
{
removelistener(filedialog_listener);
var path = n.getValue();
if (path == "") return;
var stg = io.readfile(path);
@ -481,8 +497,8 @@ var convert_stg = func
};
settimer(loop, 0);
jetways.alert("Creating " ~ size(jetway_array) ~ " jetways for airport " ~ airport);
}, 0, 1);
};
};
var flash = func(jetway)
{
if (!contains(jetway, "_flashnum") or jetway._flashnum == -1)