]> git.mxchange.org Git - flightgear.git/blobdiff - src/Navaids/routePath.cxx
Prepare and implement reinit methods for instruments
[flightgear.git] / src / Navaids / routePath.cxx
index d512f155f67d0708258f7211cfde74eed89b8549..160407528c6fadc75a1ace30098abf996b7df821 100644 (file)
@@ -12,6 +12,7 @@
 #include <Main/globals.hxx>
 #include <Airports/runways.hxx>
 #include <Navaids/waypoint.hxx>
+#include <Navaids/FlightPlan.hxx>
 #include <Navaids/positioned.hxx>
 
 namespace flightgear {
@@ -53,11 +54,24 @@ double pointsKnownDistanceFromGC(const SGGeoc& a, const SGGeoc&b, const SGGeoc&
 
 RoutePath::RoutePath(const flightgear::WayptVec& wpts) :
   _waypts(wpts)
+{
+  commonInit();
+}
+
+RoutePath::RoutePath(const flightgear::FlightPlan* fp)
+{
+  for (int l=0; l<fp->numLegs(); ++l) {
+    _waypts.push_back(fp->legAtIndex(l)->waypoint());
+  }
+  commonInit();
+}
+
+void RoutePath::commonInit()
 {
   _pathClimbFPM = 1200;
   _pathDescentFPM = 800;
   _pathIAS = 190; 
-  _pathTurnRate = 3.0; // 3 deg/sec = 180def/min = standard rate turn
+  _pathTurnRate = 3.0; // 3 deg/sec = 180def/min = standard rate turn  
 }
 
 SGGeodVec RoutePath::pathForIndex(int index) const
@@ -346,6 +360,6 @@ double RoutePath::distanceForClimb(double climbFt) const
 double RoutePath::magVarFor(const SGGeod& geod) const
 {
   double jd = globals->get_time_params()->getJD();
-  return sgGetMagVar(geod, jd);
+  return sgGetMagVar(geod, jd) * SG_RADIANS_TO_DEGREES;
 }