fix a potential crash
This commit is contained in:
		| @@ -25,6 +25,14 @@ class Node: | |||||||
|                         return star |                         return star | ||||||
|         return None |         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): |     def arrivalEstimation(self, runway : Runway, star : ArrivalRoute, weather : WeatherModel): | ||||||
|         # calculate remaining trackmiles |         # calculate remaining trackmiles | ||||||
|         trackmiles = self.PredictedDistanceToIAF |         trackmiles = self.PredictedDistanceToIAF | ||||||
| @@ -113,6 +121,7 @@ class Node: | |||||||
|  |  | ||||||
|             flightTimeSeconds += 10 |             flightTimeSeconds += 10 | ||||||
|             if flownDistance >= trackmiles: |             if flownDistance >= trackmiles: | ||||||
|  |                 self.updateArrivalWaypoint(arrivalRoute, flightTimeSeconds, currentPosition[0], currentIAS, currentPosition[1]) | ||||||
|                 break |                 break | ||||||
|  |  | ||||||
|             # check if we follow a new waypoint pair |             # check if we follow a new waypoint pair | ||||||
| @@ -120,12 +129,7 @@ class Node: | |||||||
|                 lastWaypointIndex = nextWaypointIndex |                 lastWaypointIndex = nextWaypointIndex | ||||||
|                 nextWaypointIndex += 1 |                 nextWaypointIndex += 1 | ||||||
|  |  | ||||||
|                 arrivalRoute[-1].FlightTime = timedelta(seconds = flightTimeSeconds) |                 self.updateArrivalWaypoint(arrivalRoute, flightTimeSeconds, currentPosition[0], currentIAS, currentPosition[1]) | ||||||
|                 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] |  | ||||||
|  |  | ||||||
|                 # check if a skip from base to final turn waypoints is needed |                 # check if a skip from base to final turn waypoints is needed | ||||||
|                 if -1 != turnIndices[0] and nextWaypointIndex > turnIndices[0] and nextWaypointIndex < turnIndices[1]: |                 if -1 != turnIndices[0] and nextWaypointIndex > turnIndices[0] and nextWaypointIndex < turnIndices[1]: | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user