1
0
Fork 0

Vassilii Khachaturov:

I found that all the current users of the companion
function, findByFreq() actually did assume radians despite the misleading
comment in the .hxx and .cxx saying it's degrees. I've fixed the
comment now, and no longer change the Navaids code. The new Navaids user
in NewWaypoint() is now passing radians to the findByIdent().

Note that along with fixing the comments in the navlist.hxx, I removed
an obsolete method findByLoc() declaration (there is no definition
anywhere).
This commit is contained in:
ehofman 2005-10-22 13:37:13 +00:00
parent f938af2592
commit 3188b395c8
3 changed files with 46 additions and 15 deletions

View file

@ -51,6 +51,8 @@
#include <Main/globals.hxx> #include <Main/globals.hxx>
#include <Main/fg_props.hxx> #include <Main/fg_props.hxx>
#include <Navaids/fixlist.hxx> #include <Navaids/fixlist.hxx>
#include <Navaids/navlist.hxx>
#include <Navaids/navrecord.hxx>
#include "auto_gui.hxx" #include "auto_gui.hxx"
#include "route_mgr.hxx" #include "route_mgr.hxx"
@ -691,8 +693,46 @@ int NewWaypoint( string Tgt_Alt )
fgSetString( "/autopilot/locks/heading", "true-heading-hold" ); fgSetString( "/autopilot/locks/heading", "true-heading-hold" );
return 2; return 2;
} else { } else {
// Try finding a nav matching the ID
double lat, lon;
// The base lon/lat are determined by the last WP,
// or the current pos if the WP list is empty.
const int wps = rm->size();
if (wps > 0) {
SGWayPoint wp = rm->get_waypoint(wps-1);
lat = wp.get_target_lat();
lon = wp.get_target_lon();
}
else {
lat = fgGetNode("/position/latitude-deg")->getDoubleValue();
lon = fgGetNode("/position/longitude-deg")->getDoubleValue();
}
lat *= SGD_DEGREES_TO_RADIANS;
lon *= SGD_DEGREES_TO_RADIANS;
SG_LOG( SG_GENERAL, SG_INFO,
"Looking for nav " << TgtAptId << " at " << lon << " " << lat);
if (FGNavRecord* nav =
globals->get_navlist()->findByIdent(TgtAptId.c_str(), lon, lat))
{
SG_LOG( SG_GENERAL, SG_INFO,
"Adding waypoint (nav) = " << TgtAptId );
sprintf( NewTgtAirportId, "%s", TgtAptId.c_str() );
SGWayPoint wp( nav->get_lon(), nav->get_lat(), alt,
SGWayPoint::WGS84, TgtAptId );
rm->add_waypoint( wp );
/* and turn on the autopilot */
fgSetString( "/autopilot/locks/heading", "true-heading-hold" );
return 3;
}
else {
return 0; return 0;
} }
}
} }

View file

@ -143,10 +143,6 @@ bool FGTACANList::add( FGTACANRecord *c ) {
return true; return true;
} }
// Query the database for the specified frequency. It is assumed that
// there will be multiple stations with matching frequencies so a
// position must be specified. Lon and lat are in degrees, elev is in
// meters.
FGNavRecord *FGNavList::findByFreq( double freq, double lon, double lat, double elev ) FGNavRecord *FGNavList::findByFreq( double freq, double lon, double lat, double elev )
{ {
nav_list_type stations = navaids[(int)(freq*100.0 + 0.5)]; nav_list_type stations = navaids[(int)(freq*100.0 + 0.5)];

View file

@ -78,18 +78,13 @@ public:
bool add( FGNavRecord *n ); bool add( FGNavRecord *n );
//bool add( FGTACANRecord *r ); //bool add( FGTACANRecord *r );
// Query the database for the specified frequency. It is assumed /** Query the database for the specified station. It is assumed
// that there will be multiple stations with matching frequencies * that there will be multiple stations with matching frequencies
// so a position must be specified. Lon and lat are in degrees, * so a position must be specified. Lon and lat are in radians,
// elev is in meters. * elev is in meters.
*/
FGNavRecord *findByFreq( double freq, double lon, double lat, double elev ); FGNavRecord *findByFreq( double freq, double lon, double lat, double elev );
// Query the database for the specified frequency. It is assumed
// that there will be multiple stations with matching frequencies
// so a position must be specified. Lon and lat are in degrees,
// elev is in meters.
FGNavRecord *findByLoc( double lon, double lat, double elev );
// locate closest item in the DB matching the requested ident // locate closest item in the DB matching the requested ident
FGNavRecord *findByIdent( const char* ident, const double lon, const double lat ); FGNavRecord *findByIdent( const char* ident, const double lon, const double lat );