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
30 #include <simgear/compiler.h>
35 #include <Navaids/positioned.hxx>
38 class FGAirportDynamics;
43 typedef SGSharedPtr<FGRunway> FGRunwayPtr;
44 typedef SGSharedPtr<FGTaxiway> FGTaxiwayPtr;
45 typedef SGSharedPtr<FGPavement> FGPavementPtr;
47 /***************************************************************************************
49 **************************************************************************************/
50 class FGAirport : public FGPositioned
53 SGGeod _tower_location;
56 FGAirportDynamics *_dynamics;
59 FGAirport(const std::string& id, const SGGeod& location, const SGGeod& tower,
60 const std::string& name, bool has_metar, Type aType);
63 const std::string& getId() const { return ident(); }
64 const std::string& getName() const { return _name; }
65 double getLongitude() const { return longitude(); }
67 double getLatitude() const { return latitude(); }
69 double getElevation() const { return elevation(); }
70 bool getMetar() const { return _has_metar; }
71 bool isAirport() const;
72 bool isSeaport() const;
73 bool isHeliport() const;
75 virtual const std::string& name() const
78 const SGGeod& getTowerLocation() const { return _tower_location; }
80 void setMetar(bool value) { _has_metar = value; }
82 FGRunway* getActiveRunwayForUsage() const;
84 FGAirportDynamics *getDynamics();
86 unsigned int numRunways() const;
87 FGRunway* getRunwayByIndex(unsigned int aIndex) const;
89 bool hasRunwayWithIdent(const std::string& aIdent) const;
90 FGRunway* getRunwayByIdent(const std::string& aIdent) const;
91 FGRunway* findBestRunwayForHeading(double aHeading) const;
94 * Useful predicate for FMS/GPS/NAV displays and similar - check if this
95 * aiport has a hard-surfaced runway of at least the specified length.
97 bool hasHardRunwayOfLengthFt(double aLengthFt) const;
99 unsigned int numTaxiways() const;
100 FGTaxiway* getTaxiwayByIndex(unsigned int aIndex) const;
102 unsigned int numPavements() const;
103 FGPavement* getPavementByIndex(unsigned int aIndex) const;
105 void setRunwaysAndTaxiways(std::vector<FGRunwayPtr>& rwys,
106 std::vector<FGTaxiwayPtr>& txwys,
107 std::vector<FGPavementPtr>& pvts);
109 class AirportFilter : public Filter
112 virtual bool pass(FGPositioned* aPos) const {
113 return passAirport(static_cast<FGAirport*>(aPos));
116 virtual Type minType() const {
120 virtual Type maxType() const {
124 virtual bool passAirport(FGAirport* aApt) const {
129 class HardSurfaceFilter : public AirportFilter
132 HardSurfaceFilter(double minLengthFt);
134 virtual bool passAirport(FGAirport* aApt) const;
136 virtual Type maxType() const {
144 * Syntactic wrapper around FGPositioned::findClosest - find the closest
145 * match for filter, and return it cast to FGAirport. The default filter
146 * passes all airports, including seaports and heliports.
148 static FGAirport* findClosest(const SGGeod& aPos, double aCuttofNm, Filter* filter = NULL);
151 * Helper to look up an FGAirport instance by unique ident. Throws an
152 * exception if the airport could not be found - so callers can assume
153 * the result is non-NULL.
155 static FGAirport* getByIdent(const std::string& aIdent);
158 * Helper to look up an FGAirport instance by unique ident. Returns NULL
159 * if the airport could not be found.
161 static FGAirport* findByIdent(const std::string& aIdent);
164 * Specialised helper to implement the AirportList dialog. Performs a
165 * case-insensitive search on airport names and ICAO codes, and returns
166 * matches in a format suitable for use by a puaList.
168 static char** searchNamesAndIdents(const std::string& aFilter);
170 typedef std::vector<FGRunwayPtr>::const_iterator Runway_iterator;
172 * Helper to locate a runway by ident
174 Runway_iterator getIteratorForRunwayIdent(const std::string& aIdent) const;
176 FGAirport operator=(FGAirport &other);
177 FGAirport(const FGAirport&);
179 std::vector<FGRunwayPtr> mRunways;
180 std::vector<FGTaxiwayPtr> mTaxiways;
181 std::vector<FGPavementPtr> mPavements;
184 // find basic airport location info from airport database
185 const FGAirport *fgFindAirportID( const std::string& id);
187 // get airport elevation
188 double fgGetAirportElev( const std::string& id );
190 #endif // _FG_SIMPLE_HXX