]> git.mxchange.org Git - flightgear.git/blobdiff - src/Airports/simple.hxx
Add a *really* crude model of ITT, Oil Temp, and Oil Pressure. This
[flightgear.git] / src / Airports / simple.hxx
index e4d3711965aee0a1da8f9c8e5d75e24cd1e409af..d6c84a7b49a1e92368434f75eb31ccb7b63cef57 100644 (file)
@@ -4,7 +4,7 @@
 //
 // Written by Curtis Olson, started April 1998.
 //
-// Copyright (C) 1998  Curtis L. Olson  - curt@me.umn.edu
+// Copyright (C) 1998  Curtis L. Olson  - http://www.flightgear.org/~curt
 //
 // This program is free software; you can redistribute it and/or
 // modify it under the terms of the GNU General Public License as
@@ -23,8 +23,8 @@
 // $Id$
 
 
-#ifndef _SIMPLE_HXX
-#define _SIMPLE_HXX
+#ifndef _FG_SIMPLE_HXX
+#define _FG_SIMPLE_HXX
 
 
 #ifndef __cplusplus                                                          
 
 #include <simgear/compiler.h>
 
-#ifdef SG_HAVE_STD_INCLUDES
-#  include <istream>
-#elif defined( FG_HAVE_NATIVE_SGI_COMPILERS )
-#  include <iostream.h>
-#elif defined( __BORLANDC__ )
-#  include <iostream>
-#else
-#  include <istream.h>
-#endif
-
 #include STL_STRING
-#include <set>
-
-#ifndef _MSC_VER
-#   define NDEBUG                      // she don't work without it.
-#endif
-#include <mk4.h>
-#include <mk4str.h>
-#ifndef _MSC_VER
-#  undef NDEBUG
-#endif
-
-FG_USING_STD(string);
-FG_USING_STD(set);
-
-#if ! defined( FG_HAVE_NATIVE_SGI_COMPILERS )
-FG_USING_STD(istream);
-#endif
-
+#include <map>
+#include <vector>
 
-class FGAirport {
-
-public:
+SG_USING_STD(string);
+SG_USING_STD(map);
+SG_USING_STD(vector);
 
-    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:
 
+struct FGAirport {
     string id;
     double longitude;
     double latitude;
     double elevation;
-
+    string code;
+    string name;
+    bool has_metar;
 };
 
-inline istream&
-operator >> ( istream& in, FGAirport& a )
-{
-    return in >> a.id >> a.latitude >> a.longitude >> a.elevation;
-}
+typedef map < string, FGAirport > airport_map;
+typedef airport_map::iterator airport_map_iterator;
+typedef airport_map::const_iterator const_airport_map_iterator;
+
+typedef vector < FGAirport * > airport_list;
 
 
-class FGAirports {
+class FGAirportList {
 
 private:
 
-    c4_Storage *storage;
-    c4_View *vAirport;
+    airport_map airports_by_id;
+    airport_list airports_array;
 
 public:
 
     // Constructor
-    FGAirports( const string& file );
+    FGAirportList( const string &airport_file, const string &metar_file );
 
     // Destructor
-    ~FGAirports();
+    ~FGAirportList();
 
     // 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 "apt" is not found.
-    bool search( const string& id, FGAirport* airport ) const;
-    FGAirport search( const string& id ) const;
-};
+    FGAirport search( const string& id );
 
+    // search for the airport closest to the specified position
+    // (currently a linear inefficient search so it's probably not
+    // best to use this at runtime.)  If with_metar is true, then only
+    // return station id's marked as having metar data.
+    FGAirport search( double lon_deg, double lat_deg, bool with_metar );
 
-class FGAirportsUtil {
-public:
-#ifdef FG_NO_DEFAULT_TEMPLATE_ARGS
-    typedef set< FGAirport, less< FGAirport > > container;
-#else
-    typedef set< FGAirport > container;
-#endif
-    typedef container::iterator iterator;
-    typedef container::const_iterator const_iterator;
 
-private:
-    container airports;
+    /**
+     * Return the number of airports in the list.
+     */
+    int size() const;
 
-public:
 
-    // Constructor
-    FGAirportsUtil();
-
-    // Destructor
-    ~FGAirportsUtil();
+    /**
+     * Return a specific airport, by position.
+     */
+    const FGAirport *getAirport( int index ) const;
 
-    // load the data
-    int load( const string& file );
 
-    // save the data in metakit format
-    bool dump_mk4( const string& file );
+    /**
+     * Mark the specified airport record as not having metar
+     */
+    void no_metar( const string &id );
 
-    // 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;
 };
 
 
-#endif // _SIMPLE_HXX
+#endif // _FG_SIMPLE_HXX