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/constants.h>
30 #include <simgear/math/sg_geodesy.hxx>
31 #include <simgear/misc/sgstream.hxx>
33 #ifdef SG_HAVE_STD_INCLUDES
35 #elif defined( __BORLANDC__ ) || (__APPLE__)
41 SG_USING_STD(istream);
44 #define FG_ILS_DEFAULT_RANGE 18
53 char locident[5]; // official ident
63 double gs_x, gs_y, gs_z;
67 double dme_x, dme_y, dme_z;
75 // for failure modeling
76 string trans_ident; // transmitted ident
77 bool loc_failed; // localizer failed?
78 bool gs_failed; // glide slope failed?
79 bool dme_failed; // dme failed?
84 inline ~FGILS(void) {}
86 inline char get_ilstype() const { return ilstype; }
87 inline char *get_ilstypename() { return ilstypename; }
88 inline char *get_aptcode() { return aptcode; }
89 inline char *get_rwyno() { return rwyno; }
90 inline int get_locfreq() const { return locfreq; }
91 inline char *get_locident() { return locident; }
92 inline string get_trans_ident() { return trans_ident; }
93 inline double get_locheading() const { return locheading; }
94 inline double get_loclat() const { return loclat; }
95 inline double get_loclon() const { return loclon; }
96 inline double get_x() const { return x; }
97 inline double get_y() const { return y; }
98 inline double get_z() const { return z; }
99 inline bool get_has_gs() const { return has_gs; }
100 inline double get_gselev() const { return gselev; }
101 inline double get_gsangle() const { return gsangle; }
102 inline double get_gslat() const { return gslat; }
103 inline double get_gslon() const { return gslon; }
104 inline double get_gs_x() const { return gs_x; }
105 inline double get_gs_y() const { return gs_y; }
106 inline double get_gs_z() const { return gs_z; }
107 inline bool get_has_dme() const { return has_dme; }
108 inline double get_dmelat() const { return dmelat; }
109 inline double get_dmelon() const { return dmelon; }
110 inline double get_dme_x() const { return dme_x; }
111 inline double get_dme_y() const { return dme_y; }
112 inline double get_dme_z() const { return dme_z; }
113 inline double get_omlat() const { return omlat; }
114 inline double get_omlon() const { return omlon; }
115 inline double get_mmlat() const { return mmlat; }
116 inline double get_mmlon() const { return mmlon; }
117 inline double get_imlat() const { return imlat; }
118 inline double get_imlon() const { return imlon; }
120 friend istream& operator>> ( istream&, FGILS& );
131 x(0.0), y(0.0), z(0.0),
137 gs_x(0.0), gs_y(0.0), gs_z(0.0),
141 dme_x(0.0), dme_y(0.0), dme_z(0.0),
153 ilstypename[0] = '\0';
161 operator >> ( istream& in, FGILS& i )
166 if ( i.ilstype == '[' )
169 in >> i.ilstypename >> i.aptcode >> i.rwyno
170 >> f >> i.locident >> i.locheading >> i.loclat >> i.loclon
171 >> i.gselev >> i.gsangle >> i.gslat >> i.gslon
172 >> i.dmelat >> i.dmelon
173 >> i.omlat >> i.omlon
174 >> i.mmlat >> i.mmlon
175 >> i.imlat >> i.imlon;
178 i.locfreq = (int)(f*100.0 + 0.5);
180 // generate cartesian coordinates
183 geod = Point3D( i.loclon * SGD_DEGREES_TO_RADIANS,
184 i.loclat * SGD_DEGREES_TO_RADIANS,
185 i.gselev * SG_FEET_TO_METER );
186 cart = sgGeodToCart( geod );
191 if ( i.gslon < SG_EPSILON && i.gslat < SG_EPSILON ) {
196 geod = Point3D( i.gslon * SGD_DEGREES_TO_RADIANS,
197 i.gslat * SGD_DEGREES_TO_RADIANS,
198 i.gselev * SG_FEET_TO_METER );
199 cart = sgGeodToCart( geod );
203 // cout << "gs = " << cart << endl;
206 if ( i.dmelon < SG_EPSILON && i.dmelat < SG_EPSILON ) {
211 geod = Point3D( i.dmelon * SGD_DEGREES_TO_RADIANS,
212 i.dmelat * SGD_DEGREES_TO_RADIANS,
213 i.gselev * SG_FEET_TO_METER );
214 cart = sgGeodToCart( geod );
218 // cout << "dme = " << cart << endl;
222 i.trans_ident += i.locident;
223 i.loc_failed = i.gs_failed = i.dme_failed = false;
225 // return in >> skipeol;
230 #endif // _FG_ILS_HXX