// runways.hpp -- FGFS runway list // // Written by Frederic Bouvier, started May 2002. // // Copyright (C) 2002 Frederic Bouvier - fredb@users.sourceforge.net // Copyright (C) 2000 Curtis L. Olson - curt@flightgear.org // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 2 of the // License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // // $Id: runways.hpp,v 1.6 2003/07/20 21:04:14 fredb2 Exp $ #ifndef _runways_hpp_ #define _runways_hpp_ 1 #ifdef _MSC_VER #pragma warning( disable : 4786 ) #endif #include #include #include class FGSD_AirportUtil; struct FGSD_RunwayKey { std::string id; std::string rwy_no; bool operator==( const FGSD_RunwayKey &r ) const { return id == r.id && rwy_no == r.rwy_no; } bool operator<( const FGSD_RunwayKey &r ) const { return id < r.id || ( id == r.id && rwy_no < r.rwy_no ); } }; struct FGSD_Runway { std::string id; std::string rwy_no; double lon; double lat; double heading; double length; double width; std::string surface_flags; std::string end1_flags; double threshold1; double stop1; std::string end2_flags; double threshold2; double stop2; }; struct FGSD_TaxiwayKey { std::string id; std::string twy_no; bool operator==( const FGSD_TaxiwayKey &r ) const { return id == r.id && twy_no == r.twy_no; } bool operator<( const FGSD_TaxiwayKey &r ) const { return id < r.id || ( id == r.id && twy_no < r.twy_no ); } }; struct FGSD_Taxiway { std::string id; std::string twy_no; double lon; double lat; double heading; double length; double width; char center; char surface; char edge; }; class FGSD_Runways { public: typedef std::map RunwayMap; typedef std::list RunwayList; ~FGSD_Runways(); bool search( const char *__aptid, RunwayList &__rwyLst ) const; bool search( const char *__aptid, const char *__rwy_no, FGSD_Runway &__runway ) const; private: void insertRunway( FGSD_Runway *__rwy ); RunwayMap _runwayMap; friend class FGSD_AirportUtil; }; class FGSD_Taxiways { public: typedef std::multimap TaxiwayMap; typedef std::list TaxiwayList; ~FGSD_Taxiways(); bool search( const char *__aptid, TaxiwayList &__twyLst ) const; bool search( const char *__aptid, const char *__twy_no, TaxiwayList &__twyLst ) const; private: void insertTaxiway( FGSD_Taxiway *__twy ); TaxiwayMap _taxiwayMap; friend class FGSD_AirportUtil; }; struct FGSD_Airport { std::string id; std::string name; double lon; double lat; double height; }; class FGSD_Airports { public: typedef std::map AirportMap; ~FGSD_Airports(); bool search( const char *__aptid, FGSD_Airport &__airport ) const; bool previous( const char *__aptid, size_t pos, FGSD_Airport &__airport ) const; bool next( const char *__aptid, size_t pos, FGSD_Airport &__airport ) const; bool searchByName( const char *__aptid, FGSD_Airport &__airport ) const; bool previousByName( const char *__aptid, size_t pos, FGSD_Airport &__airport ) const; bool nextByName( const char *__aptid, size_t pos, FGSD_Airport &__airport ) const; private: bool search( const AirportMap &__map, const char *__aptid, FGSD_Airport &__airport ) const; bool previous( const AirportMap &__map, const char *__aptid, size_t pos, FGSD_Airport &__airport ) const; bool next( const AirportMap &__map, const char *__aptid, size_t pos, FGSD_Airport &__airport ) const; void insertAirport( FGSD_Airport *__apt ); AirportMap _airportMap; AirportMap _aptNameMap; friend class FGSD_AirportUtil; }; inline bool FGSD_Airports::search( const char *__aptid, FGSD_Airport &__airport ) const { return search( _airportMap, __aptid, __airport ); } inline bool FGSD_Airports::previous( const char *__aptid, size_t pos, FGSD_Airport &__airport ) const { return previous( _airportMap, __aptid, pos, __airport ); } inline bool FGSD_Airports::next( const char *__aptid, size_t pos, FGSD_Airport &__airport ) const { return next( _airportMap, __aptid, pos, __airport ); } inline bool FGSD_Airports::searchByName( const char *__apt, FGSD_Airport &__airport ) const { return search( _aptNameMap, __apt, __airport ); } inline bool FGSD_Airports::previousByName( const char *__apt, size_t pos, FGSD_Airport &__airport ) const { return previous( _aptNameMap, __apt, pos, __airport ); } inline bool FGSD_Airports::nextByName( const char *__apt, size_t pos, FGSD_Airport &__airport ) const { return next( _aptNameMap, __apt, pos, __airport ); } class FGSD_AirportUtil { public: static bool loadDatabase( const char *__fgRoot, FGSD_Airports &__airports, FGSD_Runways &__runways, FGSD_Taxiways &__taxiways, size_t &nbApt, void (*__step)( size_t, void * ), void *data ); }; #endif