]> git.mxchange.org Git - flightgear.git/blob - src/Navaids/testnavs.cxx
PLIB net removed from FlightGear
[flightgear.git] / src / Navaids / testnavs.cxx
1 // Written by James Turner, started 2009.
2 //
3 // Copyright (C) 2009  Curtis L. Olson
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License as
7 // published by the Free Software Foundation; either version 2 of the
8 // License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful, but
11 // WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 // General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18
19 #include <simgear/misc/sg_path.hxx>
20
21 #include "fixlist.hxx"
22 #include "ilslist.hxx"
23 #include "navlist.hxx"
24 #include "mkrbeacons.hxx"
25
26 // change this!
27 const string FG_DATA_DIR("/usr/local/lib/FlightGear");
28
29 int main() {
30     double heading, dist;
31
32     FGNavList *current_navlist = new FGNavList;
33     SGPath p_nav( FG_DATA_DIR + "/Navaids/default.nav" );
34
35     current_navlist->init( p_nav );
36         
37     FGNavRecord *n;
38     if ( (n = current_navlist->findByFreq( -93.2 * SG_DEGREES_TO_RADIANS,
39                                            45.14 * SG_DEGREES_TO_RADIANS,
40                                            3000, 117.30)) != NULL )
41     {
42         cout << "Found a vor station in range" << endl;
43         cout << " id = " << n->get_ident() << endl;
44     } else {
45         cout << "not picking up vor. :-(" << endl;
46     }
47
48     FGNavRecord *dcs;
49     if ( (dcs = current_navlist->findByIdent( "DCS",
50                                               -3.3 * SG_DEGREES_TO_RADIANS,
51                                               55.9 * SG_DEGREES_TO_RADIANS))
52          != NULL ) {
53                                                 
54         cout << "Found DCS by ident" << endl;
55         if (dcs->get_freq() != 11520)
56             cout << "Frequency for DCS VOR is wrong (should be 115.20), it's " 
57                  << dcs->get_freq() << endl;
58     } else {
59         cout << "couldn't locate DCS (Dean-Cross) VOR" << endl;
60     }
61         
62     // we have to init the marker beacon storage before we parse the ILS file
63     FGMarkerBeacons *current_beacons = new FGMarkerBeacons;
64     current_beacons->init();
65         
66     FGILSList *current_ilslist = new FGILSList;
67     SGPath p_ils( FG_DATA_DIR + "/Navaids/default.ils" );
68     current_ilslist->init( p_ils );
69     FGILS *i = current_ilslist->findByFreq( -93.1 * SG_DEGREES_TO_RADIANS,
70                                             45.24 * SG_DEGREES_TO_RADIANS,
71                                             3000, 110.30);
72     if ( i != NULL ) {
73         cout << "Found an ils station in range" << endl;
74         cout << " apt = " << i->get_aptcode() << endl;
75         cout << " rwy = " << i->get_rwyno() << endl;
76     } else {
77         cout << "not picking up ils. :-(" << endl;
78     }
79
80     FGFixList *current_fixlist = new FGFixList;
81     SGPath p_fix( FG_DATA_DIR + "/Navaids/default.fix" );
82     current_fixlist->init( p_fix );
83     FGFix fix;
84         
85     // attempting to get the position relative to the OTR VOR; heading
86     // should be 108 degrees, distance 74nm (according to my SimCharts
87     // v1.5)
88     if ( current_fixlist->query_and_offset( "DOGGA",
89                                             -0.103 * SG_DEGREES_TO_RADIANS,
90                                             53.698 * SG_DEGREES_TO_RADIANS,
91                                             3000, &fix, &heading, &dist) )
92     {
93         cout << "Found a matching fix" << endl;
94         cout << " id = " << fix.get_ident() << endl;
95         cout << " heading = " << heading << " dist = " << dist * SG_METER_TO_NM
96              << endl;
97     } else {
98         cout << "did not find fix. :-(" << endl;
99     }
100 }