Directly associate runways objects with their ILS navrecord (if one exists)
This commit is contained in:
parent
83c29b4f43
commit
86d1e4ea9d
4 changed files with 31 additions and 20 deletions
|
@ -71,7 +71,8 @@ FGRunway::FGRunway(FGAirport* aAirport, const string& aIdent,
|
||||||
_airport(aAirport),
|
_airport(aAirport),
|
||||||
_reciprocal(reciprocal),
|
_reciprocal(reciprocal),
|
||||||
_displ_thresh(displ_thresh),
|
_displ_thresh(displ_thresh),
|
||||||
_stopway(stopway)
|
_stopway(stopway),
|
||||||
|
_ils(NULL)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
|
|
||||||
// forward decls
|
// forward decls
|
||||||
class FGAirport;
|
class FGAirport;
|
||||||
|
class FGNavRecord;
|
||||||
|
|
||||||
class FGRunway : public FGRunwayBase
|
class FGRunway : public FGRunwayBase
|
||||||
{
|
{
|
||||||
|
@ -37,6 +38,7 @@ class FGRunway : public FGRunwayBase
|
||||||
bool _reciprocal;
|
bool _reciprocal;
|
||||||
double _displ_thresh;
|
double _displ_thresh;
|
||||||
double _stopway;
|
double _stopway;
|
||||||
|
FGNavRecord* _ils;
|
||||||
public:
|
public:
|
||||||
|
|
||||||
FGRunway(FGAirport* aAirport, const std::string& rwy_no,
|
FGRunway(FGAirport* aAirport, const std::string& rwy_no,
|
||||||
|
@ -90,7 +92,7 @@ public:
|
||||||
double stopwayM() const
|
double stopwayM() const
|
||||||
{ return _stopway * SG_FEET_TO_METER; }
|
{ return _stopway * SG_FEET_TO_METER; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Airport this runway is located at
|
* Airport this runway is located at
|
||||||
*/
|
*/
|
||||||
FGAirport* airport() const
|
FGAirport* airport() const
|
||||||
|
@ -99,6 +101,9 @@ public:
|
||||||
// FIXME - should die once airport / runway creation is cleaned up
|
// FIXME - should die once airport / runway creation is cleaned up
|
||||||
void setAirport(FGAirport* aAirport)
|
void setAirport(FGAirport* aAirport)
|
||||||
{ _airport = aAirport; }
|
{ _airport = aAirport; }
|
||||||
|
|
||||||
|
FGNavRecord* ILS() const { return _ils; }
|
||||||
|
void setILS(FGNavRecord* nav) { _ils = nav; }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _FG_RUNWAYS_HXX
|
#endif // _FG_RUNWAYS_HXX
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include <simgear/misc/sgstream.hxx>
|
#include <simgear/misc/sgstream.hxx>
|
||||||
#include <simgear/structure/exception.hxx>
|
#include <simgear/structure/exception.hxx>
|
||||||
#include <simgear/debug/logstream.hxx>
|
#include <simgear/debug/logstream.hxx>
|
||||||
|
#include <simgear/sg_inlines.h>
|
||||||
|
|
||||||
#include <Navaids/navrecord.hxx>
|
#include <Navaids/navrecord.hxx>
|
||||||
#include <Navaids/navdb.hxx>
|
#include <Navaids/navdb.hxx>
|
||||||
|
@ -43,6 +44,7 @@ FGNavRecord::FGNavRecord(Type aTy, const std::string& aIdent,
|
||||||
range(aRange),
|
range(aRange),
|
||||||
multiuse(aMultiuse),
|
multiuse(aMultiuse),
|
||||||
_name(aName),
|
_name(aName),
|
||||||
|
mRunway(NULL),
|
||||||
serviceable(true),
|
serviceable(true),
|
||||||
trans_ident(aIdent)
|
trans_ident(aIdent)
|
||||||
{
|
{
|
||||||
|
@ -82,10 +84,14 @@ void FGNavRecord::initAirportRelation()
|
||||||
return; // not airport-located
|
return; // not airport-located
|
||||||
}
|
}
|
||||||
|
|
||||||
FGRunway* runway = getRunwayFromName(_name);
|
mRunway = getRunwayFromName(_name);
|
||||||
// fudge elevation to the runway elevation if it's not specified
|
// fudge elevation to the runway elevation if it's not specified
|
||||||
if (fabs(elevation()) < 0.01) {
|
if (fabs(elevation()) < 0.01) {
|
||||||
mPosition.setElevationFt(runway->elevation());
|
mPosition.setElevationFt(mRunway->elevation());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type() == ILS) {
|
||||||
|
mRunway->setILS(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// align localizers with their runway
|
// align localizers with their runway
|
||||||
|
@ -96,35 +102,29 @@ void FGNavRecord::initAirportRelation()
|
||||||
|
|
||||||
double threshold
|
double threshold
|
||||||
= fgGetDouble( "/sim/navdb/localizers/auto-align-threshold-deg", 5.0 );
|
= fgGetDouble( "/sim/navdb/localizers/auto-align-threshold-deg", 5.0 );
|
||||||
alignLocaliserWithRunway(runway, threshold);
|
alignLocaliserWithRunway(threshold);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FGNavRecord::alignLocaliserWithRunway(FGRunway* aRunway, double aThreshold)
|
void FGNavRecord::alignLocaliserWithRunway(double aThreshold)
|
||||||
{
|
{
|
||||||
// find the distance from the threshold to the localizer
|
// find the distance from the threshold to the localizer
|
||||||
SGGeod runwayThreshold(aRunway->threshold());
|
SGGeod runwayThreshold(mRunway->threshold());
|
||||||
double dist, az1, az2;
|
double dist, az1, az2;
|
||||||
SGGeodesy::inverse(mPosition, runwayThreshold, az1, az2, dist);
|
SGGeodesy::inverse(mPosition, runwayThreshold, az1, az2, dist);
|
||||||
|
|
||||||
// back project that distance along the runway center line
|
// back project that distance along the runway center line
|
||||||
SGGeod newPos = aRunway->pointOnCenterline(dist);
|
SGGeod newPos = mRunway->pointOnCenterline(dist);
|
||||||
|
|
||||||
double hdg_diff = get_multiuse() - aRunway->headingDeg();
|
double hdg_diff = get_multiuse() - mRunway->headingDeg();
|
||||||
|
SG_NORMALIZE_RANGE(hdg_diff, -180.0, 180.0);
|
||||||
// clamp to [-180.0 ... 180.0]
|
|
||||||
if ( hdg_diff < -180.0 ) {
|
|
||||||
hdg_diff += 360.0;
|
|
||||||
} else if ( hdg_diff > 180.0 ) {
|
|
||||||
hdg_diff -= 360.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( fabs(hdg_diff) <= aThreshold ) {
|
if ( fabs(hdg_diff) <= aThreshold ) {
|
||||||
mPosition = newPos;
|
mPosition = newPos;
|
||||||
set_multiuse( aRunway->headingDeg() );
|
set_multiuse( mRunway->headingDeg() );
|
||||||
} else {
|
} else {
|
||||||
SG_LOG(SG_GENERAL, SG_WARN, "localizer:" << ident() << ", aligning with runway "
|
SG_LOG(SG_GENERAL, SG_WARN, "localizer:" << ident() << ", aligning with runway "
|
||||||
<< aRunway->ident() << " exceeded heading threshold");
|
<< mRunway->ident() << " exceeded heading threshold");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ class FGNavRecord : public FGPositioned
|
||||||
// (degrees) or dme bias (nm)
|
// (degrees) or dme bias (nm)
|
||||||
|
|
||||||
std::string _name; // verbose name in nav database
|
std::string _name; // verbose name in nav database
|
||||||
FGRunway* runway;
|
FGRunway* mRunway; // associated runway, if there is one
|
||||||
|
|
||||||
bool serviceable; // for failure modeling
|
bool serviceable; // for failure modeling
|
||||||
std::string trans_ident; // for failure modeling
|
std::string trans_ident; // for failure modeling
|
||||||
|
@ -64,7 +64,7 @@ class FGNavRecord : public FGPositioned
|
||||||
*/
|
*/
|
||||||
void initAirportRelation();
|
void initAirportRelation();
|
||||||
|
|
||||||
void alignLocaliserWithRunway(FGRunway* aRunway, double aThreshold);
|
void alignLocaliserWithRunway(double aThreshold);
|
||||||
public:
|
public:
|
||||||
inline ~FGNavRecord(void) {}
|
inline ~FGNavRecord(void) {}
|
||||||
|
|
||||||
|
@ -87,6 +87,11 @@ public:
|
||||||
|
|
||||||
virtual const std::string& name() const
|
virtual const std::string& name() const
|
||||||
{ return _name; }
|
{ return _name; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve the runway this navaid is associated with (for ILS/LOC/GS)
|
||||||
|
*/
|
||||||
|
FGRunway* runway() const { return mRunway; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class FGTACANRecord : public SGReferenced {
|
class FGTACANRecord : public SGReferenced {
|
||||||
|
|
Loading…
Reference in a new issue