Add additional runway selection so the runway in use doesn't change as you roll past mid-point. Also fix possible bug for north-south runways.
This commit is contained in:
parent
7513200f8e
commit
b6b4b5fe77
1 changed files with 92 additions and 73 deletions
|
@ -152,7 +152,6 @@
|
|||
# Simple rounding of altitude to 100 ft.
|
||||
var altitude = int(getprop("/position/altitude-ft")/100) * 100;
|
||||
|
||||
|
||||
var type = getprop("/sim/description");
|
||||
if (type != "")
|
||||
{
|
||||
|
@ -181,7 +180,7 @@
|
|||
|
||||
# Determine the active runway. We have two ways to do this:
|
||||
# - If the aircraft is on the ground (or very close to it), we'll try to determine
|
||||
# the runway it is closest to.
|
||||
# the runway it is closest to, and facing the correct direction for.
|
||||
# - If the aircraft is in the air, we'll work out the active runway based on the wind.
|
||||
|
||||
var active_runway = "";
|
||||
|
@ -202,8 +201,11 @@
|
|||
var p = geo.Coord.new();
|
||||
p.set_latlon(curr.lat, curr.lon, airport.elevation);
|
||||
|
||||
var course = loc.course_to(p);
|
||||
var deviation = math.abs(course - curr.heading);
|
||||
var course = loc.course_to(p) - curr.heading;
|
||||
while (course >= 180) course -= 360;
|
||||
while (course < -180) course += 360;
|
||||
|
||||
var deviation = math.abs(course);
|
||||
|
||||
if (deviation < max)
|
||||
{
|
||||
|
@ -211,6 +213,23 @@
|
|||
max = deviation;
|
||||
}
|
||||
}
|
||||
|
||||
# It may be the case that we're taxiing down the runway, past the mid-point.
|
||||
# If the aircraft is facing the "wrong" way for this runway, then take the
|
||||
# reciprocal runway.
|
||||
var heading = getprop("/orientation/heading-magnetic-deg");
|
||||
var deviation = heading - airport.runways[active_runway].heading;
|
||||
|
||||
while (deviation >= 180) deviation -= 360;
|
||||
while (deviation < -180) deviation += 360;
|
||||
deviation = math.abs(deviation);
|
||||
|
||||
if (deviation > 90)
|
||||
{
|
||||
var number = math.mod(num(substr(active_runway, 0, 2)) + 18, 36);
|
||||
var side = substr(active_runway, 2, 1);
|
||||
active_runway = sprintf("%02d%s", number, side == "R" ? "L" : side == "L" ? "R" : side);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue