1 // ils.hxx -- navaid class
3 // Written by Curtis Olson, started April 2000.
5 // Copyright (C) 2000 Curtis L. Olson - curt@flightgear.org
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 #include <simgear/compiler.h>
29 #include <simgear/math/sg_geodesy.hxx>
30 #include <simgear/misc/fgstream.hxx>
32 #ifdef SG_HAVE_STD_INCLUDES
34 #elif defined( SG_HAVE_NATIVE_SGI_COMPILERS )
35 # include <iostream.h>
36 #elif defined( __BORLANDC__ )
42 #if ! defined( SG_HAVE_NATIVE_SGI_COMPILERS )
43 SG_USING_STD(istream);
47 #define FG_ILS_DEFAULT_RANGE 18
56 char locident[5]; // official ident
66 double gs_x, gs_y, gs_z;
70 double dme_x, dme_y, dme_z;
78 // for failure modeling
79 string trans_ident; // transmitted ident
80 bool loc_failed; // localizer failed?
81 bool gs_failed; // glide slope failed?
82 bool dme_failed; // dme failed?
87 inline ~FGILS(void) {}
89 inline char get_ilstype() const { return ilstype; }
90 inline char *get_ilstypename() { return ilstypename; }
91 inline char *get_aptcode() { return aptcode; }
92 inline char *get_rwyno() { return rwyno; }
93 inline int get_locfreq() const { return locfreq; }
94 inline char *get_locident() { return locident; }
95 inline string get_trans_ident() { return trans_ident; }
96 inline double get_locheading() const { return locheading; }
97 inline double get_loclat() const { return loclat; }
98 inline double get_loclon() const { return loclon; }
99 inline double get_x() const { return x; }
100 inline double get_y() const { return y; }
101 inline double get_z() const { return z; }
102 inline bool get_has_gs() const { return has_gs; }
103 inline double get_gselev() const { return gselev; }
104 inline double get_gsangle() const { return gsangle; }
105 inline double get_gslat() const { return gslat; }
106 inline double get_gslon() const { return gslon; }
107 inline double get_gs_x() const { return gs_x; }
108 inline double get_gs_y() const { return gs_y; }
109 inline double get_gs_z() const { return gs_z; }
110 inline bool get_has_dme() const { return has_dme; }
111 inline double get_dmelat() const { return dmelat; }
112 inline double get_dmelon() const { return dmelon; }
113 inline double get_dme_x() const { return dme_x; }
114 inline double get_dme_y() const { return dme_y; }
115 inline double get_dme_z() const { return dme_z; }
116 inline double get_omlat() const { return omlat; }
117 inline double get_omlon() const { return omlon; }
118 inline double get_mmlat() const { return mmlat; }
119 inline double get_mmlon() const { return mmlon; }
120 inline double get_imlat() const { return imlat; }
121 inline double get_imlon() const { return imlon; }
123 friend istream& operator>> ( istream&, FGILS& );
128 operator >> ( istream& in, FGILS& i )
131 in >> i.ilstype >> i.ilstypename >> i.aptcode >> i.rwyno
132 >> f >> i.locident >> i.locheading >> i.loclat >> i.loclon
133 >> i.gselev >> i.gsangle >> i.gslat >> i.gslon
134 >> i.dmelat >> i.dmelon
135 >> i.omlat >> i.omlon
136 >> i.mmlat >> i.mmlon
137 >> i.imlat >> i.imlon;
140 i.locfreq = (int)(f*100.0 + 0.5);
142 // generate cartesian coordinates
145 geod = Point3D( i.loclon * DEG_TO_RAD, i.loclat * DEG_TO_RAD, i.gselev );
146 cart = sgGeodToCart( geod );
151 if ( i.gslon < SG_EPSILON && i.gslat < SG_EPSILON ) {
156 geod = Point3D( i.gslon * DEG_TO_RAD, i.gslat * DEG_TO_RAD, i.gselev );
157 cart = sgGeodToCart( geod );
161 // cout << "gs = " << cart << endl;
164 if ( i.dmelon < SG_EPSILON && i.dmelat < SG_EPSILON ) {
169 geod = Point3D( i.dmelon * DEG_TO_RAD, i.dmelat * DEG_TO_RAD, i.gselev);
170 cart = sgGeodToCart( geod );
174 // cout << "dme = " << cart << endl;
178 i.trans_ident += i.locident;
179 i.loc_failed = i.gs_failed = i.dme_failed = false;
181 // return in >> skipeol;
186 #endif // _FG_ILS_HXX