fix bugs in TTL and TTG calculations
This commit is contained in:
		| @@ -176,12 +176,23 @@ class Node: | ||||
|             if None != star: | ||||
|                 flightTime, trackmiles, arrivalRoute = self.arrivalEstimation(identifier.Runway, star, weatherModel) | ||||
|  | ||||
|                 avgSpeed = trackmiles / (float(flightTime.seconds) / 3600.0) | ||||
|                 # the closer we get to the IAF the less time delta can be achieved by short cuts, delay vectors or speeds | ||||
|                 ratio = min(2.0, max(0.0, self.PredictedDistanceToIAF / (trackmiles - self.PredictedDistanceToIAF))) | ||||
|                 possibleTimeDelta = (trackmiles / (avgSpeed * 0.9)) * 60 | ||||
|                 ttg = timedelta(minutes = (possibleTimeDelta - flightTime.total_seconds() / 60) * ratio) | ||||
|                 ttl = timedelta(minutes = (possibleTimeDelta - flightTime.total_seconds() / 60)) | ||||
|                 # calculate average speed gain | ||||
|                 avgSpeed = trackmiles / (flightTime.total_seconds() / 3600.0) | ||||
|                 avgSpeedIncrease = avgSpeed * 1.10 | ||||
|                 avgSpeedDecrease = avgSpeed * 0.80 | ||||
|                 decreasedSpeedFlighttime = (trackmiles / avgSpeedDecrease) * 3600.0 # given in seconds | ||||
|  | ||||
|                 # calculate shortcut gain and add 15 miles for final and base turn | ||||
|                 currentPosition = Waypoint(latitude = self.PredictedCoordinate[0], longitude = self.PredictedCoordinate[1]) | ||||
|                 shortcutDistance = currentPosition.haversine(identifier.Runway.Start) + 15.0 | ||||
|                 shortcutFlighttime = (shortcutDistance / avgSpeedIncrease) * 3600.0 | ||||
|                 if shortcutFlighttime > flightTime.total_seconds(): | ||||
|                     shortcutFlighttime = flightTime.total_seconds() | ||||
|  | ||||
|                 # the best TTG is the shortest path with the fastest speed | ||||
|                 ttg = timedelta(seconds = flightTime.total_seconds() - shortcutFlighttime) | ||||
|                 # the best TTL is the longest path with the slowest speed | ||||
|                 ttl = timedelta(seconds = decreasedSpeedFlighttime - flightTime.total_seconds()) | ||||
|                 ita = self.Inbound.ReportTime + flightTime | ||||
|                 earliest = ita - ttg | ||||
|                 latest = ita + ttl | ||||
|   | ||||
		Reference in New Issue
	
	Block a user