Working on straightening out VOR navigation.
This commit is contained in:
parent
59e811fb44
commit
cbaf015481
6 changed files with 71 additions and 68 deletions
|
@ -2501,7 +2501,7 @@ SOURCE=.\src\Network\protocol.cxx
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\Network\native.cxx
|
||||
SOURCE=.\src\Network\atlas.cxx
|
||||
|
||||
!IF "$(CFG)" == "FlightGear - Win32 Release"
|
||||
|
||||
|
@ -2531,6 +2531,36 @@ SOURCE=.\src\Network\garmin.cxx
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\Network\joyclient.cxx
|
||||
|
||||
!IF "$(CFG)" == "FlightGear - Win32 Release"
|
||||
|
||||
# PROP Intermediate_Dir "Release\Lib_Network"
|
||||
|
||||
!ELSEIF "$(CFG)" == "FlightGear - Win32 Debug"
|
||||
|
||||
# PROP Intermediate_Dir "Debug\Lib_Network"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\Network\native.cxx
|
||||
|
||||
!IF "$(CFG)" == "FlightGear - Win32 Release"
|
||||
|
||||
# PROP Intermediate_Dir "Release\Lib_Network"
|
||||
|
||||
!ELSEIF "$(CFG)" == "FlightGear - Win32 Debug"
|
||||
|
||||
# PROP Intermediate_Dir "Debug\Lib_Network"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\Network\nmea.cxx
|
||||
|
||||
!IF "$(CFG)" == "FlightGear - Win32 Release"
|
||||
|
@ -2603,21 +2633,6 @@ SOURCE=.\src\Network\rul.cxx
|
|||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\Network\joyclient.cxx
|
||||
|
||||
!IF "$(CFG)" == "FlightGear - Win32 Release"
|
||||
|
||||
# PROP Intermediate_Dir "Release\Lib_Network"
|
||||
|
||||
!ELSEIF "$(CFG)" == "FlightGear - Win32 Debug"
|
||||
|
||||
# PROP Intermediate_Dir "Debug\Lib_Network"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Lib_NetworkOLK"
|
||||
|
|
|
@ -209,7 +209,8 @@ FGRadioStack::update()
|
|||
geo_inverse_wgs_84( elev, lat * RAD_TO_DEG, lon * RAD_TO_DEG,
|
||||
nav1_loclat, nav1_loclon,
|
||||
&az1, &az2, &s );
|
||||
nav1_heading = az1 - nav1_offset;
|
||||
cout << "az1 = " << az1 << " magvar = " << nav1_magvar << endl;
|
||||
nav1_heading = az1 - nav1_magvar;
|
||||
// Alex: nav1_heading = - (az1 - FGBFI::getMagVar() / RAD_TO_DEG);
|
||||
|
||||
// cout << " heading = " << nav1_heading
|
||||
|
@ -254,7 +255,7 @@ FGRadioStack::update()
|
|||
geo_inverse_wgs_84( elev, lat * RAD_TO_DEG, lon * RAD_TO_DEG,
|
||||
nav2_loclat, nav2_loclon,
|
||||
&az1, &az2, &s );
|
||||
nav2_heading = az1 - nav2_offset;
|
||||
nav2_heading = az1 - nav2_magvar;
|
||||
// Alex: nav2_heading = - (az1 - FGBFI::getMagVar() / RAD_TO_DEG);
|
||||
|
||||
// cout << " heading = " << nav2_heading
|
||||
|
@ -321,7 +322,7 @@ void FGRadioStack::search ()
|
|||
nav1_dmelon = ils.get_dmelon();
|
||||
nav1_dmelat = ils.get_dmelat();
|
||||
nav1_elev = ils.get_gselev();
|
||||
nav1_offset = 0;
|
||||
nav1_magvar = 0;
|
||||
nav1_effective_range = FG_ILS_DEFAULT_RANGE;
|
||||
nav1_target_gs = ils.get_gsangle();
|
||||
nav1_radial = ils.get_locheading();
|
||||
|
@ -346,7 +347,7 @@ void FGRadioStack::search ()
|
|||
nav1_loclon = nav.get_lon();
|
||||
nav1_loclat = nav.get_lat();
|
||||
nav1_elev = nav.get_elev();
|
||||
nav1_offset = nav.get_offset();
|
||||
nav1_magvar = nav.get_magvar();
|
||||
nav1_effective_range = kludgeRange(nav1_elev, elev, nav.get_range());
|
||||
nav1_target_gs = 0.0;
|
||||
nav1_radial = nav1_sel_radial;
|
||||
|
@ -371,7 +372,7 @@ void FGRadioStack::search ()
|
|||
nav2_loclon = ils.get_loclon();
|
||||
nav2_loclat = ils.get_loclat();
|
||||
nav2_elev = ils.get_gselev();
|
||||
nav2_offset = 0;
|
||||
nav2_magvar = 0;
|
||||
nav2_effective_range = FG_ILS_DEFAULT_RANGE;
|
||||
nav2_target_gs = ils.get_gsangle();
|
||||
nav2_radial = ils.get_locheading();
|
||||
|
@ -396,7 +397,7 @@ void FGRadioStack::search ()
|
|||
nav2_loclon = nav.get_lon();
|
||||
nav2_loclat = nav.get_lat();
|
||||
nav2_elev = nav.get_elev();
|
||||
nav2_offset = nav.get_offset();
|
||||
nav2_magvar = nav.get_magvar();
|
||||
nav2_effective_range = kludgeRange(nav2_elev, elev, nav.get_range());
|
||||
nav2_target_gs = 0.0;
|
||||
nav2_radial = nav2_sel_radial;
|
||||
|
|
|
@ -75,7 +75,7 @@ class FGRadioStack : public FGSubsystem
|
|||
double nav1_effective_range;
|
||||
double nav1_heading;
|
||||
double nav1_target_gs;
|
||||
int nav1_offset;
|
||||
double nav1_magvar;
|
||||
|
||||
bool nav2_valid;
|
||||
bool nav2_inrange;
|
||||
|
@ -108,7 +108,7 @@ class FGRadioStack : public FGSubsystem
|
|||
double nav2_effective_range;
|
||||
double nav2_heading;
|
||||
double nav2_target_gs;
|
||||
int nav2_offset;
|
||||
double nav2_magvar;
|
||||
|
||||
bool adf_valid;
|
||||
bool adf_inrange;
|
||||
|
|
|
@ -427,22 +427,11 @@ double FGSteam::get_HackVOR1_deg () {
|
|||
double r;
|
||||
|
||||
if ( current_radiostack->get_nav1_inrange() ) {
|
||||
#if 0
|
||||
// depricated
|
||||
if ( current_radiostack->get_nav1_loc() ) {
|
||||
// localizer doesn't need magvar offset
|
||||
r = current_radiostack->get_nav1_heading()
|
||||
- current_radiostack->get_nav1_radial();
|
||||
} else {
|
||||
r = current_radiostack->get_nav1_heading() - FGBFI::getMagVar()
|
||||
- current_radiostack->get_nav1_radial();
|
||||
}
|
||||
#endif
|
||||
r = current_radiostack->get_nav1_heading()
|
||||
- current_radiostack->get_nav1_radial();
|
||||
// cout << "Radial = " << current_radiostack->get_nav1_radial()
|
||||
// << " Bearing = " << current_radiostack->get_nav1_heading()
|
||||
// << endl;
|
||||
cout << "Radial = " << current_radiostack->get_nav1_radial()
|
||||
<< " Bearing = " << current_radiostack->get_nav1_heading()
|
||||
<< endl;
|
||||
|
||||
if (r> 180.0) r-=360.0; else
|
||||
if (r<-180.0) r+=360.0;
|
||||
|
@ -462,17 +451,6 @@ double FGSteam::get_HackVOR2_deg () {
|
|||
double r;
|
||||
|
||||
if ( current_radiostack->get_nav2_inrange() ) {
|
||||
#if 0
|
||||
// Depricated
|
||||
if ( current_radiostack->get_nav2_loc() ) {
|
||||
// localizer doesn't need magvar offset
|
||||
r = current_radiostack->get_nav2_heading()
|
||||
- current_radiostack->get_nav2_radial();
|
||||
} else {
|
||||
r = current_radiostack->get_nav2_heading() - FGBFI::getMagVar()
|
||||
- current_radiostack->get_nav2_radial();
|
||||
}
|
||||
#endif
|
||||
r = current_radiostack->get_nav2_heading()
|
||||
- current_radiostack->get_nav2_radial();
|
||||
// cout << "Radial = " << current_radiostack->get_nav1_radial()
|
||||
|
|
|
@ -56,7 +56,7 @@ class FGNav {
|
|||
int range;
|
||||
bool has_dme;
|
||||
string ident; // to avoid a core dump with corrupt data
|
||||
int offset; // offset from true north (negative = W)
|
||||
double magvar; // magvar from true north (negative = W)
|
||||
|
||||
public:
|
||||
|
||||
|
@ -74,7 +74,7 @@ public:
|
|||
inline int get_range() const { return range; }
|
||||
inline bool get_has_dme() const { return has_dme; }
|
||||
inline const char *get_ident() { return ident.c_str(); }
|
||||
inline int get_offset () const { return offset; }
|
||||
inline double get_magvar () const { return magvar; }
|
||||
|
||||
/* inline void set_type( char t ) { type = t; }
|
||||
inline void set_lon( double l ) { lon = l; }
|
||||
|
@ -93,11 +93,11 @@ inline istream&
|
|||
operator >> ( istream& in, FGNav& n )
|
||||
{
|
||||
double f;
|
||||
char c /* , offset_dir */ ;
|
||||
string offset_s;
|
||||
char c /* , magvar_dir */ ;
|
||||
string magvar_s;
|
||||
|
||||
in >> n.type >> n.lat >> n.lon >> n.elev >> f >> n.range
|
||||
>> c >> n.ident >> offset_s;
|
||||
>> c >> n.ident >> magvar_s;
|
||||
|
||||
n.freq = (int)(f*100.0 + 0.5);
|
||||
if ( c == 'Y' ) {
|
||||
|
@ -106,29 +106,35 @@ operator >> ( istream& in, FGNav& n )
|
|||
n.has_dme = false;
|
||||
}
|
||||
|
||||
// Calculate the offset from true north.
|
||||
// cout << "Calculating offset for navaid " << n.ident << endl;
|
||||
if (offset_s == "XXX") {
|
||||
// Calculate the magvar from true north.
|
||||
// cout << "Calculating magvar for navaid " << n.ident << endl;
|
||||
if (magvar_s == "XXX") {
|
||||
// default to mag var as of 1990-01-01 (Julian 2447892.5)
|
||||
double var = sgGetMagVar(n.lon * DEG_TO_RAD, n.lat * DEG_TO_RAD,
|
||||
n.elev * FEET_TO_METER,
|
||||
2447892.5) * RAD_TO_DEG;
|
||||
n.magvar = -sgGetMagVar(n.lon * DEG_TO_RAD, n.lat * DEG_TO_RAD,
|
||||
n.elev * FEET_TO_METER,
|
||||
2447892.5) * RAD_TO_DEG;
|
||||
// cout << "Default variation at " << n.lon << ',' << n.lat
|
||||
// << " is " << var << endl;
|
||||
#if 0
|
||||
// I don't know what this is for - CLO 1 Feb 2001
|
||||
if (var - int(var) >= 0.5)
|
||||
n.offset = int(var) + 1;
|
||||
n.magvar = int(var) + 1;
|
||||
else if (var - int(var) <= -0.5)
|
||||
n.offset = int(var) - 1;
|
||||
n.magvar = int(var) - 1;
|
||||
else
|
||||
n.offset = int(var);
|
||||
// cout << "Defaulted to offset of " << n.offset << endl;
|
||||
n.magvar = int(var);
|
||||
#endif
|
||||
// cout << "Defaulted to magvar of " << n.magvar << endl;
|
||||
} else {
|
||||
char direction;
|
||||
sscanf(offset_s.c_str(), "%d%c", &(n.offset), &direction);
|
||||
if (direction == 'W')
|
||||
n.offset = 0 - n.offset;
|
||||
// cout << "Explicit offset of " << n.offset << endl;
|
||||
int var;
|
||||
sscanf(magvar_s.c_str(), "%d%c", &var, &direction);
|
||||
n.magvar = var;
|
||||
if (direction == 'E')
|
||||
n.magvar = 0 - n.magvar;
|
||||
// cout << "Explicit magvar of " << n.magvar << endl;
|
||||
}
|
||||
cout << n.ident << " " << n.magvar << endl;
|
||||
|
||||
// generate cartesian coordinates
|
||||
Point3D geod( n.lon * DEG_TO_RAD, n.lat * DEG_TO_RAD, n.elev );
|
||||
|
|
|
@ -45,6 +45,9 @@ FGNavList::~FGNavList( void ) {
|
|||
bool FGNavList::init( FGPath path ) {
|
||||
FGNav n;
|
||||
|
||||
SGTime time_params;
|
||||
time_params.update( 0.0, 0.0, 0 );
|
||||
|
||||
navaids.erase( navaids.begin(), navaids.end() );
|
||||
|
||||
fg_gzifstream in( path.str() );
|
||||
|
|
Loading…
Add table
Reference in a new issue