fix a potential crash

This commit is contained in:
Sven Czarnian
2021-11-29 17:56:08 +01:00
parent 836ff0a8b2
commit 7636c549db

View File

@@ -25,6 +25,14 @@ class Node:
return star
return None
def updateArrivalWaypoint(self, arrivalRoute, flightTime, altitude, indicatedAirspeed, groundSpeed):
arrivalRoute[-1].FlightTime = timedelta(seconds = flightTime)
arrivalRoute[-1].ETA = self.PredictionTime + arrivalRoute[-1].FlightTime
arrivalRoute[-1].PTA = arrivalRoute[-1].ETA
arrivalRoute[-1].Altitude = altitude
arrivalRoute[-1].IndicatedAirspeed = indicatedAirspeed
arrivalRoute[-1].GroundSpeed = groundSpeed
def arrivalEstimation(self, runway : Runway, star : ArrivalRoute, weather : WeatherModel):
# calculate remaining trackmiles
trackmiles = self.PredictedDistanceToIAF
@@ -113,6 +121,7 @@ class Node:
flightTimeSeconds += 10
if flownDistance >= trackmiles:
self.updateArrivalWaypoint(arrivalRoute, flightTimeSeconds, currentPosition[0], currentIAS, currentPosition[1])
break
# check if we follow a new waypoint pair
@@ -120,12 +129,7 @@ class Node:
lastWaypointIndex = nextWaypointIndex
nextWaypointIndex += 1
arrivalRoute[-1].FlightTime = timedelta(seconds = flightTimeSeconds)
arrivalRoute[-1].ETA = self.PredictionTime + arrivalRoute[-1].FlightTime
arrivalRoute[-1].PTA = arrivalRoute[-1].ETA
arrivalRoute[-1].Altitude = currentPosition[0]
arrivalRoute[-1].IndicatedAirspeed = currentIAS
arrivalRoute[-1].GroundSpeed = currentPosition[1]
self.updateArrivalWaypoint(arrivalRoute, flightTimeSeconds, currentPosition[0], currentIAS, currentPosition[1])
# check if a skip from base to final turn waypoints is needed
if -1 != turnIndices[0] and nextWaypointIndex > turnIndices[0] and nextWaypointIndex < turnIndices[1]: