Browse Source

add a predicted waypoint for later calculations

Sven Czarnian 3 years ago
parent
commit
f359ec8189
1 changed files with 4 additions and 6 deletions
  1. 4 6
      aman/sys/aco/Node.py

+ 4 - 6
aman/sys/aco/Node.py

@@ -144,6 +144,7 @@ class Node:
     def __init__(self, inbound : Inbound, referenceTime : datetime, weatherModel : WeatherModel,
                  navData : SctEseFormat, sequencingConfig : AirportSequencing):
         self.PredictedDistanceToIAF = inbound.Report.distanceToIAF
+        self.PredictedCoordinate = [ inbound.CurrentPosition.latitude, inbound.CurrentPosition.longitude ]
         self.ArrivalCandidates = {}
         self.Inbound = inbound
 
@@ -157,17 +158,14 @@ class Node:
             course = weatherModel.estimateCourse(inbound.Report.dynamics.altitude, inbound.Report.dynamics.groundSpeed, inbound.Report.dynamics.heading)
             tempWaypoint = Waypoint(longitude = inbound.CurrentPosition.longitude, latitude = inbound.CurrentPosition.latitude)
             gs = inbound.Report.dynamics.groundSpeed * 0.514444 # ground speed in m/s
-            distance = gs * timePrediction * 0.000539957 # distance back to nm
+            distance = gs * timePrediction
+            self.PredictedCoordinate = tempWaypoint.project(course, distance)
 
             # calculate the bearing between the current position and the IAF
             star = Node.findArrivalRoute(inbound.Report.initialApproachFix, sequencingConfig.ActiveArrivalRunways[0].Runway, navData)
-            if None != star:
-                bearing = tempWaypoint.bearing(star.Route[0])
-            else:
-                bearing = inbound.Report.dynamics.heading
 
             # calculate the distance based on the flown distance and update the predicted distance
-            self.PredictedDistanceToIAF -= math.cos(math.radians(bearing - course)) * distance
+            self.PredictedDistanceToIAF = Waypoint(longitude = self.PredictedCoordinate[1], latitude = self.PredictedCoordinate[0]).haversine(star.Route[0])
             if 0.0 > self.PredictedDistanceToIAF:
                 self.PredictedDistanceToIAF = 0.0