2000-04-21 18:00:47 +00:00
|
|
|
// ils.hxx -- navaid class
|
|
|
|
//
|
|
|
|
// Written by Curtis Olson, started April 2000.
|
|
|
|
//
|
|
|
|
// Copyright (C) 2000 Curtis L. Olson - curt@flightgear.org
|
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU General Public License as
|
|
|
|
// published by the Free Software Foundation; either version 2 of the
|
|
|
|
// License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful, but
|
|
|
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
//
|
|
|
|
// $Id$
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef _FG_ILS_HXX
|
|
|
|
#define _FG_ILS_HXX
|
|
|
|
|
|
|
|
|
|
|
|
#include <simgear/compiler.h>
|
2000-09-27 20:16:22 +00:00
|
|
|
#include <simgear/math/sg_geodesy.hxx>
|
2001-03-25 14:20:12 +00:00
|
|
|
#include <simgear/misc/sgstream.hxx>
|
2000-04-21 18:00:47 +00:00
|
|
|
|
2001-03-23 22:15:19 +00:00
|
|
|
#ifdef SG_HAVE_STD_INCLUDES
|
2000-04-21 18:00:47 +00:00
|
|
|
# include <istream>
|
2002-05-11 12:30:22 +00:00
|
|
|
#elif defined( __BORLANDC__ ) || (__APPLE__)
|
2000-04-21 18:00:47 +00:00
|
|
|
# include <iostream>
|
|
|
|
#else
|
|
|
|
# include <istream.h>
|
|
|
|
#endif
|
|
|
|
|
2001-03-23 22:59:18 +00:00
|
|
|
SG_USING_STD(istream);
|
2000-04-21 18:00:47 +00:00
|
|
|
|
|
|
|
|
2001-03-14 07:25:14 +00:00
|
|
|
#define FG_ILS_DEFAULT_RANGE 18
|
2000-04-21 18:00:47 +00:00
|
|
|
|
|
|
|
class FGILS {
|
|
|
|
|
|
|
|
char ilstype;
|
|
|
|
char ilstypename[6];
|
|
|
|
char aptcode[5];
|
|
|
|
char rwyno[4];
|
|
|
|
int locfreq;
|
2001-03-12 12:40:18 +00:00
|
|
|
char locident[5]; // official ident
|
2000-04-21 18:00:47 +00:00
|
|
|
double locheading;
|
|
|
|
double loclat;
|
|
|
|
double loclon;
|
2000-05-12 22:17:09 +00:00
|
|
|
double x, y, z;
|
|
|
|
bool has_gs;
|
2000-04-21 18:00:47 +00:00
|
|
|
double gselev;
|
|
|
|
double gsangle;
|
|
|
|
double gslat;
|
|
|
|
double gslon;
|
2000-05-12 20:07:51 +00:00
|
|
|
double gs_x, gs_y, gs_z;
|
2000-05-12 22:17:09 +00:00
|
|
|
bool has_dme;
|
2000-04-21 18:00:47 +00:00
|
|
|
double dmelat;
|
|
|
|
double dmelon;
|
2000-05-12 20:07:51 +00:00
|
|
|
double dme_x, dme_y, dme_z;
|
2000-04-21 18:00:47 +00:00
|
|
|
double omlat;
|
|
|
|
double omlon;
|
|
|
|
double mmlat;
|
|
|
|
double mmlon;
|
|
|
|
double imlat;
|
|
|
|
double imlon;
|
|
|
|
|
2001-03-12 12:40:18 +00:00
|
|
|
// for failure modeling
|
|
|
|
string trans_ident; // transmitted ident
|
|
|
|
bool loc_failed; // localizer failed?
|
|
|
|
bool gs_failed; // glide slope failed?
|
|
|
|
bool dme_failed; // dme failed?
|
|
|
|
|
2000-04-21 18:00:47 +00:00
|
|
|
public:
|
|
|
|
|
2002-03-30 12:51:42 +00:00
|
|
|
inline FGILS(void);
|
2000-04-21 18:00:47 +00:00
|
|
|
inline ~FGILS(void) {}
|
|
|
|
|
|
|
|
inline char get_ilstype() const { return ilstype; }
|
|
|
|
inline char *get_ilstypename() { return ilstypename; }
|
|
|
|
inline char *get_aptcode() { return aptcode; }
|
|
|
|
inline char *get_rwyno() { return rwyno; }
|
|
|
|
inline int get_locfreq() const { return locfreq; }
|
|
|
|
inline char *get_locident() { return locident; }
|
2001-03-12 12:40:18 +00:00
|
|
|
inline string get_trans_ident() { return trans_ident; }
|
2000-04-21 18:00:47 +00:00
|
|
|
inline double get_locheading() const { return locheading; }
|
|
|
|
inline double get_loclat() const { return loclat; }
|
|
|
|
inline double get_loclon() const { return loclon; }
|
2000-05-12 22:17:09 +00:00
|
|
|
inline double get_x() const { return x; }
|
|
|
|
inline double get_y() const { return y; }
|
|
|
|
inline double get_z() const { return z; }
|
|
|
|
inline bool get_has_gs() const { return has_gs; }
|
2000-04-25 03:09:26 +00:00
|
|
|
inline double get_gselev() const { return gselev; }
|
2000-04-21 18:00:47 +00:00
|
|
|
inline double get_gsangle() const { return gsangle; }
|
|
|
|
inline double get_gslat() const { return gslat; }
|
|
|
|
inline double get_gslon() const { return gslon; }
|
2000-05-12 20:07:51 +00:00
|
|
|
inline double get_gs_x() const { return gs_x; }
|
|
|
|
inline double get_gs_y() const { return gs_y; }
|
|
|
|
inline double get_gs_z() const { return gs_z; }
|
2000-05-12 22:17:09 +00:00
|
|
|
inline bool get_has_dme() const { return has_dme; }
|
2000-04-21 18:00:47 +00:00
|
|
|
inline double get_dmelat() const { return dmelat; }
|
|
|
|
inline double get_dmelon() const { return dmelon; }
|
2000-05-12 20:07:51 +00:00
|
|
|
inline double get_dme_x() const { return dme_x; }
|
|
|
|
inline double get_dme_y() const { return dme_y; }
|
|
|
|
inline double get_dme_z() const { return dme_z; }
|
2000-04-21 18:00:47 +00:00
|
|
|
inline double get_omlat() const { return omlat; }
|
|
|
|
inline double get_omlon() const { return omlon; }
|
|
|
|
inline double get_mmlat() const { return mmlat; }
|
|
|
|
inline double get_mmlon() const { return mmlon; }
|
|
|
|
inline double get_imlat() const { return imlat; }
|
|
|
|
inline double get_imlon() const { return imlon; }
|
|
|
|
|
|
|
|
friend istream& operator>> ( istream&, FGILS& );
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2002-03-30 12:51:42 +00:00
|
|
|
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';
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-04-21 18:00:47 +00:00
|
|
|
inline istream&
|
|
|
|
operator >> ( istream& in, FGILS& i )
|
|
|
|
{
|
|
|
|
double f;
|
2001-10-11 22:07:45 +00:00
|
|
|
in >> i.ilstype;
|
|
|
|
|
|
|
|
if ( i.ilstype == '[' )
|
|
|
|
return in;
|
|
|
|
|
|
|
|
in >> i.ilstypename >> i.aptcode >> i.rwyno
|
2000-04-21 18:00:47 +00:00
|
|
|
>> f >> i.locident >> i.locheading >> i.loclat >> i.loclon
|
|
|
|
>> i.gselev >> i.gsangle >> i.gslat >> i.gslon
|
|
|
|
>> i.dmelat >> i.dmelon
|
|
|
|
>> i.omlat >> i.omlon
|
|
|
|
>> i.mmlat >> i.mmlon
|
|
|
|
>> i.imlat >> i.imlon;
|
|
|
|
|
|
|
|
|
2000-04-24 23:51:56 +00:00
|
|
|
i.locfreq = (int)(f*100.0 + 0.5);
|
2000-04-21 18:00:47 +00:00
|
|
|
|
2000-05-04 01:18:45 +00:00
|
|
|
// generate cartesian coordinates
|
2000-05-12 20:07:51 +00:00
|
|
|
Point3D geod, cart;
|
|
|
|
|
2001-03-24 04:48:44 +00:00
|
|
|
geod = Point3D( i.loclon * SGD_DEGREES_TO_RADIANS, i.loclat * SGD_DEGREES_TO_RADIANS, i.gselev );
|
2000-09-27 20:16:22 +00:00
|
|
|
cart = sgGeodToCart( geod );
|
2000-05-12 22:17:09 +00:00
|
|
|
i.x = cart.x();
|
|
|
|
i.y = cart.y();
|
|
|
|
i.z = cart.z();
|
|
|
|
|
2001-03-24 00:18:01 +00:00
|
|
|
if ( i.gslon < SG_EPSILON && i.gslat < SG_EPSILON ) {
|
2000-05-12 22:17:09 +00:00
|
|
|
i.has_gs = false;
|
|
|
|
} else {
|
|
|
|
i.has_gs = true;
|
|
|
|
|
2001-03-24 04:48:44 +00:00
|
|
|
geod = Point3D( i.gslon * SGD_DEGREES_TO_RADIANS, i.gslat * SGD_DEGREES_TO_RADIANS, i.gselev );
|
2000-09-27 20:16:22 +00:00
|
|
|
cart = sgGeodToCart( geod );
|
2000-05-12 22:17:09 +00:00
|
|
|
i.gs_x = cart.x();
|
|
|
|
i.gs_y = cart.y();
|
|
|
|
i.gs_z = cart.z();
|
|
|
|
// cout << "gs = " << cart << endl;
|
2000-05-12 20:07:51 +00:00
|
|
|
}
|
|
|
|
|
2001-03-24 00:18:01 +00:00
|
|
|
if ( i.dmelon < SG_EPSILON && i.dmelat < SG_EPSILON ) {
|
2000-05-12 22:17:09 +00:00
|
|
|
i.has_dme = false;
|
|
|
|
} else {
|
|
|
|
i.has_dme = true;
|
|
|
|
|
2001-03-24 04:48:44 +00:00
|
|
|
geod = Point3D( i.dmelon * SGD_DEGREES_TO_RADIANS, i.dmelat * SGD_DEGREES_TO_RADIANS, i.gselev);
|
2000-09-27 20:16:22 +00:00
|
|
|
cart = sgGeodToCart( geod );
|
2000-05-12 22:17:09 +00:00
|
|
|
i.dme_x = cart.x();
|
|
|
|
i.dme_y = cart.y();
|
|
|
|
i.dme_z = cart.z();
|
|
|
|
// cout << "dme = " << cart << endl;
|
2000-05-12 20:07:51 +00:00
|
|
|
}
|
|
|
|
|
2001-03-12 12:40:18 +00:00
|
|
|
i.trans_ident = "I";
|
|
|
|
i.trans_ident += i.locident;
|
|
|
|
i.loc_failed = i.gs_failed = i.dme_failed = false;
|
|
|
|
|
|
|
|
// return in >> skipeol;
|
2000-04-21 18:00:47 +00:00
|
|
|
return in;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-05-04 01:18:45 +00:00
|
|
|
#endif // _FG_ILS_HXX
|