]> git.mxchange.org Git - flightgear.git/blob - src/Navaids/testnavs.cxx
Rename FGMarkerBeacon to FGMarkerBeacon record, to avoid a clash with the
[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     FGNavList *current_navlist = new FGNavList;
15     SGPath p_nav( FG_DATA_DIR + "/Navaids/default.nav" );
16
17     current_navlist->init( p_nav );
18         
19     FGNavRecord *n;
20     if ( (n = current_navlist->findByFreq( -93.2 * SG_DEGREES_TO_RADIANS,
21                                            45.14 * SG_DEGREES_TO_RADIANS,
22                                            3000, 117.30)) != NULL )
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     FGNavRecord *dcs;
31     if ( (dcs = current_navlist->findByIdent( "DCS",
32                                               -3.3 * SG_DEGREES_TO_RADIANS,
33                                               55.9 * SG_DEGREES_TO_RADIANS))
34          != NULL ) {
35                                                 
36         cout << "Found DCS by ident" << endl;
37         if (dcs->get_freq() != 11520)
38             cout << "Frequency for DCS VOR is wrong (should be 115.20), it's " 
39                  << dcs->get_freq() << endl;
40     } else {
41         cout << "couldn't locate DCS (Dean-Cross) VOR" << endl;
42     }
43         
44     // we have to init the marker beacon storage before we parse the ILS file
45     FGMarkerBeacons *current_beacons = new FGMarkerBeacons;
46     current_beacons->init();
47         
48     FGILSList *current_ilslist = new FGILSList;
49     SGPath p_ils( FG_DATA_DIR + "/Navaids/default.ils" );
50     current_ilslist->init( p_ils );
51     FGILS *i = current_ilslist->findByFreq( -93.1 * SG_DEGREES_TO_RADIANS,
52                                             45.24 * SG_DEGREES_TO_RADIANS,
53                                             3000, 110.30);
54     if ( i != NULL ) {
55         cout << "Found an ils station in range" << endl;
56         cout << " apt = " << i->get_aptcode() << endl;
57         cout << " rwy = " << i->get_rwyno() << endl;
58     } else {
59         cout << "not picking up ils. :-(" << endl;
60     }
61
62     FGFixList *current_fixlist = new FGFixList;
63     SGPath p_fix( FG_DATA_DIR + "/Navaids/default.fix" );
64     current_fixlist->init( p_fix );
65     FGFix fix;
66         
67     // attempting to get the position relative to the OTR VOR; heading
68     // should be 108 degrees, distance 74nm (according to my SimCharts
69     // v1.5)
70     if ( current_fixlist->query_and_offset( "DOGGA",
71                                             -0.103 * SG_DEGREES_TO_RADIANS,
72                                             53.698 * SG_DEGREES_TO_RADIANS,
73                                             3000, &fix, &heading, &dist) )
74     {
75         cout << "Found a matching fix" << endl;
76         cout << " id = " << fix.get_ident() << endl;
77         cout << " heading = " << heading << " dist = " << dist * SG_METER_TO_NM
78              << endl;
79     } else {
80         cout << "did not find fix. :-(" << endl;
81     }
82 }