]> git.mxchange.org Git - flightgear.git/blob - utils/GPSsmooth/gps.hxx
FGCom-sa: force console output
[flightgear.git] / utils / GPSsmooth / gps.hxx
1 #ifdef HAVE_CONFIG_H
2 #  include <config.h>
3 #endif
4
5 #include <simgear/compiler.h>
6
7 #include <iostream>
8 #include <string>
9 #include <vector>
10
11 using std::cout;
12 using std::endl;
13 using std::string;
14 using std::vector;
15
16
17 // encapsulate a gps integer time (fixme, assumes all times in a track
18 // are from the same day, so we don't handle midnight roll over)
19 class GPSTime {
20
21 public:
22
23     double seconds;
24
25     inline GPSTime( const int hh, const int mm, const double ss ) {
26         seconds = hh*3600 + mm*60 + ss;
27     }
28     inline GPSTime( const double gpstime ) {
29         double tmp = gpstime;
30         int hh = (int)(tmp / 10000);
31         tmp -= hh * 10000;
32         int mm = (int)(tmp / 100);
33         tmp -= mm * 100;
34         double ss = tmp;
35         seconds = hh*3600 + mm*60 + ss;
36         // cout << gpstime << " = " << seconds << endl;
37     }
38     inline ~GPSTime() {}
39
40     inline double get_time() const { return seconds; }
41     inline double diff_sec( const GPSTime t ) const {
42         return seconds - t.seconds;        
43     }
44 };
45
46
47
48 // encapsulate the interesting gps data for a moment in time
49 class GPSPoint {
50
51 public:
52
53     GPSTime gps_time;
54     double lat_deg;
55     double lon_deg;
56     int fix_quality;
57     int num_satellites;
58     double hdop;
59     double altitude_msl;
60     double speed_kts;
61     double course_true;
62
63     GPSPoint() :
64         gps_time(GPSTime(0,0,0)),
65         lat_deg(0.0),
66         lon_deg(0.0),
67         fix_quality(0),
68         num_satellites(0),
69         hdop(0.0),
70         altitude_msl(0.0),
71         speed_kts(0.0),
72         course_true(0.0)
73     { }
74
75     inline double get_time() const { return gps_time.get_time(); }
76 };
77
78
79 // Manage a saved gps log (track file)
80 class GPSTrack {
81
82 private:
83
84     vector <GPSPoint> data;
85
86 public:
87
88     GPSTrack();
89     ~GPSTrack();
90
91     int load( const string &file );
92
93     inline int size() const { return data.size(); }
94
95     inline GPSPoint get_point( const unsigned int i )
96     {
97         if ( i < data.size() ) {
98             return data[i];
99         } else {
100             return GPSPoint();
101         }
102     }
103         
104
105 };
106
107
108 GPSPoint GPSInterpolate( const GPSPoint A, const GPSPoint B,
109                          const double percent );