1998-08-25 17:19:13 +00:00
|
|
|
//
|
1999-02-26 22:08:34 +00:00
|
|
|
// simple.hxx -- a really simplistic class to manage airport ID,
|
1998-08-25 17:19:13 +00:00
|
|
|
// lat, lon of the center of one of it's runways, and
|
|
|
|
// elevation in feet.
|
|
|
|
//
|
|
|
|
// Written by Curtis Olson, started April 1998.
|
|
|
|
//
|
|
|
|
// Copyright (C) 1998 Curtis L. Olson - curt@me.umn.edu
|
|
|
|
//
|
|
|
|
// 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$
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef _AIRPORTS_HXX
|
|
|
|
#define _AIRPORTS_HXX
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef __cplusplus
|
|
|
|
# error This library requires C++
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
1999-02-26 22:08:34 +00:00
|
|
|
#include <Include/compiler.h>
|
1999-03-15 17:58:57 +00:00
|
|
|
#ifdef FG_HAVE_STD_INCLUDES
|
|
|
|
# include <istream>
|
|
|
|
#else
|
|
|
|
# include <istream.h>
|
|
|
|
#endif
|
1999-02-26 22:08:34 +00:00
|
|
|
|
|
|
|
#include STL_STRING
|
1998-09-01 19:02:53 +00:00
|
|
|
#include <set>
|
1998-08-25 17:19:13 +00:00
|
|
|
|
1999-03-02 01:02:31 +00:00
|
|
|
FG_USING_STD(string);
|
|
|
|
FG_USING_STD(set);
|
1999-03-15 17:58:57 +00:00
|
|
|
FG_USING_STD(istream);
|
1998-08-25 17:19:13 +00:00
|
|
|
|
|
|
|
|
1998-09-01 19:02:53 +00:00
|
|
|
class fgAIRPORT {
|
|
|
|
public:
|
|
|
|
fgAIRPORT( const string& name = "",
|
|
|
|
double lon = 0.0,
|
|
|
|
double lat = 0.0,
|
|
|
|
double ele = 0.0 )
|
|
|
|
: id(name), longitude(lon), latitude(lat), elevation(ele) {}
|
|
|
|
|
|
|
|
bool operator < ( const fgAIRPORT& a ) const {
|
|
|
|
return id < a.id;
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
string id;
|
1998-08-25 17:19:13 +00:00
|
|
|
double longitude;
|
|
|
|
double latitude;
|
|
|
|
double elevation;
|
1998-09-01 19:02:53 +00:00
|
|
|
};
|
1998-08-25 17:19:13 +00:00
|
|
|
|
1998-09-01 19:02:53 +00:00
|
|
|
inline istream&
|
|
|
|
operator >> ( istream& in, fgAIRPORT& a )
|
|
|
|
{
|
|
|
|
return in >> a.id >> a.longitude >> a.latitude >> a.elevation;
|
|
|
|
}
|
1998-08-25 17:19:13 +00:00
|
|
|
|
|
|
|
class fgAIRPORTS {
|
1998-09-01 19:02:53 +00:00
|
|
|
public:
|
1998-11-02 18:25:34 +00:00
|
|
|
#ifdef FG_NO_DEFAULT_TEMPLATE_ARGS
|
1998-09-08 21:38:41 +00:00
|
|
|
typedef set< fgAIRPORT, less< fgAIRPORT > > container;
|
|
|
|
#else
|
1998-09-01 19:02:53 +00:00
|
|
|
typedef set< fgAIRPORT > container;
|
1998-09-08 21:38:41 +00:00
|
|
|
#endif
|
1998-09-01 19:02:53 +00:00
|
|
|
typedef container::iterator iterator;
|
|
|
|
typedef container::const_iterator const_iterator;
|
|
|
|
|
|
|
|
private:
|
|
|
|
container airports;
|
1998-08-25 17:19:13 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
// Constructor
|
1998-09-01 19:02:53 +00:00
|
|
|
fgAIRPORTS();
|
|
|
|
|
|
|
|
// Destructor
|
|
|
|
~fgAIRPORTS();
|
1998-08-25 17:19:13 +00:00
|
|
|
|
|
|
|
// load the data
|
1998-08-27 17:01:55 +00:00
|
|
|
int load( const string& file );
|
1998-08-25 17:19:13 +00:00
|
|
|
|
1998-09-01 19:02:53 +00:00
|
|
|
// search for the specified id.
|
|
|
|
// Returns true if successful, otherwise returns false.
|
|
|
|
// On success, airport data is returned thru "airport" pointer.
|
|
|
|
// "airport" is not changed if "id" is not found.
|
|
|
|
bool search( const string& id, fgAIRPORT* airport ) const;
|
|
|
|
fgAIRPORT search( const string& id ) const;
|
1998-08-25 17:19:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* _AIRPORTS_HXX */
|
|
|
|
|
|
|
|
|