]> git.mxchange.org Git - flightgear.git/blob - src/Navaids/navrecord.hxx
Fix distance-along-path computation
[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 "navaids_fwd.hxx"
30 #include "positioned.hxx"
31 #include <Airports/airports_fwd.hxx>
32
33 #include <simgear/props/propsfwd.hxx>
34 #include <simgear/timing/timestamp.hxx>
35
36 const double FG_NAV_DEFAULT_RANGE = 50; // nm
37 const double FG_LOC_DEFAULT_RANGE = 18; // nm
38 const double FG_DME_DEFAULT_RANGE = 50; // nm
39 const double FG_TACAN_DEFAULT_RANGE = 250; // nm
40 const double FG_NAV_MAX_RANGE = 300;    // nm
41
42 class FGNavRecord : public FGPositioned 
43 {
44
45     int freq;
46     int range;
47     double multiuse;            // can be slaved variation of VOR
48                                 // (degrees) or localizer heading
49                                 // (degrees) or dme bias (nm)
50
51     std::string mName;          // verbose name in nav database
52     PositionedID mRunway;       // associated runway, if there is one
53     PositionedID mColocated;    // Colocated DME at a navaid (ILS, VOR, TACAN, NDB)
54
55   protected:
56     mutable bool serviceable;   // for failure modeling
57
58   public:
59     FGNavRecord( PositionedID aGuid,
60                  Type type,
61                  const std::string& ident,
62                  const std::string& name,
63                  const SGGeod& aPos,
64                  int freq,
65                  int range,
66                  double multiuse,
67                  PositionedID aRunway );
68
69     inline double get_lon() const { return longitude(); } // degrees
70     inline double get_lat() const { return latitude(); } // degrees
71     inline double get_elev_ft() const { return elevation(); }
72         
73     inline int get_freq() const { return freq; }
74     inline int get_range() const { return range; }
75     inline double get_multiuse() const { return multiuse; }
76     inline void set_multiuse( double m ) { multiuse = m; }
77     inline const char *get_ident() const { return ident().c_str(); }
78
79     inline bool get_serviceable() const { return serviceable; }
80     inline const char *get_trans_ident() const { return get_ident(); }
81
82   virtual const std::string& name() const
83   { return mName; }
84   
85   /**
86    * Retrieve the runway this navaid is associated with (for ILS/LOC/GS)
87    */
88   FGRunwayRef runway() const;
89   
90   /**
91    * return the localizer width, in degrees
92    * computation is based up ICAO stdandard width at the runway threshold
93    * see implementation for further details.
94    */
95   double localizerWidth() const;
96   
97   void bindToNode(SGPropertyNode* nd) const;
98   void unbindFromNode(SGPropertyNode* nd) const;
99
100   void setColocatedDME(PositionedID other);
101   bool hasDME();
102     
103     void updateFromXML(const SGGeod& geod, double heading);
104 };
105
106 /**
107  * A mobile navaid, aka. a navaid which can change its position (eg. a mobile
108  * TACAN)
109  */
110 class FGMobileNavRecord:
111   public FGNavRecord
112 {
113   public:
114     FGMobileNavRecord( PositionedID aGuid,
115                        Type type,
116                        const std::string& ident,
117                        const std::string& name,
118                        const SGGeod& aPos,
119                        int freq,
120                        int range,
121                        double multiuse,
122                        PositionedID aRunway );
123
124     virtual const SGGeod& geod() const;
125     virtual const SGVec3d& cart() const;
126
127     void updateVehicle();
128     void updatePos();
129
130   protected:
131     SGTimeStamp _last_vehicle_update;
132     SGPropertyNode_ptr _vehicle_node;
133     double _initial_elevation_ft; // Elevation as given in the config file
134 };
135
136 class FGTACANRecord : public SGReferenced {
137
138     std::string channel;                
139     int freq;
140      
141 public:
142     
143      FGTACANRecord(void);
144     inline ~FGTACANRecord(void) {}
145
146     inline const std::string& get_channel() const { return channel; }
147     inline int get_freq() const { return freq; }
148     friend std::istream& operator>> ( std::istream&, FGTACANRecord& );
149     };
150
151 #endif // _FG_NAVRECORD_HXX