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