1 // Written by James Turner, started 2009.
3 // Copyright (C) 2009 Curtis L. Olson
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.
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.
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.
19 #include <simgear/misc/sg_path.hxx>
21 #include "fixlist.hxx"
22 #include "ilslist.hxx"
23 #include "navlist.hxx"
24 #include "mkrbeacons.hxx"
27 const string FG_DATA_DIR("/usr/local/lib/FlightGear");
32 FGNavList *current_navlist = new FGNavList;
33 SGPath p_nav( FG_DATA_DIR + "/Navaids/default.nav" );
35 current_navlist->init( p_nav );
38 if ( (n = current_navlist->findByFreq( -93.2 * SG_DEGREES_TO_RADIANS,
39 45.14 * SG_DEGREES_TO_RADIANS,
40 3000, 117.30)) != NULL )
42 cout << "Found a vor station in range" << endl;
43 cout << " id = " << n->get_ident() << endl;
45 cout << "not picking up vor. :-(" << endl;
49 if ( (dcs = current_navlist->findByIdent( "DCS",
50 -3.3 * SG_DEGREES_TO_RADIANS,
51 55.9 * SG_DEGREES_TO_RADIANS))
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;
59 cout << "couldn't locate DCS (Dean-Cross) VOR" << endl;
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();
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,
73 cout << "Found an ils station in range" << endl;
74 cout << " apt = " << i->get_aptcode() << endl;
75 cout << " rwy = " << i->get_rwyno() << endl;
77 cout << "not picking up ils. :-(" << endl;
80 FGFixList *current_fixlist = new FGFixList;
81 SGPath p_fix( FG_DATA_DIR + "/Navaids/default.fix" );
82 current_fixlist->init( p_fix );
85 // attempting to get the position relative to the OTR VOR; heading
86 // should be 108 degrees, distance 74nm (according to my SimCharts
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) )
93 cout << "Found a matching fix" << endl;
94 cout << " id = " << fix.get_ident() << endl;
95 cout << " heading = " << heading << " dist = " << dist * SG_METER_TO_NM
98 cout << "did not find fix. :-(" << endl;