#include <simgear/compiler.h>
#include <simgear/math/sg_random.h>
+#include <simgear/math/sg_geodesy.hxx>
+#include <simgear/timing/sg_time.hxx>
#include <Aircraft/aircraft.hxx>
#include <Navaids/navlist.hxx>
#include "kr_87.hxx"
#include <string>
-SG_USING_STD(string);
+using std::string;
static int play_count = 0;
static time_t last_time = 0;
// Update current nav/adf radio stations based on current postition
void FGKR_87::search() {
- double acft_lon = lon_node->getDoubleValue() * SGD_DEGREES_TO_RADIANS;
- double acft_lat = lat_node->getDoubleValue() * SGD_DEGREES_TO_RADIANS;
- double acft_elev = alt_node->getDoubleValue() * SG_FEET_TO_METER;
-
+ SGGeod pos = SGGeod::fromDegFt(lon_node->getDoubleValue(),
+ lat_node->getDoubleValue(), alt_node->getDoubleValue());
+
// FIXME: the panel should handle this
static string last_ident = "";
// ADF.
////////////////////////////////////////////////////////////////////////
- FGNavRecord *adf
- = globals->get_navlist()->findByFreq( freq, acft_lon, acft_lat,
- acft_elev );
+
+ FGNavRecord *adf = globals->get_navlist()->findByFreq( freq, pos);
if ( adf != NULL ) {
char sfreq[128];
snprintf( sfreq, 10, "%d", freq );
stn_lat = adf->get_lat();
stn_elev = adf->get_elev_ft();
range = adf->get_range();
- effective_range = kludgeRange(stn_elev, acft_elev, range);
- xyz = adf->get_cart();
+ effective_range = kludgeRange(stn_elev, pos.getElevationM(), range);
+ xyz = adf->cart();
if ( globals->get_soundmgr()->exists( "adf-ident" ) ) {
globals->get_soundmgr()->remove( "adf-ident" );