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>
34 #include "airports.hxx"
38 fgAIRPORTS::fgAIRPORTS( void ) {
43 int fgAIRPORTS::load( char *file ) {
45 char path[256], fgpath[256], line[256];
50 // build the path name to the airport file
51 current_options.get_fg_root(path);
52 strcat(path, "/Scenery/");
53 strcat(path, "Airports");
55 strcat(fgpath, ".gz");
57 // first try "path.gz"
58 if ( (f = fgopen(fgpath, "rb")) == NULL ) {
60 if ( (f = fgopen(path, "rb")) == NULL ) {
61 fgPrintf(FG_GENERAL, FG_EXIT, "Cannot open file: %s\n", path);
65 while ( fggets(f, line, 250) != NULL ) {
66 // printf("%s", line);
68 sscanf( line, "%s %lf %lf %lfl\n", id, &a.longitude, &a.latitude,
80 // search for the specified id
81 fgAIRPORT fgAIRPORTS::search( char *id ) {
82 map < string, fgAIRPORT, less<string> > :: iterator find;
85 find = airports.find(id);
86 if ( find == airports.end() ) {
88 a.longitude = a.latitude = a.elevation = 0;
98 fgAIRPORTS::~fgAIRPORTS( void ) {
103 // Revision 1.8 1998/07/13 21:01:37 curt
104 // Wrote access functions for current fgOPTIONS.
106 // Revision 1.7 1998/06/03 22:01:07 curt
107 // Tweaking sound library usage.
109 // Revision 1.6 1998/06/03 00:47:13 curt
110 // Updated to compile in audio support if OSS available.
111 // Updated for new version of Steve's audio library.
112 // STL includes don't use .h
113 // Small view optimizations.
115 // Revision 1.5 1998/05/29 20:37:22 curt
116 // Tweaked material properties & lighting a bit in GLUTmain.cxx.
117 // Read airport list into a "map" STL for dynamic list sizing and fast tree
120 // Revision 1.4 1998/05/13 18:26:25 curt
121 // Root path info moved to fgOPTIONS.
123 // Revision 1.3 1998/05/06 03:16:24 curt
124 // Added an averaged global frame rate counter.
125 // Added an option to control tile radius.
127 // Revision 1.2 1998/04/28 21:42:50 curt
128 // Wrapped zlib calls up so we can conditionally comment out zlib support.
130 // Revision 1.1 1998/04/25 15:11:11 curt
131 // Added an command line option to set starting position based on airport ID.