From dd3390b3afee955ba23dfd9334baf438bc7ae989 Mon Sep 17 00:00:00 2001 From: Torsten Dreyer Date: Sun, 11 Oct 2015 22:32:25 +0200 Subject: [PATCH] Fix elevation bug for jetways Thanks to Martin Herweg (d-laser) --- Nasal/jetways/jetways.nas | 19 ++++++++++++++--- Nasal/jetways_edit/jetways_edit.nas | 32 +++++++++++++++++++++-------- 2 files changed, 40 insertions(+), 11 deletions(-) diff --git a/Nasal/jetways/jetways.nas b/Nasal/jetways/jetways.nas index bb6c0932d..0a195861c 100644 --- a/Nasal/jetways/jetways.nas +++ b/Nasal/jetways/jetways.nas @@ -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; diff --git a/Nasal/jetways_edit/jetways_edit.nas b/Nasal/jetways_edit/jetways_edit.nas index c8eebc369..f8b867afe 100644 --- a/Nasal/jetways_edit/jetways_edit.nas +++ b/Nasal/jetways_edit/jetways_edit.nas @@ -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)