]> git.mxchange.org Git - flightgear.git/blob - src/Navaids/navrecord.hxx
Merge branch 'maint2' into next
[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
47 class FGNavRecord : public FGPositioned 
48 {
49
50     int freq;
51     int range;
52     double multiuse;            // can be slaved variation of VOR
53                                 // (degrees) or localizer heading
54                                 // (degrees) or dme bias (nm)
55
56     std::string _name;                // verbose name in nav database
57     FGRunway* runway;
58
59     bool serviceable;           // for failure modeling
60     std::string trans_ident;         // for failure modeling
61
62   /**
63    * Helper to init data when a navrecord is associated with an airport
64    */
65   void initAirportRelation();
66   
67   void alignLocaliserWithRunway(FGRunway* aRunway, double aThreshold);
68 public:
69   inline ~FGNavRecord(void) {}
70
71   static FGNavRecord* createFromStream(std::istream& aStream);
72
73     FGNavRecord(Type type, const std::string& ident, const std::string& name,
74       const SGGeod& aPos,
75       int freq, int range, double multiuse);
76     
77     inline double get_lon() const { return longitude(); } // degrees
78     inline double get_lat() const { return latitude(); } // degrees
79     inline double get_elev_ft() const { return elevation(); }
80         
81     inline int get_freq() const { return freq; }
82     inline int get_range() const { return range; }
83     inline double get_multiuse() const { return multiuse; }
84     inline void set_multiuse( double m ) { multiuse = m; }
85     inline const char *get_ident() const { return ident().c_str(); }
86
87     inline bool get_serviceable() const { return serviceable; }
88     inline const char *get_trans_ident() const { return trans_ident.c_str(); }
89
90   virtual const std::string& name() const
91   { return _name; }
92 };
93
94 class FGTACANRecord : public SGReferenced {
95
96     std::string channel;                
97     int freq;
98      
99 public:
100     
101      FGTACANRecord(void);
102     inline ~FGTACANRecord(void) {}
103
104     inline const std::string& get_channel() const { return channel; }
105     inline int get_freq() const { return freq; }
106     friend std::istream& operator>> ( std::istream&, FGTACANRecord& );
107     };
108
109 #endif // _FG_NAVRECORD_HXX