]> git.mxchange.org Git - flightgear.git/blobdiff - src/AIModel/AIFlightPlanCreateCruise.cxx
Removed hardcoded performance data.
[flightgear.git] / src / AIModel / AIFlightPlanCreateCruise.cxx
index d38896b7c498f315c85bdfacc3e194f87b7ad1ea..8d9cc8db5e65c9c5e3ef8c52fe21ec3473ca1b76 100755 (executable)
@@ -25,9 +25,6 @@
 
 #include <fstream>
 #include <iostream>
-#include "AIFlightPlan.hxx"
-#include <simgear/math/polar3d.hxx>
-#include <simgear/math/sg_geodesy.hxx>
 #include <simgear/route/waypoint.hxx>
 
 #include <Navaids/awynet.hxx>
 #include <Environment/environment_mgr.hxx>
 #include <Environment/environment.hxx>
 
+#include "AIFlightPlan.hxx"
+#include "AIAircraft.hxx"
+#include "performancedata.hxx"
+
+
 using std::iostream;
 
 void FGAIFlightPlan::evaluateRoutePart(double deplat,
@@ -276,7 +278,7 @@ void FGAIFlightPlan::createCruise(bool firstFlight, FGAirport *dep,
     //  {
     //    cerr << "Creating cruise to EHAM " << latitude << " " << longitude << endl;
     //  }
-    heading = rwy->headingDeg();
+    heading = rwy._heading;
     azimuth = heading + 180.0;
     while ( azimuth >= 360.0 ) { azimuth -= 360.0; }
 
@@ -310,57 +312,23 @@ void FGAIFlightPlan::createCruise(bool firstFlight, FGAirport *dep,
  * Note that this is the original version that does not 
  * do any dynamic route computation.
  ******************************************************************/
-void FGAIFlightPlan::createCruise(bool firstFlight, FGAirport *dep, 
+void FGAIFlightPlan::createCruise(FGAIAircraft *ac, bool firstFlight, FGAirport *dep, 
                                  FGAirport *arr, double latitude, 
                                  double longitude, double speed, 
                                  double alt, const string& fltType)
 {
-  double wind_speed;
-  double wind_heading;
-  double heading;
-  double lat, lon, az;
-  double lat2, lon2, az2;
-  double azimuth;
+  double vCruise = ac->getPerformance()->vCruise();
   waypoint *wpt;
-
-  wpt = new waypoint;
-  wpt->name      = "Cruise"; //wpt_node->getStringValue("name", "END");
-  wpt->latitude  = latitude;
-  wpt->longitude = longitude;
-  wpt->altitude  = alt;
-  wpt->speed     = speed; 
-  wpt->crossat   = -10000;
-  wpt->gear_down = false;
-  wpt->flaps_down= false;
-  wpt->finished  = false;
-  wpt->on_ground = false;
-  wpt->routeIndex = 0;
+  wpt = createInAir(ac, "Cruise", SGGeod::fromDeg(longitude, latitude), alt, vCruise);
   waypoints.push_back(wpt); 
   
   string rwyClass = getRunwayClassFromTrafficType(fltType);
-  arr->getDynamics()->getActiveRunway(rwyClass, 2, activeRunway);
+  double heading = ac->getTrafficRef()->getCourse();
+  arr->getDynamics()->getActiveRunway(rwyClass, 2, activeRunway, heading);
   rwy = arr->getRunwayByIdent(activeRunway);
+  // begin descent 110km out
+  SGGeod beginDescentPoint = rwy->pointOnCenterline(-110000);
   
-  heading = rwy->headingDeg();
-  azimuth = heading + 180.0;
-  while ( azimuth >= 360.0 ) { azimuth -= 360.0; }
-  
-  
-  geo_direct_wgs_84 ( 0, rwy->latitude(), rwy->longitude(), azimuth, 
-                     110000,
-                     &lat2, &lon2, &az2 );
-  wpt = new waypoint;
-  wpt->name      = "BOD";
-  wpt->latitude  = lat2;
-  wpt->longitude = lon2;
-  wpt->altitude  = alt;
-  wpt->speed     = speed; 
-  wpt->crossat   = alt;
-  wpt->gear_down = false;
-  wpt->flaps_down= false;
-  wpt->finished  = false;
-  wpt->on_ground = false;
-  wpt->routeIndex = 0;
+  wpt = createInAir(ac, "BOD", beginDescentPoint, alt, vCruise);
   waypoints.push_back(wpt); 
 }