1 // navrecord.hxx -- generic vor/dme/ndb class
3 // Written by Curtis Olson, started May 2004.
5 // Copyright (C) 2004 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.
24 #ifndef _FG_NAVRECORD_HXX
25 #define _FG_NAVRECORD_HXX
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>
35 #ifdef SG_HAVE_STD_INCLUDES
37 #elif defined( __BORLANDC__ ) || (__APPLE__)
43 SG_USING_STD(istream);
46 #define FG_NAV_DEFAULT_RANGE 50
47 #define FG_LOC_DEFAULT_RANGE 18
48 #define FG_DME_DEFAULT_RANGE 50
54 double lon, lat; // location in geodetic coords
56 double x, y, z; // location in cartesian coords (earth centered)
59 double multiuse; // can be slaved variation of VOR
60 // (degrees) or localizer heading
61 // (degrees) or dme bias (nm)
63 string ident; // navaid ident
64 string name; // "given" name
67 bool serviceable; // for failure modeling
68 string trans_ident; // for failure modeling
72 inline FGNavRecord(void);
73 inline ~FGNavRecord(void) {}
75 inline int get_type() const { return type; }
76 inline double get_lon() const { return lon; }
77 inline double get_lat() const { return lat; }
78 inline double get_elev_ft() const { return elev_ft; }
79 inline double get_x() const { return x; }
80 inline double get_y() const { return y; }
81 inline double get_z() const { return z; }
82 inline int get_freq() const { return freq; }
83 inline int get_range() const { return range; }
84 inline double get_multiuse() const { return multiuse; }
85 inline const char *get_ident() { return ident.c_str(); }
86 inline string get_name() { return name; }
87 inline bool get_serviceable() { return serviceable; }
88 inline const char *get_trans_ident() { return trans_ident.c_str(); }
90 friend istream& operator>> ( istream&, FGNavRecord& );
95 FGNavRecord::FGNavRecord(void) :
99 x(0.0), y(0.0), z(0.0),
112 operator >> ( istream& in, FGNavRecord& n )
116 if ( n.type == 99 ) {
117 return in >> skipeol;
120 in >> n.lat >> n.lon >> n.elev_ft >> n.freq >> n.multiuse
122 getline( in, n.name );
124 // silently multiply adf frequencies by 100 so that adf
125 // vs. nav/loc frequency lookups can use the same code.
130 // Remove the space before the name
131 if ( n.name.substr(0,1) == " " ) {
132 n.name = n.name.erase(0,1);
135 // assign default ranges
136 if ( n.type == 2 || n.type == 3 ) {
137 n.range = FG_NAV_DEFAULT_RANGE;
138 } else if ( n.type == 4 || n.type == 5 || n.type == 6 ) {
139 n.range = FG_LOC_DEFAULT_RANGE;
140 } else if ( n.type == 12 ) {
141 n.range = FG_DME_DEFAULT_RANGE;
143 n.range = FG_LOC_DEFAULT_RANGE;
146 // transmitted ident (same as ident unless modeling a fault)
147 n.trans_ident = n.ident;
149 // generate cartesian coordinates
150 Point3D geod( n.lon * SGD_DEGREES_TO_RADIANS,
151 n.lat * SGD_DEGREES_TO_RADIANS,
152 n.elev_ft * SG_FEET_TO_METER );
153 Point3D cart = sgGeodToCart( geod );
162 #endif // _FG_NAVRECORD_HXX