]> 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
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 <Include/compiler.h>
37 #ifdef FG_HAVE_STD_INCLUDES
38 #  include <istream>
39 #else
40 #  include <istream.h>
41 #endif
42
43 #include STL_STRING
44 #include <set>
45
46 FG_USING_STD(string);
47 FG_USING_STD(set);
48 FG_USING_STD(istream);
49
50
51 class fgAIRPORT {
52 public:
53     fgAIRPORT( const string& name = "",
54                double lon = 0.0,
55                double lat = 0.0,
56                double ele = 0.0 )
57         : id(name), longitude(lon), latitude(lat), elevation(ele) {}
58
59     bool operator < ( const fgAIRPORT& a ) const {
60         return id < a.id;
61     }
62
63 public:
64     string id;
65     double longitude;
66     double latitude;
67     double elevation;
68 };
69
70 inline istream&
71 operator >> ( istream& in, fgAIRPORT& a )
72 {
73     return in >> a.id >> a.longitude >> a.latitude >> a.elevation;
74 }
75
76 class fgAIRPORTS {
77 public:
78 #ifdef FG_NO_DEFAULT_TEMPLATE_ARGS
79     typedef set< fgAIRPORT, less< fgAIRPORT > > container;
80 #else
81     typedef set< fgAIRPORT > container;
82 #endif
83     typedef container::iterator iterator;
84     typedef container::const_iterator const_iterator;
85
86 private:
87     container airports;
88
89 public:
90
91     // Constructor
92     fgAIRPORTS();
93
94     // Destructor
95     ~fgAIRPORTS();
96
97     // load the data
98     int load( const string& file );
99
100     // search for the specified id.
101     // Returns true if successful, otherwise returns false.
102     // On success, airport data is returned thru "airport" pointer.
103     // "airport" is not changed if "id" is not found.
104     bool search( const string& id, fgAIRPORT* airport ) const;
105     fgAIRPORT search( const string& id ) const;
106 };
107
108
109 #endif /* _AIRPORTS_HXX */
110
111