Expose additional Navaid fields for use by Nasal
This commit is contained in:
parent
9583e2d7ad
commit
510f2de84d
4 changed files with 318 additions and 305 deletions
|
@ -52,7 +52,7 @@ FGNavRecord::FGNavRecord(PositionedID aGuid, Type aTy, const std::string& aIdent
|
||||||
mRunway(aRunway),
|
mRunway(aRunway),
|
||||||
mColocated(0),
|
mColocated(0),
|
||||||
serviceable(true)
|
serviceable(true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
FGRunwayRef FGNavRecord::runway() const
|
FGRunwayRef FGNavRecord::runway() const
|
||||||
|
@ -65,19 +65,19 @@ double FGNavRecord::localizerWidth() const
|
||||||
if (!mRunway) {
|
if (!mRunway) {
|
||||||
return 6.0;
|
return 6.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
FGRunway* rwy = runway();
|
FGRunway* rwy = runway();
|
||||||
SGVec3d thresholdCart(SGVec3d::fromGeod(rwy->threshold()));
|
SGVec3d thresholdCart(SGVec3d::fromGeod(rwy->threshold()));
|
||||||
double axisLength = dist(cart(), thresholdCart);
|
double axisLength = dist(cart(), thresholdCart);
|
||||||
double landingLength = dist(thresholdCart, SGVec3d::fromGeod(rwy->end()));
|
double landingLength = dist(thresholdCart, SGVec3d::fromGeod(rwy->end()));
|
||||||
|
|
||||||
// Reference: http://dcaa.slv.dk:8000/icaodocs/
|
// Reference: http://dcaa.slv.dk:8000/icaodocs/
|
||||||
// ICAO standard width at threshold is 210 m = 689 feet = approx 700 feet.
|
// ICAO standard width at threshold is 210 m = 689 feet = approx 700 feet.
|
||||||
// ICAO 3.1.1 half course = DDM = 0.0775
|
// ICAO 3.1.1 half course = DDM = 0.0775
|
||||||
// ICAO 3.1.3.7.1 Sensitivity 0.00145 DDM/m at threshold
|
// ICAO 3.1.3.7.1 Sensitivity 0.00145 DDM/m at threshold
|
||||||
// implies peg-to-peg of 214 m ... we will stick with 210.
|
// implies peg-to-peg of 214 m ... we will stick with 210.
|
||||||
// ICAO 3.1.3.7.1 "Course sector angle shall not exceed 6 degrees."
|
// ICAO 3.1.3.7.1 "Course sector angle shall not exceed 6 degrees."
|
||||||
|
|
||||||
// Very short runway: less than 1200 m (4000 ft) landing length:
|
// Very short runway: less than 1200 m (4000 ft) landing length:
|
||||||
if (landingLength < 1200.0) {
|
if (landingLength < 1200.0) {
|
||||||
// ICAO fudges localizer sensitivity for very short runways.
|
// ICAO fudges localizer sensitivity for very short runways.
|
||||||
|
@ -93,7 +93,7 @@ double FGNavRecord::localizerWidth() const
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FGNavRecord::hasDME()
|
bool FGNavRecord::hasDME() const
|
||||||
{
|
{
|
||||||
return (mColocated > 0);
|
return (mColocated > 0);
|
||||||
}
|
}
|
||||||
|
@ -232,7 +232,7 @@ void FGMobileNavRecord::updatePos()
|
||||||
FGTACANRecord::FGTACANRecord(void) :
|
FGTACANRecord::FGTACANRecord(void) :
|
||||||
channel(""),
|
channel(""),
|
||||||
freq(0)
|
freq(0)
|
||||||
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ const double FG_DME_DEFAULT_RANGE = 50; // nm
|
||||||
const double FG_TACAN_DEFAULT_RANGE = 250; // nm
|
const double FG_TACAN_DEFAULT_RANGE = 250; // nm
|
||||||
const double FG_NAV_MAX_RANGE = 300; // nm
|
const double FG_NAV_MAX_RANGE = 300; // nm
|
||||||
|
|
||||||
class FGNavRecord : public FGPositioned
|
class FGNavRecord : public FGPositioned
|
||||||
{
|
{
|
||||||
|
|
||||||
int freq;
|
int freq;
|
||||||
|
@ -69,7 +69,7 @@ class FGNavRecord : public FGPositioned
|
||||||
inline double get_lon() const { return longitude(); } // degrees
|
inline double get_lon() const { return longitude(); } // degrees
|
||||||
inline double get_lat() const { return latitude(); } // degrees
|
inline double get_lat() const { return latitude(); } // degrees
|
||||||
inline double get_elev_ft() const { return elevation(); }
|
inline double get_elev_ft() const { return elevation(); }
|
||||||
|
|
||||||
inline int get_freq() const { return freq; }
|
inline int get_freq() const { return freq; }
|
||||||
inline int get_range() const { return range; }
|
inline int get_range() const { return range; }
|
||||||
inline double get_multiuse() const { return multiuse; }
|
inline double get_multiuse() const { return multiuse; }
|
||||||
|
@ -98,7 +98,7 @@ class FGNavRecord : public FGPositioned
|
||||||
void unbindFromNode(SGPropertyNode* nd) const;
|
void unbindFromNode(SGPropertyNode* nd) const;
|
||||||
|
|
||||||
void setColocatedDME(PositionedID other);
|
void setColocatedDME(PositionedID other);
|
||||||
bool hasDME();
|
bool hasDME() const;
|
||||||
|
|
||||||
bool isVORTAC() const;
|
bool isVORTAC() const;
|
||||||
|
|
||||||
|
@ -137,11 +137,11 @@ class FGMobileNavRecord:
|
||||||
|
|
||||||
class FGTACANRecord : public SGReferenced {
|
class FGTACANRecord : public SGReferenced {
|
||||||
|
|
||||||
std::string channel;
|
std::string channel;
|
||||||
int freq;
|
int freq;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
FGTACANRecord(void);
|
FGTACANRecord(void);
|
||||||
inline ~FGTACANRecord(void) {}
|
inline ~FGTACANRecord(void) {}
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -401,7 +401,7 @@ static naRef f_findByName(nasal::CallContext ctx)
|
||||||
std::string prefix = ctx.requireArg<std::string>(0);
|
std::string prefix = ctx.requireArg<std::string>(0);
|
||||||
std::string typeSpec = ctx.getArg<std::string>(1);
|
std::string typeSpec = ctx.getArg<std::string>(1);
|
||||||
FGPositioned::TypeFilter filter(FGPositioned::TypeFilter::fromString(typeSpec));
|
FGPositioned::TypeFilter filter(FGPositioned::TypeFilter::fromString(typeSpec));
|
||||||
|
|
||||||
return ctx.to_nasal( FGPositioned::findAllWithName(prefix, &filter, false) );
|
return ctx.to_nasal( FGPositioned::findAllWithName(prefix, &filter, false) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -414,16 +414,16 @@ static naRef f_courseAndDistance(nasal::CallContext ctx)
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
ctx.runtimeError("invalid arguments to courseAndDistance");
|
ctx.runtimeError("invalid arguments to courseAndDistance");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (extractGeod(ctx, to)) {
|
if (extractGeod(ctx, to)) {
|
||||||
from = pos; // we parsed both FROM and TO args, so first was FROM
|
from = pos; // we parsed both FROM and TO args, so first was FROM
|
||||||
} else {
|
} else {
|
||||||
to = pos; // only parsed one arg, so FROM is current
|
to = pos; // only parsed one arg, so FROM is current
|
||||||
}
|
}
|
||||||
|
|
||||||
double course, course2, d;
|
double course, course2, d;
|
||||||
SGGeodesy::inverse(from, to, course, course2, d);
|
SGGeodesy::inverse(from, to, course, course2, d);
|
||||||
|
|
||||||
return ctx.to_nasal_vec(course, d * SG_METER_TO_NM);
|
return ctx.to_nasal_vec(course, d * SG_METER_TO_NM);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -490,11 +490,14 @@ naRef initNasalPositioned_cppbind(naRef globalsRef, naContext c)
|
||||||
.bases<NasalPositioned>()
|
.bases<NasalPositioned>()
|
||||||
.member("frequency", &FGNavRecord::get_freq)
|
.member("frequency", &FGNavRecord::get_freq)
|
||||||
.member("range_nm", &FGNavRecord::get_range)
|
.member("range_nm", &FGNavRecord::get_range)
|
||||||
.member("course", &f_navaid_course);
|
.member("course", &f_navaid_course)
|
||||||
|
.member("magvar", &FGNavRecord::get_multiuse)
|
||||||
|
.member("dme", &FGNavRecord::hasDME)
|
||||||
|
.member("vorac", &FGNavRecord::isVORTAC);
|
||||||
|
|
||||||
NasalFix::init("Fix")
|
NasalFix::init("Fix")
|
||||||
.bases<NasalPositioned>();
|
.bases<NasalPositioned>();
|
||||||
|
|
||||||
NasalAirport::init("FGAirport")
|
NasalAirport::init("FGAirport")
|
||||||
.bases<NasalPositioned>()
|
.bases<NasalPositioned>()
|
||||||
.member("has_metar", &FGAirport::getMetar)
|
.member("has_metar", &FGAirport::getMetar)
|
||||||
|
@ -514,7 +517,7 @@ naRef initNasalPositioned_cppbind(naRef globalsRef, naContext c)
|
||||||
.method("getStar", &FGAirport::findSTARWithIdent)
|
.method("getStar", &FGAirport::findSTARWithIdent)
|
||||||
.method("getIAP", &FGAirport::findApproachWithIdent)
|
.method("getIAP", &FGAirport::findApproachWithIdent)
|
||||||
.method("tostring", &FGAirport::toString);
|
.method("tostring", &FGAirport::toString);
|
||||||
|
|
||||||
nasal::Hash globals(globalsRef, c),
|
nasal::Hash globals(globalsRef, c),
|
||||||
positioned( globals.createHash("positioned") );
|
positioned( globals.createHash("positioned") );
|
||||||
|
|
||||||
|
@ -522,13 +525,13 @@ naRef initNasalPositioned_cppbind(naRef globalsRef, naContext c)
|
||||||
positioned.set("findAirportsWithinRange", f_findAirportsWithinRange);
|
positioned.set("findAirportsWithinRange", f_findAirportsWithinRange);
|
||||||
positioned.set("findAirportsByICAO", &f_findAirportsByICAO);
|
positioned.set("findAirportsByICAO", &f_findAirportsByICAO);
|
||||||
positioned.set("navinfo", &f_navinfo);
|
positioned.set("navinfo", &f_navinfo);
|
||||||
|
|
||||||
positioned.set("findWithinRange", &f_findWithinRange);
|
positioned.set("findWithinRange", &f_findWithinRange);
|
||||||
positioned.set("findByIdent", &f_findByIdent);
|
positioned.set("findByIdent", &f_findByIdent);
|
||||||
positioned.set("findByName", &f_findByName);
|
positioned.set("findByName", &f_findByName);
|
||||||
positioned.set("courseAndDistance", &f_courseAndDistance);
|
positioned.set("courseAndDistance", &f_courseAndDistance);
|
||||||
positioned.set("sortByRange", &f_sortByRange);
|
positioned.set("sortByRange", &f_sortByRange);
|
||||||
|
|
||||||
positioned.set("diff", &f_diff);
|
positioned.set("diff", &f_diff);
|
||||||
|
|
||||||
return naNil();
|
return naNil();
|
||||||
|
|
Loading…
Reference in a new issue