]> git.mxchange.org Git - flightgear.git/blob - src/Airports/simple.hxx
Change tower location to an SGGeod. Include taxiways too.
[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 // Updated by Durk Talsma, started December 2004.
7 //
8 // Copyright (C) 1998  Curtis L. Olson  - http://www.flightgear.org/~curt
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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
23 //
24 // $Id$
25
26
27 #ifndef _FG_SIMPLE_HXX
28 #define _FG_SIMPLE_HXX
29
30
31 #ifndef __cplusplus
32 # error This library requires C++
33 #endif
34
35
36 #ifdef HAVE_CONFIG_H
37 #  include <config.h>
38 #endif
39 #include <simgear/math/point3d.hxx>
40
41 #include <simgear/compiler.h>
42
43 #include STL_STRING
44 #include <map>
45 #include <set>
46 #include <vector>
47
48 #include "runwayprefs.hxx"
49 #include "parking.hxx"
50 #include "groundnetwork.hxx"
51 #include "dynamics.hxx"
52
53
54 SG_USING_STD(string);
55 SG_USING_STD(map);
56 SG_USING_STD(set);
57 SG_USING_STD(vector);
58
59
60
61
62 /***************************************************************************************
63  *
64  **************************************************************************************/
65 class FGAirport {
66 private:
67     string _id;
68     SGGeod _location;
69     SGGeod _tower_location;
70     string _name;
71     bool _has_metar;
72     FGAirportDynamics *dynamics;
73
74 public:
75     FGAirport();
76     // FGAirport(const FGAirport &other);
77     FGAirport(const string& id, const SGGeod& location, const SGGeod& tower, const string& name, bool has_metar);
78     ~FGAirport();
79
80     const string& getId() const { return _id; }
81     const string& getName() const { return _name; }
82     double getLongitude() const { return _location.getLongitudeDeg(); }
83     // Returns degrees
84     double getLatitude()  const { return _location.getLatitudeDeg(); }
85     // Returns ft
86     double getElevation() const { return _location.getElevationFt(); }
87     bool   getMetar()     const { return _has_metar; }
88
89     const SGGeod& getTowerLocation() const { return _tower_location; }
90
91     void setId(const string& id) { _id = id; }
92     void setMetar(bool value) { _has_metar = value; }
93
94     FGAirportDynamics *getDynamics();
95
96 private:
97     FGAirport operator=(FGAirport &other);
98     FGAirport(const FGAirport&);
99 };
100
101
102
103 typedef map < string, FGAirport* > airport_map;
104 typedef airport_map::iterator airport_map_iterator;
105 typedef airport_map::const_iterator const_airport_map_iterator;
106
107 typedef vector < FGAirport * > airport_list;
108 typedef airport_list::iterator airport_list_iterator;
109 typedef airport_list::const_iterator const_airport_list_iterator;
110
111
112
113 class FGAirportList {
114 private:
115
116     airport_map airports_by_id;
117     airport_list airports_array;
118     //set < string > ai_dirs;
119
120 public:
121     // Constructor (new)
122     FGAirportList();
123
124     // Destructor
125     ~FGAirportList();
126
127     // add an entry to the list
128     void add( const string& id, const SGGeod& location, const SGGeod& tower,
129               const string& name, const bool has_metar );
130
131     // search for the specified id.
132     // Returns NULL if unsucessfull.
133     FGAirport* search( const string& id );
134
135     // Search for the next airport in ASCII sequence to the supplied id.
136     // eg. id = "KDC" or "KDCA" would both return "KDCA".
137     // If exact = true then only exact matches are returned.
138     // NOTE: Numbers come prior to A-Z in ASCII sequence so id = "LD" would return "LD57", not "LDDP"
139     // Implementation assumes airport codes are unique.
140     // Returns NULL if unsucessfull.
141     const FGAirport* findFirstById( const string& id, bool exact = false );
142
143     // search for the airport closest to the specified position
144     // (currently a linear inefficient search so it's probably not
145     // best to use this at runtime.)  If with_metar is true, then only
146     // return station id's marked as having metar data.
147     // Returns NULL if fails (unlikely unless none have metar and with_metar spec'd!)
148     FGAirport* search( double lon_deg, double lat_deg, bool with_metar );
149
150     /**
151      * Return the number of airports in the list.
152      */
153     int size() const;
154
155     /**
156      * Return a specific airport, by position.
157      */
158     const FGAirport *getAirport( unsigned int index ) const;
159
160     /**
161      * Return a pointer to the raw airport list
162      */
163     inline const airport_list* getAirportList() { return (&airports_array); }
164
165     /**
166      * Mark the specified airport record as not having metar
167      */
168     void no_metar( const string &id );
169
170     /**
171      * Mark the specified airport record as (yes) having metar
172      */
173     void has_metar( const string &id );
174
175 };
176
177 // find basic airport location info from airport database
178 const FGAirport *fgFindAirportID( const string& id);
179
180 // get airport elevation
181 double fgGetAirportElev( const string& id );
182
183 // get airport position
184 Point3D fgGetAirportPos( const string& id );
185
186 #endif // _FG_SIMPLE_HXX
187
188