]> git.mxchange.org Git - flightgear.git/blobdiff - src/Navaids/nav.hxx
Moved some of the low level scene graph construction code over to simgear.
[flightgear.git] / src / Navaids / nav.hxx
index de9f28d0bd57ff05dba6314deea36620a38e3a3c..2bfff9f1e85db8b3e641841201191b3d46e33887 100644 (file)
 
 #include <simgear/compiler.h>
 #include <simgear/math/sg_geodesy.hxx>
-#include <simgear/misc/fgstream.hxx>
+#include <simgear/misc/sgstream.hxx>
 #include <simgear/magvar/magvar.hxx>
 #include <simgear/timing/sg_time.hxx>
 
 #ifdef SG_HAVE_STD_INCLUDES
 #  include <istream>
-#elif defined( SG_HAVE_NATIVE_SGI_COMPILERS )
-#  include <iostream.h>
-#elif defined( __BORLANDC__ )
+#elif defined( __BORLANDC__ ) || (__APPLE__)
 #  include <iostream>
 #else
 #  include <istream.h>
 #endif
 
-#if ! defined( SG_HAVE_NATIVE_SGI_COMPILERS )
 SG_USING_STD(istream);
-#endif
 
 
 class FGNav {
@@ -66,7 +62,7 @@ class FGNav {
 
 public:
 
-    inline FGNav(void) {}
+    inline FGNav(void);
     inline ~FGNav(void) {}
 
     inline char get_type() const { return type; }
@@ -83,19 +79,28 @@ public:
     inline string get_trans_ident() { return trans_ident; }
     inline double get_magvar () const { return magvar; }
 
-    /* inline void set_type( char t ) { type = t; }
-    inline void set_lon( double l ) { lon = l; }
-    inline void set_lat( double l ) { lat = l; }
-    inline void set_elev( double e ) { elev = e; }
-    inline void set_freq( int f ) { freq = f; }
-    inline void set_range( int r ) { range = r; }
-    inline void set_dme( bool b ) { dme = b; }
-    inline void set_ident( char *i ) { strncpy( ident, i, 5 ); } */
-
     friend istream& operator>> ( istream&, FGNav& );
 };
 
 
+inline
+FGNav::FGNav(void) :
+    type(0),
+    lon(0.0), lat(0.0),
+    elev(0.0),
+    x(0.0), y(0.0), z(0.0),
+    freq(0),
+    range(0),
+    has_dme(false),
+    ident(""),
+    magvar(0.0),
+    trans_ident(""),
+    nav_failed(false),
+    dme_failed(false)
+{
+}
+
+
 inline istream&
 operator >> ( istream& in, FGNav& n )
 {
@@ -103,16 +108,20 @@ operator >> ( istream& in, FGNav& n )
     char c /* , magvar_dir */ ;
     string magvar_s;
 
-    static SGTime time_params;
     static bool first_time = true;
     static double julian_date = 0;
+    static const double MJD0    = 2415020.0;
     if ( first_time ) {
-       time_params.update( 0.0, 0.0, 0 );
-       julian_date = time_params.getJD();
+       julian_date = sgTimeCurrentMJD(0,0) + MJD0;
        first_time = false;
     }
 
-    in >> n.type >> n.lat >> n.lon >> n.elev >> f >> n.range 
+    in >> n.type;
+    
+    if ( n.type == '[' )
+      return in >> skipeol;
+
+    in >> n.lat >> n.lon >> n.elev >> f >> n.range 
        >> c >> n.ident >> magvar_s;
 
     n.freq = (int)(f*100.0 + 0.5);
@@ -129,9 +138,11 @@ operator >> ( istream& in, FGNav& n )
        // cout << "lat = " << n.lat << " lon = " << n.lon << " elev = " 
        //      << n.elev << " JD = " 
        //      << julian_date << endl;
-       n.magvar = sgGetMagVar(n.lon * SGD_DEGREES_TO_RADIANS, n.lat * SGD_DEGREES_TO_RADIANS,
-                               n.elev * SG_FEET_TO_METER,
-                               julian_date) * SGD_RADIANS_TO_DEGREES;
+       n.magvar = sgGetMagVar( n.lon * SGD_DEGREES_TO_RADIANS,
+                                n.lat * SGD_DEGREES_TO_RADIANS,
+                                n.elev * SG_FEET_TO_METER,
+                                julian_date )
+            * SGD_RADIANS_TO_DEGREES;
        // cout << "Default variation at " << n.lon << ',' << n.lat
        //      << " is " << var << endl;
 #if 0