]> git.mxchange.org Git - flightgear.git/blob - src/Navaids/navrecord.hxx
Merge branch 'vivian/cullsetting'
[flightgear.git] / src / Navaids / navrecord.hxx
1 // navrecord.hxx -- generic vor/dme/ndb class
2 //
3 // Written by Curtis Olson, started May 2004.
4 //
5 // Copyright (C) 2004  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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20 //
21 // $Id$
22
23
24 #ifndef _FG_NAVRECORD_HXX
25 #define _FG_NAVRECORD_HXX
26
27 #include <iosfwd>
28
29 #include "positioned.hxx"
30
31 #define FG_NAV_DEFAULT_RANGE 50 // nm
32 #define FG_LOC_DEFAULT_RANGE 18 // nm
33 #define FG_DME_DEFAULT_RANGE 50 // nm
34 #define FG_NAV_MAX_RANGE 300    // nm
35
36 // FIXME - get rid of these, and use the real enum directly
37 #define FG_NAV_VOR FGPositioned::VOR
38 #define FG_NAV_NDB FGPositioned::NDB
39 #define FG_NAV_ILS FGPositioned::ILS
40 #define FG_NAV_ANY FGPositioned::INVALID
41
42 typedef FGPositioned::Type fg_nav_types;
43
44 // forward decls
45 class FGRunway;
46 class SGPropertyNode;
47
48 class FGNavRecord : public FGPositioned 
49 {
50
51     int freq;
52     int range;
53     double multiuse;            // can be slaved variation of VOR
54                                 // (degrees) or localizer heading
55                                 // (degrees) or dme bias (nm)
56
57     std::string _name;                // verbose name in nav database
58     FGRunway* mRunway;        // associated runway, if there is one
59
60     bool serviceable;           // for failure modeling
61     std::string trans_ident;         // for failure modeling
62
63   /**
64    * Helper to init data when a navrecord is associated with an airport
65    */
66   void initAirportRelation();
67   
68   void alignLocaliserWithRunway(double aThreshold);
69   
70   void readAirportSceneryData();
71   void processSceneryILS(SGPropertyNode* aILSNode);
72 public:
73   inline ~FGNavRecord(void) {}
74
75     FGNavRecord(Type type, const std::string& ident, const std::string& name,
76       const SGGeod& aPos,
77       int freq, int range, double multiuse);
78     
79     inline double get_lon() const { return longitude(); } // degrees
80     inline double get_lat() const { return latitude(); } // degrees
81     inline double get_elev_ft() const { return elevation(); }
82         
83     inline int get_freq() const { return freq; }
84     inline int get_range() const { return range; }
85     inline double get_multiuse() const { return multiuse; }
86     inline void set_multiuse( double m ) { multiuse = m; }
87     inline const char *get_ident() const { return ident().c_str(); }
88
89     inline bool get_serviceable() const { return serviceable; }
90     inline const char *get_trans_ident() const { return trans_ident.c_str(); }
91
92   virtual const std::string& name() const
93   { return _name; }
94   
95   /**
96    * Retrieve the runway this navaid is associated with (for ILS/LOC/GS)
97    */
98   FGRunway* runway() const { return mRunway; }
99   
100   /**
101    * return the localizer width, in degrees
102    * computation is based up ICAO stdandard width at the runway threshold
103    * see implementation for further details.
104    */
105   double localizerWidth() const;
106 };
107
108 class FGTACANRecord : public SGReferenced {
109
110     std::string channel;                
111     int freq;
112      
113 public:
114     
115      FGTACANRecord(void);
116     inline ~FGTACANRecord(void) {}
117
118     inline const std::string& get_channel() const { return channel; }
119     inline int get_freq() const { return freq; }
120     friend std::istream& operator>> ( std::istream&, FGTACANRecord& );
121     };
122
123 #endif // _FG_NAVRECORD_HXX