Protect against division by zero in level off calculation
This commit is contained in:
parent
9db758d9d0
commit
fa6ee1d57d
1 changed files with 9 additions and 6 deletions
|
@ -776,16 +776,19 @@ var flightPlanController = {
|
|||
|
||||
|
||||
calculateLvlOffPoint: func(deltaAltitude) {
|
||||
me.distLvl = (deltaAltitude * pts.Velocities.groundspeedKt.getValue()) / (fmgc.Internal.vs.getValue() * 60);
|
||||
me._verticalSpeedVal = fmgc.Internal.vs.getValue();
|
||||
if (me._verticalSpeedVal != 0) {
|
||||
me.distLvl = (deltaAltitude * pts.Velocities.groundspeedKt.getValue()) / (fmgc.Internal.vs.getValue() * 60);
|
||||
} else {
|
||||
me.distLvl = 999;
|
||||
}
|
||||
|
||||
if (me.active.getBoolValue() and fmgc.Output.lat.getValue() == 1 and me.distLvl >= 0) { # NAV
|
||||
me.lvlOffPoint = me.flightplans[2].pathGeod(me.currentToWptIndex.getValue() - 1, me.flightplans[2].getWP(me.currentToWptIndex.getValue()).leg_distance - me.distToWpt.getValue() + me.distLvl);
|
||||
} elsif (fmgc.Output.lat.getValue() == 0 and me.distLvl >= 0) { # HDG TRK
|
||||
var coord = geo.aircraft_position();
|
||||
coord.apply_course_distance(getprop("/orientation/track-magnetic-deg"), me.distLvl * NM2M);
|
||||
var latGeo = coord.lat();
|
||||
var lonGeo = coord.lon();
|
||||
me.lvlOffPoint = {lat: latGeo, lon: lonGeo};
|
||||
me._lvlOffCoord = geo.aircraft_position();
|
||||
me._lvlOffCoord.apply_course_distance(getprop("/orientation/track-magnetic-deg"), me.distLvl * NM2M);
|
||||
me.lvlOffPoint = {lat: me._lvlOffCoord.lat(), lon: me._lvlOffCoord.lon()};
|
||||
} else {
|
||||
setprop("/autopilot/route-manager/vnav/ec/show", 0);
|
||||
setprop("/autopilot/route-manager/vnav/ed/show", 0);
|
||||
|
|
Loading…
Reference in a new issue