]> git.mxchange.org Git - flightgear.git/blob - Simulator/Airports/simple.hxx
Initial revision
[flightgear.git] / Simulator / Airports / simple.hxx
1 //
2 // simple.hxx -- a really simplistic class to manage airport ID,
3 //                 lat, lon of the center of one of it's runways, and 
4 //                 elevation in feet.
5 //
6 // Written by Curtis Olson, started April 1998.
7 //
8 // Copyright (C) 1998  Curtis L. Olson  - curt@me.umn.edu
9 //
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.
14 //
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.
19 //
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.
23 //
24 // $Id$
25 // (Log is kept at end of this file)
26
27
28 #ifndef _AIRPORTS_HXX
29 #define _AIRPORTS_HXX
30
31
32 #ifndef __cplusplus                                                          
33 # error This library requires C++
34 #endif                                   
35
36
37 #include <Include/compiler.h>
38 #ifdef FG_HAVE_STD_INCLUDES
39 #  include <istream>
40 #else
41 #  include <istream.h>
42 #endif
43
44 #include STL_STRING
45 #include <set>
46
47 FG_USING_STD(string);
48 FG_USING_STD(set);
49 FG_USING_STD(istream);
50
51
52 class fgAIRPORT {
53 public:
54     fgAIRPORT( const string& name = "",
55                double lon = 0.0,
56                double lat = 0.0,
57                double ele = 0.0 )
58         : id(name), longitude(lon), latitude(lat), elevation(ele) {}
59
60     bool operator < ( const fgAIRPORT& a ) const {
61         return id < a.id;
62     }
63
64 public:
65     string id;
66     double longitude;
67     double latitude;
68     double elevation;
69 };
70
71 inline istream&
72 operator >> ( istream& in, fgAIRPORT& a )
73 {
74     return in >> a.id >> a.longitude >> a.latitude >> a.elevation;
75 }
76
77 class fgAIRPORTS {
78 public:
79 #ifdef FG_NO_DEFAULT_TEMPLATE_ARGS
80     typedef set< fgAIRPORT, less< fgAIRPORT > > container;
81 #else
82     typedef set< fgAIRPORT > container;
83 #endif
84     typedef container::iterator iterator;
85     typedef container::const_iterator const_iterator;
86
87 private:
88     container airports;
89
90 public:
91
92     // Constructor
93     fgAIRPORTS();
94
95     // Destructor
96     ~fgAIRPORTS();
97
98     // load the data
99     int load( const string& file );
100
101     // search for the specified id.
102     // Returns true if successful, otherwise returns false.
103     // On success, airport data is returned thru "airport" pointer.
104     // "airport" is not changed if "id" is not found.
105     bool search( const string& id, fgAIRPORT* airport ) const;
106     fgAIRPORT search( const string& id ) const;
107 };
108
109
110 #endif /* _AIRPORTS_HXX */
111
112
113 // $Log$
114 // Revision 1.1  1999/04/05 21:32:47  curt
115 // Initial revision
116 //
117 // Revision 1.8  1999/03/15 17:58:57  curt
118 // MSVC++ portability tweaks contributed by Bernie Bright.
119 //   Added using std::istream declaration.
120 //
121 // Revision 1.7  1999/03/02 01:02:33  curt
122 // Tweaks for building with native SGI compilers.
123 //
124 // Revision 1.6  1999/02/26 22:08:36  curt
125 // Added initial support for native SGI compilers.
126 //
127 // Revision 1.5  1998/11/02 18:25:34  curt
128 // Check for __CYGWIN__ (b20) as well as __CYGWIN32__ (pre b20 compilers)
129 // Other misc. tweaks.
130 //
131 // Revision 1.4  1998/09/08 21:38:43  curt
132 // Changes by Bernie Bright.
133 //
134 // Revision 1.3  1998/09/01 19:02:54  curt
135 // Changes contributed by Bernie Bright <bbright@c031.aone.net.au>
136 //  - The new classes in libmisc.tgz define a stream interface into zlib.
137 //    I've put these in a new directory, Lib/Misc.  Feel free to rename it
138 //    to something more appropriate.  However you'll have to change the
139 //    include directives in all the other files.  Additionally you'll have
140 //    add the library to Lib/Makefile.am and Simulator/Main/Makefile.am.
141 //
142 //    The StopWatch class in Lib/Misc requires a HAVE_GETRUSAGE autoconf
143 //    test so I've included the required changes in config.tgz.
144 //
145 //    There are a fair few changes to Simulator/Objects as I've moved
146 //    things around.  Loading tiles is quicker but thats not where the delay
147 //    is.  Tile loading takes a few tenths of a second per file on a P200
148 //    but it seems to be the post-processing that leads to a noticeable
149 //    blip in framerate.  I suppose its time to start profiling to see where
150 //    the delays are.
151 //
152 //    I've included a brief description of each archives contents.
153 //
154 // Lib/Misc/
155 //   zfstream.cxx
156 //   zfstream.hxx
157 //     C++ stream interface into zlib.
158 //     Taken from zlib-1.1.3/contrib/iostream/.
159 //     Minor mods for STL compatibility.
160 //     There's no copyright associated with these so I assume they're
161 //     covered by zlib's.
162 //
163 //   fgstream.cxx
164 //   fgstream.hxx
165 //     FlightGear input stream using gz_ifstream.  Tries to open the
166 //     given filename.  If that fails then filename is examined and a
167 //     ".gz" suffix is removed or appended and that file is opened.
168 //
169 //   stopwatch.hxx
170 //     A simple timer for benchmarking.  Not used in production code.
171 //     Taken from the Blitz++ project.  Covered by GPL.
172 //
173 //   strutils.cxx
174 //   strutils.hxx
175 //     Some simple string manipulation routines.
176 //
177 // Simulator/Airports/
178 //   Load airports database using fgstream.
179 //   Changed fgAIRPORTS to use set<> instead of map<>.
180 //   Added bool fgAIRPORTS::search() as a neater way doing the lookup.
181 //   Returns true if found.
182 //
183 // Simulator/Astro/
184 //   Modified fgStarsInit() to load stars database using fgstream.
185 //
186 // Simulator/Objects/
187 //   Modified fgObjLoad() to use fgstream.
188 //   Modified fgMATERIAL_MGR::load_lib() to use fgstream.
189 //   Many changes to fgMATERIAL.
190 //   Some changes to fgFRAGMENT but I forget what!
191 //
192 // Revision 1.2  1998/08/27 17:01:56  curt
193 // Contributions from Bernie Bright <bbright@c031.aone.net.au>
194 // - use strings for fg_root and airport_id and added methods to return
195 //   them as strings,
196 // - inlined all access methods,
197 // - made the parsing functions private methods,
198 // - deleted some unused functions.
199 // - propogated some of these changes out a bit further.
200 //
201 // Revision 1.1  1998/08/25 17:19:14  curt
202 // Moved from ../Main/
203 //
204 // Revision 1.7  1998/07/24 21:39:09  curt
205 // Debugging output tweaks.
206 // Cast glGetString to (char *) to avoid compiler errors.
207 // Optimizations to fgGluLookAt() by Norman Vine.
208 //
209 // Revision 1.6  1998/07/06 21:34:19  curt
210 // Added an enable/disable splash screen option.
211 // Added an enable/disable intro music option.
212 // Added an enable/disable instrument panel option.
213 // Added an enable/disable mouse pointer option.
214 // Added using namespace std for compilers that support this.
215 //
216 // Revision 1.5  1998/06/17 21:35:11  curt
217 // Refined conditional audio support compilation.
218 // Moved texture parameter setup calls to ../Scenery/materials.cxx
219 // #include <string.h> before various STL includes.
220 // Make HUD default state be enabled.
221 //
222 // Revision 1.4  1998/06/03 00:47:14  curt
223 // Updated to compile in audio support if OSS available.
224 // Updated for new version of Steve's audio library.
225 // STL includes don't use .h
226 // Small view optimizations.
227 //
228 // Revision 1.3  1998/06/01 17:54:42  curt
229 // Added Linux audio support.
230 // avoid glClear( COLOR_BUFFER_BIT ) when not using it to set the sky color.
231 // map stl tweaks.
232 //
233 // Revision 1.2  1998/05/29 20:37:22  curt
234 // Tweaked material properties & lighting a bit in GLUTmain.cxx.
235 // Read airport list into a "map" STL for dynamic list sizing and fast tree
236 // based lookups.
237 //
238 // Revision 1.1  1998/04/25 15:11:11  curt
239 // Added an command line option to set starting position based on airport ID.
240 //
241 //