1
0
Fork 0

Expose an additional flight plan leg data to Nasal.

This commit is contained in:
James Turner 2012-12-31 11:46:36 +00:00
parent 851029143e
commit 6c3853fd0d

View file

@ -2204,6 +2204,26 @@ static naRef f_leg_path(naContext c, naRef me, int argc, naRef* args)
return result; return result;
} }
static naRef f_leg_courseAndDistanceFrom(naContext c, naRef me, int argc, naRef* args)
{
FlightPlan::Leg* leg = fpLegGhost(me);
if (!leg) {
naRuntimeError(c, "leg.courseAndDistanceFrom called on non-flightplan-leg object");
}
SGGeod pos;
geodFromArgs(args, 0, argc, pos);
double courseDeg;
double distanceM;
boost::tie(courseDeg, distanceM) = leg->waypoint()->courseAndDistanceFrom(pos);
naRef result = naNewVector(c);
naVec_append(result, naNum(courseDeg));
naVec_append(result, naNum(distanceM * SG_METER_TO_NM));
return result;
}
static naRef f_waypoint_navaid(naContext c, naRef me, int argc, naRef* args) static naRef f_waypoint_navaid(naContext c, naRef me, int argc, naRef* args)
{ {
flightgear::Waypt* w = wayptGhost(me); flightgear::Waypt* w = wayptGhost(me);
@ -2409,6 +2429,7 @@ naRef initNasalPositioned(naRef globals, naContext c, naRef gcSave)
hashset(c, fpLegPrototype, "setSpeed", naNewFunc(c, naNewCCode(c, f_leg_setSpeed))); hashset(c, fpLegPrototype, "setSpeed", naNewFunc(c, naNewCCode(c, f_leg_setSpeed)));
hashset(c, fpLegPrototype, "setAltitude", naNewFunc(c, naNewCCode(c, f_leg_setAltitude))); hashset(c, fpLegPrototype, "setAltitude", naNewFunc(c, naNewCCode(c, f_leg_setAltitude)));
hashset(c, fpLegPrototype, "path", naNewFunc(c, naNewCCode(c, f_leg_path))); hashset(c, fpLegPrototype, "path", naNewFunc(c, naNewCCode(c, f_leg_path)));
hashset(c, fpLegPrototype, "courseAndDistanceFrom", naNewFunc(c, naNewCCode(c, f_leg_courseAndDistanceFrom)));
for(int i=0; funcs[i].name; i++) { for(int i=0; funcs[i].name; i++) {
hashset(c, globals, funcs[i].name, hashset(c, globals, funcs[i].name,