2 // airports.cxx -- a really simplistic class to manage airport ID,
3 // lat, lon of the center of one of it's runways, and
6 // Written by Curtis Olson, started April 1998.
8 // Copyright (C) 1998 Curtis L. Olson - curt@me.umn.edu
10 // This program is free software; you can redistribute it and/or
11 // modify it under the terms of the GNU General Public License as
12 // published by the Free Software Foundation; either version 2 of the
13 // License, or (at your option) any later version.
15 // This program is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // General Public License for more details.
20 // You should have received a copy of the GNU General Public License
21 // along with this program; if not, write to the Free Software
22 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 // (Log is kept at end of this file)
30 #include <Debug/fg_debug.h>
31 #include <Include/fg_zlib.h>
32 #include <Main/options.hxx>
38 fgAIRPORTS::fgAIRPORTS( void ) {
43 int fgAIRPORTS::load( const string& file ) {
45 string path, fgpath, id;
46 char id_raw[256], line[256];
49 // build the path name to the airport file
50 path = current_options.get_fg_root() + "/Airports/" + file;
51 fgpath = path + ".gz";
53 // first try "path.gz"
54 if ( (f = fgopen(fgpath.c_str(), "rb")) == NULL ) {
56 if ( (f = fgopen(path.c_str(), "rb")) == NULL ) {
57 fgPrintf( FG_GENERAL, FG_EXIT, "Cannot open file: %s\n",
62 while ( fggets(f, line, 250) != NULL ) {
63 // printf("%s", line);
65 sscanf( line, "%s %lf %lf %lfl\n", id_raw, &a.longitude, &a.latitude,
77 // search for the specified id
78 fgAIRPORT fgAIRPORTS::search( char *id ) {
79 map < string, fgAIRPORT, less<string> > :: iterator find;
82 find = airports.find(id);
83 if ( find == airports.end() ) {
85 a.longitude = a.latitude = a.elevation = 0;
95 fgAIRPORTS::~fgAIRPORTS( void ) {
100 // Revision 1.3 1998/08/27 17:01:55 curt
101 // Contributions from Bernie Bright <bbright@c031.aone.net.au>
102 // - use strings for fg_root and airport_id and added methods to return
104 // - inlined all access methods,
105 // - made the parsing functions private methods,
106 // - deleted some unused functions.
107 // - propogated some of these changes out a bit further.
109 // Revision 1.2 1998/08/25 20:53:24 curt
110 // Shuffled $FG_ROOT file layout.
112 // Revision 1.1 1998/08/25 17:19:13 curt
113 // Moved from ../Main/
115 // Revision 1.8 1998/07/13 21:01:37 curt
116 // Wrote access functions for current fgOPTIONS.
118 // Revision 1.7 1998/06/03 22:01:07 curt
119 // Tweaking sound library usage.
121 // Revision 1.6 1998/06/03 00:47:13 curt
122 // Updated to compile in audio support if OSS available.
123 // Updated for new version of Steve's audio library.
124 // STL includes don't use .h
125 // Small view optimizations.
127 // Revision 1.5 1998/05/29 20:37:22 curt
128 // Tweaked material properties & lighting a bit in GLUTmain.cxx.
129 // Read airport list into a "map" STL for dynamic list sizing and fast tree
132 // Revision 1.4 1998/05/13 18:26:25 curt
133 // Root path info moved to fgOPTIONS.
135 // Revision 1.3 1998/05/06 03:16:24 curt
136 // Added an averaged global frame rate counter.
137 // Added an option to control tile radius.
139 // Revision 1.2 1998/04/28 21:42:50 curt
140 // Wrapped zlib calls up so we can conditionally comment out zlib support.
142 // Revision 1.1 1998/04/25 15:11:11 curt
143 // Added an command line option to set starting position based on airport ID.