]> git.mxchange.org Git - flightgear.git/blob - src/Airports/simple.hxx
Melchior FRANZ:
[flightgear.git] / src / Airports / simple.hxx
1 // simple.hxx -- a really simplistic class to manage airport ID,
2 //                 lat, lon of the center of one of it's runways, and 
3 //                 elevation in feet.
4 //
5 // Written by Curtis Olson, started April 1998.
6 //
7 // Copyright (C) 1998  Curtis L. Olson  - http://www.flightgear.org/~curt
8 //
9 // This program is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU General Public License as
11 // published by the Free Software Foundation; either version 2 of the
12 // License, or (at your option) any later version.
13 //
14 // This program is distributed in the hope that it will be useful, but
15 // WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 // General Public License for more details.
18 //
19 // You should have received a copy of the GNU General Public License
20 // along with this program; if not, write to the Free Software
21 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 //
23 // $Id$
24
25
26 #ifndef _FG_SIMPLE_HXX
27 #define _FG_SIMPLE_HXX
28
29
30 #ifndef __cplusplus                                                          
31 # error This library requires C++
32 #endif                                   
33
34
35 #ifdef HAVE_CONFIG_H
36 #  include <config.h>
37 #endif
38
39 #include <simgear/compiler.h>
40
41 #include STL_STRING
42 #include <map>
43 #include <vector>
44
45 SG_USING_STD(string);
46 SG_USING_STD(map);
47 SG_USING_STD(vector);
48
49
50 struct FGAirport {
51     string _id;
52     double _longitude;
53     double _latitude;
54     double _elevation;
55     string _code;               // depricated and can be removed
56     string _name;
57     bool _has_metar;
58
59     FGAirport() : _longitude(0), _latitude(0), _elevation(0) {}
60 };
61
62 typedef map < string, FGAirport > airport_map;
63 typedef airport_map::iterator airport_map_iterator;
64 typedef airport_map::const_iterator const_airport_map_iterator;
65
66 typedef vector < FGAirport * > airport_list;
67
68
69 class FGAirportList {
70
71 private:
72
73     airport_map airports_by_id;
74     airport_list airports_array;
75
76 public:
77
78     // Constructor (new)
79     FGAirportList() {}
80
81     // Destructor
82     ~FGAirportList();
83
84     // add an entry to the list
85     void add( const string id, const double longitude, const double latitude,
86               const double elevation, const string name, const bool has_metar );
87
88     // search for the specified id.
89     // Returns true if successful, otherwise returns false.
90     // On success, airport data is returned thru "airport" pointer.
91     // "airport" is not changed if "apt" is not found.
92     FGAirport search( const string& id );
93
94     // search for the airport closest to the specified position
95     // (currently a linear inefficient search so it's probably not
96     // best to use this at runtime.)  If with_metar is true, then only
97     // return station id's marked as having metar data.
98     FGAirport search( double lon_deg, double lat_deg, bool with_metar );
99
100
101     /**
102      * Return the number of airports in the list.
103      */
104     int size() const;
105
106
107     /**
108      * Return a specific airport, by position.
109      */
110     const FGAirport *getAirport( int index ) const;
111
112
113     /**
114      * Mark the specified airport record as not having metar
115      */
116     void no_metar( const string &id );
117
118     /**
119      * Mark the specified airport record as (yes) having metar
120      */
121     void has_metar( const string &id );
122
123 };
124
125
126 #endif // _FG_SIMPLE_HXX
127
128