]> git.mxchange.org Git - flightgear.git/blobdiff - src/Navaids/routePath.cxx
Bug #927 - flightplan XML loading.
[flightgear.git] / src / Navaids / routePath.cxx
index ee67effb52c1c58c23ad1c9bae52bd5814b28d66..6353fb5b678711d5815de93ca7778dd4deb92b6c 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 {
@@ -38,7 +39,7 @@ double pointsKnownDistanceFromGC(const SGGeoc& a, const SGGeoc&b, const SGGeoc&
   double p = atan2(sin(bDist)*cos(A), cos(bDist));
   
   if (sqr(cos(dist)) > sqr(r)) {
-    SG_LOG(SG_GENERAL, SG_INFO, "pointsKnownDistanceFromGC, no points exist");
+    SG_LOG(SG_NAVAID, SG_INFO, "pointsKnownDistanceFromGC, no points exist");
     return -1.0;
   }
   
@@ -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
@@ -242,7 +256,7 @@ bool RoutePath::computedPositionForIndex(int index, SGGeod& r) const
     return true;
   }
   
-  SG_LOG(SG_GENERAL, SG_INFO, "RoutePath::computedPositionForIndex: unhandled type:" << w->type());
+  SG_LOG(SG_NAVAID, SG_INFO, "RoutePath::computedPositionForIndex: unhandled type:" << w->type());
   return false;
 }
 
@@ -273,7 +287,7 @@ double RoutePath::computeAltitudeForIndex(int index) const
   if (!computedPositionForIndex(index, pos) ||
       !computedPositionForIndex(index - 1, prevPos))
   {
-    SG_LOG(SG_GENERAL, SG_WARN, "unable to compute position for waypoints");
+    SG_LOG(SG_NAVAID, SG_WARN, "unable to compute position for waypoints");
     throw sg_range_exception("unable to compute position for waypoints");
   }
   
@@ -311,7 +325,7 @@ double RoutePath::computeTrackForIndex(int index) const
     Hold* h = (Hold*) w.get();
     return h->inboundRadial();
   } else if (w->type() == "vectors") {
-    SG_LOG(SG_GENERAL, SG_WARN, "asked for track from VECTORS");
+    SG_LOG(SG_NAVAID, SG_WARN, "asked for track from VECTORS");
     throw sg_range_exception("asked for track from vectors waypt");
   } else if (w->type() == "runway") {
     FGRunway* rwy = static_cast<RunwayWaypt*>(w.get())->runway();
@@ -324,7 +338,7 @@ double RoutePath::computeTrackForIndex(int index) const
   if (!computedPositionForIndex(index, pos) ||
       !computedPositionForIndex(index - 1, prevPos))
   {
-    SG_LOG(SG_GENERAL, SG_WARN, "unable to compute position for waypoints");
+    SG_LOG(SG_NAVAID, SG_WARN, "unable to compute position for waypoints");
     throw sg_range_exception("unable to compute position for waypoints");
   }