1
0
Fork 0

Patch from Melchior Franz:

My last patch fixed the initialization problem only for the main branch, but
ignored the _MWERKS_ branch.
- merged the branches, only the loop head needs different treatment;
- don't access n.type before it is initialized (valgrind complaint)
- created a constructor; the operator>> wouldn't have initialized all
  variables in case of a broken default.nav.gz entry, so we would have
  got a mixture of the broken one and the previous one; in case of
  the first entry, that would have made nice random values ... ;-)
- move the automatic FGNav variable into the loop, so that the gets
  cleanly constructed for every database entry.
- commented out the frequency min/max exploration, which isn't used at all
- updated the commented out debug output statements, which were simply
  copied over from the nav* files, but never adapted (I needed them :-)
This commit is contained in:
david 2002-03-30 12:51:42 +00:00
parent 1ba6272e3c
commit 50e25151e1
4 changed files with 80 additions and 48 deletions

View file

@ -83,7 +83,7 @@ class FGILS {
public:
inline FGILS(void) {}
inline FGILS(void);
inline ~FGILS(void) {}
inline char get_ilstype() const { return ilstype; }
@ -124,6 +124,42 @@ public:
};
inline
FGILS::FGILS(void)
: ilstype(0),
locfreq(0),
locheading(0.0),
loclat(0.0),
loclon(0.0),
x(0.0), y(0.0), z(0.0),
has_gs(false),
gselev(0.0),
gsangle(0.0),
gslat(0.0),
gslon(0.0),
gs_x(0.0), gs_y(0.0), gs_z(0.0),
has_dme(false),
dmelat(0.0),
dmelon(0.0),
dme_x(0.0), dme_y(0.0), dme_z(0.0),
omlat(0.0),
omlon(0.0),
mmlat(0.0),
mmlon(0.0),
imlat(0.0),
imlon(0.0),
trans_ident(""),
loc_failed(false),
gs_failed(false),
dme_failed(false)
{
ilstypename[0] = '\0';
aptcode[0] = '\0';
rwyno[0] = '\0';
locident[0] = '\0';
}
inline istream&
operator >> ( istream& in, FGILS& i )
{

View file

@ -48,7 +48,6 @@ FGILSList::~FGILSList( void ) {
// load the navaids and build the map
bool FGILSList::init( SGPath path ) {
FGILS ils;
ilslist.erase( ilslist.begin(), ilslist.end() );
@ -63,47 +62,38 @@ bool FGILSList::init( SGPath path ) {
in >> skipeol;
in >> skipcomment;
// double min = 1000000.0;
// double max = 0.0;
#ifdef __MWERKS__
char c = 0;
while ( in.get(c) && c != '\0' && ils.get_ilstype() != '[' ) {
while ( in.get(c) && c != '\0' ) {
in.putback(c);
in >> ils;
if ( ils.get_ilstype() != '[' ) {
ilslist[ils.get_locfreq()].push_back(ils);
}
in >> skipcomment;
}
#else
double min = 1000000.0;
double max = 0.0;
while ( ! in.eof() ) {
in >> ils;
#endif
FGILS ils;
in >> ils;
if ( ils.get_ilstype() == '[' ) {
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; */
/* cout << "typename = " << ils.get_ilstypename() << endl;
cout << " aptcode = " << ils.get_aptcode() << endl;
cout << " twyno = " << ils.get_rwyno() << endl;
cout << " locfreq = " << ils.get_locfreq() << endl;
cout << " locident = " << ils.get_locident() << endl << endl; */
ilslist[ils.get_locfreq()].push_back(ils);
in >> skipcomment;
if ( ils.get_locfreq() < min ) {
/* if ( ils.get_locfreq() < min ) {
min = ils.get_locfreq();
}
if ( ils.get_locfreq() > max ) {
max = ils.get_locfreq();
}
} */
// update the marker beacon list
if ( fabs(ils.get_omlon()) > SG_EPSILON ||
@ -126,8 +116,6 @@ bool FGILSList::init( SGPath path ) {
// cout << "min freq = " << min << endl;
// cout << "max freq = " << max << endl;
#endif
return true;
}

View file

@ -66,7 +66,7 @@ class FGNav {
public:
inline FGNav(void) {}
inline FGNav(void);
inline ~FGNav(void) {}
inline char get_type() const { return type; }
@ -96,6 +96,24 @@ public:
};
inline
FGNav::FGNav(void) :
type(0),
lon(0.0), lat(0.0),
elev(0.0),
x(0.0), y(0.0), z(0.0),
freq(0),
range(0),
has_dme(false),
ident(""),
magvar(0.0),
trans_ident(""),
nav_failed(false),
dme_failed(false)
{
}
inline istream&
operator >> ( istream& in, FGNav& n )
{

View file

@ -47,7 +47,6 @@ FGNavList::~FGNavList( void ) {
// load the navaids and build the map
bool FGNavList::init( SGPath path ) {
FGNav n;
navaids.erase( navaids.begin(), navaids.end() );
@ -62,26 +61,19 @@ bool FGNavList::init( SGPath path ) {
in >> skipeol;
in >> skipcomment;
// 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
double min = 100000;
double max = 0;
while ( ! in.eof() ) {
in >> n;
#endif
FGNav n;
in >> n;
if ( n.get_type() == '[' ) {
break;
}
@ -92,26 +84,24 @@ bool FGNavList::init( SGPath path ) {
cout << " lat = " << n.get_lat() << endl;
cout << " elev = " << n.get_elev() << endl;
cout << " freq = " << n.get_freq() << endl;
cout << " range = " << n.get_range() << endl; */
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;
}