]> git.mxchange.org Git - flightgear.git/blob - src/Navaids/ils.hxx
Added support for managing fov via the property manager so the --fov= option
[flightgear.git] / src / Navaids / ils.hxx
1 // ils.hxx -- navaid class
2 //
3 // Written by Curtis Olson, started April 2000.
4 //
5 // Copyright (C) 2000  Curtis L. Olson - curt@flightgear.org
6 //
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.
11 //
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.
16 //
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.
20 //
21 // $Id$
22
23
24 #ifndef _FG_ILS_HXX
25 #define _FG_ILS_HXX
26
27
28 #include <simgear/compiler.h>
29 #include <simgear/math/sg_geodesy.hxx>
30 #include <simgear/misc/fgstream.hxx>
31
32 #ifdef FG_HAVE_STD_INCLUDES
33 #  include <istream>
34 #elif defined( FG_HAVE_NATIVE_SGI_COMPILERS )
35 #  include <iostream.h>
36 #elif defined( __BORLANDC__ )
37 #  include <iostream>
38 #else
39 #  include <istream.h>
40 #endif
41
42 #if ! defined( FG_HAVE_NATIVE_SGI_COMPILERS )
43 FG_USING_STD(istream);
44 #endif
45
46
47 #define FG_ILS_DEFAULT_RANGE 30
48
49 class FGILS {
50
51     char ilstype;
52     char ilstypename[6];
53     char aptcode[5];
54     char rwyno[4];
55     int  locfreq;
56     char locident[5];
57     double locheading;
58     double loclat;
59     double loclon;
60     double x, y, z;
61     bool has_gs;
62     double gselev;
63     double gsangle;
64     double gslat;
65     double gslon;
66     double gs_x, gs_y, gs_z;
67     bool has_dme;
68     double dmelat;
69     double dmelon;
70     double dme_x, dme_y, dme_z;
71     double omlat;
72     double omlon;
73     double mmlat;
74     double mmlon;
75     double imlat;
76     double imlon;
77
78 public:
79
80     inline FGILS(void) {}
81     inline ~FGILS(void) {}
82
83     inline char get_ilstype() const { return ilstype; }
84     inline char *get_ilstypename() { return ilstypename; }
85     inline char *get_aptcode() { return aptcode; }
86     inline char *get_rwyno() { return rwyno; }
87     inline int get_locfreq() const { return locfreq; }
88     inline char *get_locident() { return locident; }
89     inline double get_locheading() const { return locheading; }
90     inline double get_loclat() const { return loclat; }
91     inline double get_loclon() const { return loclon; }
92     inline double get_x() const { return x; }
93     inline double get_y() const { return y; }
94     inline double get_z() const { return z; }
95     inline bool get_has_gs() const { return has_gs; }
96     inline double get_gselev() const { return gselev; }
97     inline double get_gsangle() const { return gsangle; }
98     inline double get_gslat() const { return gslat; }
99     inline double get_gslon() const { return gslon; }
100     inline double get_gs_x() const { return gs_x; }
101     inline double get_gs_y() const { return gs_y; }
102     inline double get_gs_z() const { return gs_z; }
103     inline bool get_has_dme() const { return has_dme; }
104     inline double get_dmelat() const { return dmelat; }
105     inline double get_dmelon() const { return dmelon; }
106     inline double get_dme_x() const { return dme_x; }
107     inline double get_dme_y() const { return dme_y; }
108     inline double get_dme_z() const { return dme_z; }
109     inline double get_omlat() const { return omlat; }
110     inline double get_omlon() const { return omlon; }
111     inline double get_mmlat() const { return mmlat; }
112     inline double get_mmlon() const { return mmlon; }
113     inline double get_imlat() const { return imlat; }
114     inline double get_imlon() const { return imlon; }
115
116     friend istream& operator>> ( istream&, FGILS& );
117 };
118
119
120 inline istream&
121 operator >> ( istream& in, FGILS& i )
122 {
123     double f;
124     in >> i.ilstype >> i.ilstypename >> i.aptcode >> i.rwyno 
125        >> f >> i.locident >> i.locheading >> i.loclat >> i.loclon
126        >> i.gselev >> i.gsangle >> i.gslat >> i.gslon
127        >> i.dmelat >> i.dmelon
128        >> i.omlat >> i.omlon
129        >> i.mmlat >> i.mmlon
130        >> i.imlat >> i.imlon;
131         
132
133     i.locfreq = (int)(f*100.0 + 0.5);
134
135     // generate cartesian coordinates
136     Point3D geod, cart;
137
138     geod = Point3D( i.loclon * DEG_TO_RAD, i.loclat * DEG_TO_RAD, i.gselev );
139     cart = sgGeodToCart( geod );
140     i.x = cart.x();
141     i.y = cart.y();
142     i.z = cart.z();
143
144     if ( i.gslon < FG_EPSILON && i.gslat < FG_EPSILON ) {
145         i.has_gs = false;
146     } else {
147         i.has_gs = true;
148
149         geod = Point3D( i.gslon * DEG_TO_RAD, i.gslat * DEG_TO_RAD, i.gselev );
150         cart = sgGeodToCart( geod );
151         i.gs_x = cart.x();
152         i.gs_y = cart.y();
153         i.gs_z = cart.z();
154         // cout << "gs = " << cart << endl;
155     }
156
157     if ( i.dmelon < FG_EPSILON && i.dmelat < FG_EPSILON ) {
158         i.has_dme = false;
159     } else {
160         i.has_dme = true;
161
162         geod = Point3D( i.dmelon * DEG_TO_RAD, i.dmelat * DEG_TO_RAD, i.gselev);
163         cart = sgGeodToCart( geod );
164         i.dme_x = cart.x();
165         i.dme_y = cart.y();
166         i.dme_z = cart.z();
167         // cout << "dme = " << cart << endl;
168     }
169
170      // return in >> skipeol;
171     return in;
172 }
173
174
175 #endif // _FG_ILS_HXX