+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
#include <Navaids/routePath.hxx>
#include <simgear/structure/exception.hxx>
#include <Main/globals.hxx>
#include <Airports/runways.hxx>
#include <Navaids/waypoint.hxx>
+#include <Navaids/FlightPlan.hxx>
#include <Navaids/positioned.hxx>
namespace flightgear {
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;
}
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
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;
}
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");
}
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();
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");
}
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;
}