1 // navdb.cxx -- top level navaids management routines
3 // Written by Curtis Olson, started May 2004.
5 // Copyright (C) 2004 Curtis L. Olson - curt@flightgear.org
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include <simgear/debug/logstream.hxx>
26 #include <Main/globals.hxx>
28 #include "navrecord.hxx"
33 // load and initialize the navigational databases
34 bool fgNavDBInit( FGNavList *navlist, FGNavList *loclist, FGNavList *gslist,
35 FGNavList *dmelist, FGNavList *mkrlist )
37 SG_LOG(SG_GENERAL, SG_INFO, "Loading Navaid Databases");
38 // SG_LOG(SG_GENERAL, SG_INFO, " VOR/NDB");
39 // SGPath p_nav( globals->get_fg_root() );
40 // p_nav.append( "Navaids/default.nav" );
41 // navlist->init( p_nav );
43 // SG_LOG(SG_GENERAL, SG_INFO, " ILS and Marker Beacons");
45 // SGPath p_ils( globals->get_fg_root() );
46 // p_ils.append( "Navaids/default.ils" );
47 // ilslist->init( p_ils );
50 SGPath path( globals->get_fg_root() );
51 path.append( "Navaids/nav.dat" );
53 sg_gzifstream in( path.str() );
54 if ( !in.is_open() ) {
55 SG_LOG( SG_GENERAL, SG_ALERT, "Cannot open file: " << path.str() );
59 // skip first two lines
66 while ( in.get(c) && c != '\0' ) {
69 while ( ! in.eof() ) {
72 FGNavRecord *r = new FGNavRecord;
74 if ( r->get_type() > 95 ) {
78 /* cout << "id = " << n.get_ident() << endl;
79 cout << " type = " << n.get_type() << endl;
80 cout << " lon = " << n.get_lon() << endl;
81 cout << " lat = " << n.get_lat() << endl;
82 cout << " elev = " << n.get_elev() << endl;
83 cout << " freq = " << n.get_freq() << endl;
84 cout << " range = " << n.get_range() << endl << endl; */
86 if ( r->get_type() == 2 || r->get_type() == 3 ) {
89 } else if ( r->get_type() == 4 || r->get_type() == 5 ) {
92 } else if ( r->get_type() == 6 ) {
95 } else if ( r->get_type() == 7 || r->get_type() == 8
96 || r->get_type() == 9 )
98 // Marker Beacon = 7,8,9
100 } else if ( r->get_type() == 12 ) {
108 // cout << "min freq = " << min << endl;
109 // cout << "max freq = " << max << endl;