// $Id$
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include <simgear/debug/logstream.hxx>
-#include <simgear/misc/fgstream.hxx>
+#include <simgear/misc/sgstream.hxx>
#include <simgear/math/sg_geodesy.hxx>
#include "navlist.hxx"
// load the navaids and build the map
-bool FGNavList::init( FGPath path ) {
- FGNav n;
+bool FGNavList::init( SGPath path ) {
navaids.erase( navaids.begin(), navaids.end() );
- fg_gzifstream in( path.str() );
+ sg_gzifstream in( path.str() );
if ( !in.is_open() ) {
- FG_LOG( FG_GENERAL, FG_ALERT, "Cannot open file: " << path.str() );
+ SG_LOG( SG_GENERAL, SG_ALERT, "Cannot open file: " << path.str() );
exit(-1);
}
in >> skipeol;
in >> skipcomment;
-#ifdef __MWERKS__
+ // double min = 100000;
+ // double max = 0;
+#ifdef __MWERKS__
char c = 0;
- while ( in.get(c) && c != '\0' && n.get_type() != '[' ) {
+ while ( in.get(c) && c != '\0' ) {
in.putback(c);
- in >> n;
- if ( n.get_type() != '[' ) {
- navaids[n.get_freq()].push_back(n);
- }
- in >> skipcomment;
- }
-
#else
+ while ( ! in.eof() ) {
+#endif
- double min = 100000;
- double max = 0;
-
- while ( ! in.eof() && n.get_type() != '[' ) {
+ FGNav n;
in >> n;
+ if ( n.get_type() == '[' ) {
+ break;
+ }
+
/* cout << "id = " << n.get_ident() << endl;
cout << " type = " << n.get_type() << endl;
cout << " lon = " << n.get_lon() << endl;
cout << " lat = " << n.get_lat() << endl;
cout << " elev = " << n.get_elev() << endl;
cout << " freq = " << n.get_freq() << endl;
- cout << " range = " << n.get_range() << endl; */
- if ( n.get_type() != '[' ) {
- navaids[n.get_freq()].push_back(n);
- }
+ cout << " range = " << n.get_range() << endl << endl; */
+
+ navaids[n.get_freq()].push_back(n);
in >> skipcomment;
- if ( n.get_type() != 'N' ) {
+ /* if ( n.get_type() != 'N' ) {
if ( n.get_freq() < min ) {
min = n.get_freq();
}
if ( n.get_freq() > max ) {
max = n.get_freq();
}
- }
+ } */
}
// cout << "min freq = " << min << endl;
// cout << "max freq = " << max << endl;
-#endif
-
return true;
}
d = aircraft.distance3Dsquared( station );
// cout << " dist = " << sqrt(d)
- // << " range = " << current->get_range() * NM_TO_METER << endl;
- if ( d < (current->get_range() * NM_TO_METER
- * current->get_range() * NM_TO_METER * 5.0) ) {
+ // << " range = " << current->get_range() * SG_NM_TO_METER << endl;
+
+ // match up to twice the published range so we can model
+ // reduced signal strength
+ if ( d < (2 * current->get_range() * SG_NM_TO_METER
+ * 2 * current->get_range() * SG_NM_TO_METER ) ) {
// cout << "matched = " << current->get_ident() << endl;
*n = *current;
return true;