1 // simple.hxx -- a really simplistic class to manage airport ID,
2 // lat, lon of the center of one of it's runways, and
5 // Written by Curtis Olson, started April 1998.
6 // Updated by Durk Talsma, started December 2004.
8 // Copyright (C) 1998 Curtis L. Olson - http://www.flightgear.org/~curt
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.
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.
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.
27 #ifndef _FG_SIMPLE_HXX
28 #define _FG_SIMPLE_HXX
32 # error This library requires C++
39 #include <simgear/math/point3d.hxx>
41 #include <simgear/compiler.h>
48 #include "runwayprefs.hxx"
49 #include "parking.hxx"
50 #include "groundnetwork.hxx"
51 #include "dynamics.hxx"
61 /***************************************************************************************
63 **************************************************************************************/
67 double _longitude; // degrees
68 double _latitude; // degrees
69 double _elevation; // ft
72 FGAirportDynamics *dynamics;
76 // FGAirport(const FGAirport &other);
77 FGAirport(const string& id, double lon, double lat, double elev, const string& name, bool has_metar);
80 string getId() const { return _id; }
81 const string &getName() const { return _name; }
82 double getLongitude() const { return _longitude; }
84 double getLatitude() const { return _latitude; }
86 double getElevation() const { return _elevation; }
87 bool getMetar() const { return _has_metar; }
89 void setId(const string& id) { _id = id; }
90 void setMetar(bool value) { _has_metar = value; }
92 FGAirportDynamics *getDynamics();
95 FGAirport operator=(FGAirport &other);
96 FGAirport(const FGAirport&);
101 typedef map < string, FGAirport* > airport_map;
102 typedef airport_map::iterator airport_map_iterator;
103 typedef airport_map::const_iterator const_airport_map_iterator;
105 typedef vector < FGAirport * > airport_list;
106 typedef airport_list::iterator airport_list_iterator;
107 typedef airport_list::const_iterator const_airport_list_iterator;
111 class FGAirportList {
114 airport_map airports_by_id;
115 airport_list airports_array;
116 //set < string > ai_dirs;
125 // add an entry to the list
126 void add( const string& id, const double longitude, const double latitude,
127 const double elevation, const string& name, const bool has_metar );
129 // search for the specified id.
130 // Returns NULL if unsucessfull.
131 FGAirport* search( const string& id );
133 // Search for the next airport in ASCII sequence to the supplied id.
134 // eg. id = "KDC" or "KDCA" would both return "KDCA".
135 // If exact = true then only exact matches are returned.
136 // NOTE: Numbers come prior to A-Z in ASCII sequence so id = "LD" would return "LD57", not "LDDP"
137 // Implementation assumes airport codes are unique.
138 // Returns NULL if unsucessfull.
139 const FGAirport* findFirstById( const string& id, bool exact = false );
141 // search for the airport closest to the specified position
142 // (currently a linear inefficient search so it's probably not
143 // best to use this at runtime.) If with_metar is true, then only
144 // return station id's marked as having metar data.
145 // Returns NULL if fails (unlikely unless none have metar and with_metar spec'd!)
146 FGAirport* search( double lon_deg, double lat_deg, bool with_metar );
149 * Return the number of airports in the list.
154 * Return a specific airport, by position.
156 const FGAirport *getAirport( unsigned int index ) const;
159 * Return a pointer to the raw airport list
161 inline const airport_list* getAirportList() { return (&airports_array); }
164 * Mark the specified airport record as not having metar
166 void no_metar( const string &id );
169 * Mark the specified airport record as (yes) having metar
171 void has_metar( const string &id );
175 // find basic airport location info from airport database
176 const FGAirport *fgFindAirportID( const string& id);
178 // get airport elevation
179 double fgGetAirportElev( const string& id );
181 // get airport position
182 Point3D fgGetAirportPos( const string& id );
184 #endif // _FG_SIMPLE_HXX