]> git.mxchange.org Git - flightgear.git/blob - src/Navaids/testnavs.cxx
James Turner:
[flightgear.git] / src / Navaids / testnavs.cxx
1 #include <simgear/misc/sg_path.hxx>
2
3 #include "fixlist.hxx"
4 #include "ilslist.hxx"
5 #include "navlist.hxx"
6 #include "mkrbeacons.hxx"
7
8 // change this!
9 const string FG_DATA_DIR("/usr/local/lib/FlightGear");
10
11 int main() {
12     double heading, dist;
13
14     current_navlist = new FGNavList;
15     SGPath p_nav( FG_DATA_DIR + "/Navaids/default.nav" );
16
17     current_navlist->init( p_nav );
18         
19     FGNav n;
20     if ( current_navlist->query( -93.2 * SG_DEGREES_TO_RADIANS,
21                                  45.14 * SG_DEGREES_TO_RADIANS,
22                                  3000, 117.30, &n) )
23     {
24         cout << "Found a vor station in range" << endl;
25         cout << " id = " << n.get_ident() << endl;
26     } else {
27         cout << "not picking up vor. :-(" << endl;
28     }
29
30     FGNav dcs;
31     if (current_navlist->findByIdent("DCS", -3.3 * SG_DEGREES_TO_RADIANS,
32                                      55.9 * SG_DEGREES_TO_RADIANS, &dcs)) {
33                                                 
34         cout << "Found DCS by ident" << endl;
35         if (dcs.get_freq() != 11520)
36             cout << "Frequency for DCS VOR is wrong (should be 115.20), it's " 
37                  << dcs.get_freq() << endl;
38     } else {
39         cout << "couldn't locate DCS (Dean-Cross) VOR" << endl;
40     }
41         
42     // we have to init the marker beacon storage before we parse the ILS file
43     current_beacons = new FGMarkerBeacons;
44     current_beacons->init();
45         
46     current_ilslist = new FGILSList;
47     SGPath p_ils( FG_DATA_DIR + "/Navaids/default.ils" );
48     current_ilslist->init( p_ils );
49     FGILS i;
50     if ( current_ilslist->query( -93.1 * SG_DEGREES_TO_RADIANS,
51                                  45.24 * SG_DEGREES_TO_RADIANS,
52                                  3000, 110.30, &i) )
53     {
54         cout << "Found an ils station in range" << endl;
55         cout << " apt = " << i.get_aptcode() << endl;
56         cout << " rwy = " << i.get_rwyno() << endl;
57     } else {
58         cout << "not picking up ils. :-(" << endl;
59     }
60
61     current_fixlist = new FGFixList;
62     SGPath p_fix( FG_DATA_DIR + "/Navaids/default.fix" );
63     current_fixlist->init( p_fix );
64     FGFix fix;
65         
66     // attempting to get the position relative to the OTR VOR; heading
67     // should be 108 degrees, distance 74nm (according to my SimCharts
68     // v1.5)
69     if ( current_fixlist->query( "DOGGA", -0.103 * SG_DEGREES_TO_RADIANS,
70                                  53.698 * SG_DEGREES_TO_RADIANS, 3000,
71                                  &fix, &heading, &dist) )
72     {
73         cout << "Found a matching fix" << endl;
74         cout << " id = " << fix.get_ident() << endl;
75         cout << " heading = " << heading << " dist = " << dist * SG_METER_TO_NM
76              << endl;
77     } else {
78         cout << "did not find fix. :-(" << endl;
79     }
80 }