]> git.mxchange.org Git - flightgear.git/blob - src/Navaids/nav.hxx
don't destroy iterated map entries; delete _menubar; restore closed
[flightgear.git] / src / Navaids / nav.hxx
1 // nav.hxx -- vor/dme/ndb class
2 //
3 // Written by Curtis Olson, started April 2000.
4 //
5 // Copyright (C) 2000  Curtis L. Olson - http://www.flightgear.org/~curt
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_NAV_HXX
25 #define _FG_NAV_HXX
26
27 #include <stdio.h>
28
29 #include <simgear/compiler.h>
30 #include <simgear/math/sg_geodesy.hxx>
31 #include <simgear/misc/sgstream.hxx>
32 #include <simgear/magvar/magvar.hxx>
33 #include <simgear/timing/sg_time.hxx>
34
35 #ifdef SG_HAVE_STD_INCLUDES
36 #  include <istream>
37 #elif defined( __BORLANDC__ ) || (__APPLE__)
38 #  include <iostream>
39 #else
40 #  include <istream.h>
41 #endif
42
43 SG_USING_STD(istream);
44
45
46 class FGNav {
47     int type;
48     double lon, lat;
49     double elev_ft;
50     double x, y, z;
51     int freq;
52     double range;
53     string ident;
54     double magvar;              // magvar from true north (negative = W)
55     string name;
56
57     // for failure modeling
58     bool serviceable;
59     string trans_ident;         // transmitted ident
60
61 public:
62
63     inline FGNav();
64     inline FGNav( int _type, double _lat, double _lon, double _elev_ft,
65                   int _freq, double _range, double _magvar,
66                   const string& _ident, const string& _name,
67                   bool _serviceable );
68     inline ~FGNav() {}
69
70     inline int get_type() const { return type; }
71     inline double get_lon() const { return lon; }
72     inline double get_lat() const { return lat; }
73     inline double get_elev_ft() const { return elev_ft; }
74     inline double get_x() const { return x; }
75     inline double get_y() const { return y; }
76     inline double get_z() const { return z; }
77     inline int get_freq() const { return freq; }
78     inline double get_range() const { return range; }
79     // inline bool get_has_dme() const { return has_dme; }
80     inline const char *get_ident() { return ident.c_str(); }
81     inline const string& get_trans_ident() { return trans_ident; }
82     inline double get_magvar() const { return magvar; }
83     inline const string& get_name() { return name; }
84 };
85
86
87 inline
88 FGNav::FGNav() :
89     type(0),
90     lon(0.0), lat(0.0),
91     elev_ft(0.0),
92     x(0.0), y(0.0), z(0.0),
93     freq(0),
94     range(0.0),
95     // has_dme(false),
96     ident(""),
97     magvar(0.0),
98     name(""),
99     serviceable(true),
100     trans_ident("")
101 {
102 }
103
104
105 inline
106 FGNav::FGNav( int _type, double _lat, double _lon, double _elev_ft,
107               int _freq, double _range, double _magvar,
108               const string& _ident, const string& _name,
109               bool _serviceable ) :
110     type(0),
111     lon(0.0), lat(0.0),
112     elev_ft(0.0),
113     x(0.0), y(0.0), z(0.0),
114     freq(0),
115     range(0.0),
116     // has_dme(false),
117     ident(""),
118     magvar(0.0),
119     name(""),
120     serviceable(true),
121     trans_ident("")
122 {
123     type = _type;
124     lat = _lat;
125     lon = _lon;
126     elev_ft = _elev_ft;
127     freq = _freq;
128     range = _range;
129     magvar = _magvar;
130     ident = _ident;
131     name = _name;
132     trans_ident = _ident;
133     serviceable = _serviceable;
134
135     // generate cartesian coordinates
136     Point3D geod( lon * SGD_DEGREES_TO_RADIANS,
137                   lat * SGD_DEGREES_TO_RADIANS,
138                   elev_ft * SG_FEET_TO_METER );
139     Point3D cart = sgGeodToCart( geod );
140     x = cart.x();
141     y = cart.y();
142     z = cart.z();
143 }
144
145
146 #endif // _FG_NAV_HXX