1 // atis.hxx -- ATIS class
3 // Written by Curtis Olson, started April 2000.
5 // Copyright (C) 2000 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.
27 #include <simgear/compiler.h>
28 #include <simgear/math/sg_geodesy.hxx>
29 #include <simgear/misc/sgstream.hxx>
30 #include <simgear/magvar/magvar.hxx>
31 #include <simgear/timing/sg_time.hxx>
33 #ifdef SG_HAVE_STD_INCLUDES
36 #elif defined( SG_HAVE_NATIVE_SGI_COMPILERS )
37 # include <iostream.h>
38 #elif defined( __BORLANDC__ )
45 #if ! defined( SG_HAVE_NATIVE_SGI_COMPILERS )
46 SG_USING_STD(istream);
53 //DCL - a complete guess for now.
54 #define FG_ATIS_DEFAULT_RANGE 30
64 string ident; // Code of the airport its at.
65 string name; // Name transmitted in the broadcast.
66 string info; // The actual ATIS transmission
67 // This is not stored in default.atis but is generated
68 // from the prevailing conditions when required.
70 // for failure modeling
71 string trans_ident; // transmitted ident
72 bool atis_failed; // atis failed?
79 inline char get_type() const { return type; }
80 inline double get_lon() const { return lon; }
81 inline double get_lat() const { return lat; }
82 inline double get_elev() const { return elev; }
83 inline double get_x() const { return x; }
84 inline double get_y() const { return y; }
85 inline double get_z() const { return z; }
86 inline int get_freq() const { return freq; }
87 inline int get_range() const { return range; }
88 inline const char *get_ident() { return ident.c_str(); }
89 inline string get_trans_ident() { return trans_ident; }
90 string get_transmission(void);
91 // void get_transmission();
93 /* inline void set_type( char t ) { type = t; }
94 inline void set_lon( double l ) { lon = l; }
95 inline void set_lat( double l ) { lat = l; }
96 inline void set_elev( double e ) { elev = e; }
97 inline void set_freq( int f ) { freq = f; }
98 inline void set_range( int r ) { range = r; }
99 inline void set_dme( bool b ) { dme = b; }
100 inline void set_ident( char *i ) { strncpy( ident, i, 5 ); } */
102 friend istream& operator>> ( istream&, FGATIS& );
107 operator >> ( istream& in, FGATIS& a )
112 static bool first_time = true;
113 static double julian_date = 0;
114 static const double MJD0 = 2415020.0;
116 julian_date = sgTimeCurrentMJD(0, 0) + MJD0;
123 return in >> skipeol;
125 in >> a.lat >> a.lon >> a.elev >> f >> a.range
133 in.unsetf(ios::skipws);
136 if((ch == '"') || (ch == 0x0A)) {
138 } // we shouldn't need the 0x0A but it makes a nice safely in case someone leaves off the "
140 in.setf(ios::skipws);
141 //cout << "atis.name = " << a.name << '\n';
143 a.freq = (int)(f*100.0 + 0.5);
145 // cout << a.ident << endl;
147 // generate cartesian coordinates
148 Point3D geod( a.lon * SGD_DEGREES_TO_RADIANS, a.lat * SGD_DEGREES_TO_RADIANS, a.elev );
149 Point3D cart = sgGeodToCart( geod );
154 a.trans_ident = a.ident;
155 a.atis_failed = false;
157 return in >> skipeol;
160 #endif // _FG_ATIS_HXX