]> git.mxchange.org Git - flightgear.git/blob - src/Airports/simple.hxx
UIUC flight model contribution. This is based on LaRCsim, but can read
[flightgear.git] / src / 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
26
27 #ifndef _AIRPORTS_HXX
28 #define _AIRPORTS_HXX
29
30
31 #ifndef __cplusplus                                                          
32 # error This library requires C++
33 #endif                                   
34
35
36 #include <simgear/compiler.h>
37
38 #ifdef FG_HAVE_STD_INCLUDES
39 #  include <istream>
40 #elif defined( FG_HAVE_NATIVE_SGI_COMPILERS )
41 #  include <iostream.h>
42 #elif defined( __BORLANDC__ )
43 #  include <iostream>
44 #else
45 #  include <istream.h>
46 #endif
47
48 #include STL_STRING
49 #include <set>
50
51 FG_USING_STD(string);
52 FG_USING_STD(set);
53
54 #if ! defined( FG_HAVE_NATIVE_SGI_COMPILERS )
55 FG_USING_STD(istream);
56 #endif
57
58
59 class fgAIRPORT {
60 public:
61     fgAIRPORT( const string& name = "",
62                double lon = 0.0,
63                double lat = 0.0,
64                double ele = 0.0 )
65         : id(name), longitude(lon), latitude(lat), elevation(ele) {}
66
67     bool operator < ( const fgAIRPORT& a ) const {
68         return id < a.id;
69     }
70
71 public:
72     string id;
73     double longitude;
74     double latitude;
75     double elevation;
76 };
77
78 inline istream&
79 operator >> ( istream& in, fgAIRPORT& a )
80 {
81     return in >> a.id >> a.longitude >> a.latitude >> a.elevation;
82 }
83
84 class fgAIRPORTS {
85 public:
86 #ifdef FG_NO_DEFAULT_TEMPLATE_ARGS
87     typedef set< fgAIRPORT, less< fgAIRPORT > > container;
88 #else
89     typedef set< fgAIRPORT > container;
90 #endif
91     typedef container::iterator iterator;
92     typedef container::const_iterator const_iterator;
93
94 private:
95     container airports;
96
97 public:
98
99     // Constructor
100     fgAIRPORTS();
101
102     // Destructor
103     ~fgAIRPORTS();
104
105     // load the data
106     int load( const string& file );
107
108     // search for the specified id.
109     // Returns true if successful, otherwise returns false.
110     // On success, airport data is returned thru "airport" pointer.
111     // "airport" is not changed if "id" is not found.
112     bool search( const string& id, fgAIRPORT* airport ) const;
113     fgAIRPORT search( const string& id ) const;
114 };
115
116
117 #endif /* _AIRPORTS_HXX */
118
119