1
0
Fork 0

Expose additional Navaid fields for use by Nasal

This commit is contained in:
Stuart Buchanan 2018-04-16 13:37:17 +01:00
parent 9583e2d7ad
commit 510f2de84d
4 changed files with 318 additions and 305 deletions

View file

@ -52,7 +52,7 @@ FGNavRecord::FGNavRecord(PositionedID aGuid, Type aTy, const std::string& aIdent
mRunway(aRunway),
mColocated(0),
serviceable(true)
{
{
}
FGRunwayRef FGNavRecord::runway() const
@ -65,19 +65,19 @@ double FGNavRecord::localizerWidth() const
if (!mRunway) {
return 6.0;
}
FGRunway* rwy = runway();
SGVec3d thresholdCart(SGVec3d::fromGeod(rwy->threshold()));
double axisLength = dist(cart(), thresholdCart);
double landingLength = dist(thresholdCart, SGVec3d::fromGeod(rwy->end()));
// Reference: http://dcaa.slv.dk:8000/icaodocs/
// 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.3.7.1 Sensitivity 0.00145 DDM/m at threshold
// 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."
// Very short runway: less than 1200 m (4000 ft) landing length:
if (landingLength < 1200.0) {
// 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);
}
@ -232,7 +232,7 @@ void FGMobileNavRecord::updatePos()
FGTACANRecord::FGTACANRecord(void) :
channel(""),
freq(0)
{
}

View file

@ -39,7 +39,7 @@ const double FG_DME_DEFAULT_RANGE = 50; // nm
const double FG_TACAN_DEFAULT_RANGE = 250; // nm
const double FG_NAV_MAX_RANGE = 300; // nm
class FGNavRecord : public FGPositioned
class FGNavRecord : public FGPositioned
{
int freq;
@ -69,7 +69,7 @@ class FGNavRecord : public FGPositioned
inline double get_lon() const { return longitude(); } // degrees
inline double get_lat() const { return latitude(); } // degrees
inline double get_elev_ft() const { return elevation(); }
inline int get_freq() const { return freq; }
inline int get_range() const { return range; }
inline double get_multiuse() const { return multiuse; }
@ -98,7 +98,7 @@ class FGNavRecord : public FGPositioned
void unbindFromNode(SGPropertyNode* nd) const;
void setColocatedDME(PositionedID other);
bool hasDME();
bool hasDME() const;
bool isVORTAC() const;
@ -137,11 +137,11 @@ class FGMobileNavRecord:
class FGTACANRecord : public SGReferenced {
std::string channel;
std::string channel;
int freq;
public:
FGTACANRecord(void);
inline ~FGTACANRecord(void) {}

File diff suppressed because it is too large Load diff

View file

@ -401,7 +401,7 @@ static naRef f_findByName(nasal::CallContext ctx)
std::string prefix = ctx.requireArg<std::string>(0);
std::string typeSpec = ctx.getArg<std::string>(1);
FGPositioned::TypeFilter filter(FGPositioned::TypeFilter::fromString(typeSpec));
return ctx.to_nasal( FGPositioned::findAllWithName(prefix, &filter, false) );
}
@ -414,16 +414,16 @@ static naRef f_courseAndDistance(nasal::CallContext ctx)
if (!ok) {
ctx.runtimeError("invalid arguments to courseAndDistance");
}
if (extractGeod(ctx, to)) {
from = pos; // we parsed both FROM and TO args, so first was FROM
} else {
to = pos; // only parsed one arg, so FROM is current
}
double course, course2, d;
SGGeodesy::inverse(from, to, course, course2, d);
return ctx.to_nasal_vec(course, d * SG_METER_TO_NM);
}
@ -490,11 +490,14 @@ naRef initNasalPositioned_cppbind(naRef globalsRef, naContext c)
.bases<NasalPositioned>()
.member("frequency", &FGNavRecord::get_freq)
.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")
.bases<NasalPositioned>();
NasalAirport::init("FGAirport")
.bases<NasalPositioned>()
.member("has_metar", &FGAirport::getMetar)
@ -514,7 +517,7 @@ naRef initNasalPositioned_cppbind(naRef globalsRef, naContext c)
.method("getStar", &FGAirport::findSTARWithIdent)
.method("getIAP", &FGAirport::findApproachWithIdent)
.method("tostring", &FGAirport::toString);
nasal::Hash globals(globalsRef, c),
positioned( globals.createHash("positioned") );
@ -522,13 +525,13 @@ naRef initNasalPositioned_cppbind(naRef globalsRef, naContext c)
positioned.set("findAirportsWithinRange", f_findAirportsWithinRange);
positioned.set("findAirportsByICAO", &f_findAirportsByICAO);
positioned.set("navinfo", &f_navinfo);
positioned.set("findWithinRange", &f_findWithinRange);
positioned.set("findByIdent", &f_findByIdent);
positioned.set("findByName", &f_findByName);
positioned.set("courseAndDistance", &f_courseAndDistance);
positioned.set("sortByRange", &f_sortByRange);
positioned.set("diff", &f_diff);
return naNil();