]> git.mxchange.org Git - flightgear.git/blobdiff - src/Airports/runways.hxx
Set the format default to float instead of int.
[flightgear.git] / src / Airports / runways.hxx
index 09fa3e632107d214eae848c96f3315c24387d518..9c47124d26668d22e5dc5f48ad3b15b036dd4fff 100644 (file)
@@ -21,8 +21,8 @@
 // $Id$
 
 
-#ifndef _RUNWAYS_HXX
-#define _RUNWAYS_HXX
+#ifndef _FG_RUNWAYS_HXX
+#define _FG_RUNWAYS_HXX
 
 
 #ifndef __cplusplus                                                          
 
 #include <simgear/compiler.h>
 
-#ifdef SG_HAVE_STD_INCLUDES
-#  include <istream>
-#elif defined( SG_HAVE_NATIVE_SGI_COMPILERS )
-#  include <iostream.h>
-#elif defined( __BORLANDC__ )
-#  include <iostream>
-#else
-#  include <istream.h>
-#endif
-
 #include STL_STRING
-#include <vector>
-
-#define NDEBUG                 // she don't work without it.
-#include <mk4.h>
-#include <mk4str.h>
-#undef NDEBUG
+#include <map>
 
 SG_USING_STD(string);
-SG_USING_STD(vector);
+SG_USING_STD(multimap);
 
-#if ! defined( SG_HAVE_NATIVE_SGI_COMPILERS )
-SG_USING_STD(istream);
-#endif
 
+struct ltstr {
+    bool operator()(const string s1, const string s2) const {
+        return s1 < s2;
+    }
+};
 
-class FGRunway {
 
-public:
+struct FGRunway {
 
+    string type;
     string id;
     string rwy_no;
 
@@ -79,39 +66,32 @@ public:
     string end1_flags;
     string end2_flags;
 
-public:
+    double end1_displaced_threshold;
+    double end2_displaced_threshold;
 
-    FGRunway();
-    ~FGRunway();
+    double end1_stopway;
+    double end2_stopway;
 
 };
 
-inline istream&
-operator >> ( istream& in, FGRunway& a )
-{
-    int tmp;
-
-    return in >> a.rwy_no >> a.lat >> a.lon >> a.heading >> a.length >> a.width
-             >> a.surface_flags >> a.end1_flags >> tmp >> tmp >> a.end2_flags
-             >> tmp >> tmp;
-}
+typedef multimap < string, FGRunway, ltstr > runway_map;
+typedef runway_map::iterator runway_map_iterator;
+typedef runway_map::const_iterator const_runway_map_iterator;
 
-
-class FGRunways {
+class FGRunwayList {
 
 private:
 
-    c4_Storage *storage;
-    c4_View *vRunway;
-    int next_index;
+    runway_map runways;
+    runway_map_iterator current;
 
 public:
 
     // Constructor
-    FGRunways( const string& file );
+    FGRunwayList( const string& file );
 
     // Destructor
-    ~FGRunways();
+    ~FGRunwayList();
 
     // search for the specified apt id.
     // Returns true if successful, otherwise returns false.
@@ -119,42 +99,17 @@ public:
     // "runway" is not changed if "apt" is not found.
     bool search( const string& aptid, FGRunway* runway );
     bool search( const string& aptid, const string& rwyno, FGRunway* runway );
-    FGRunway search( const string& aptid );
-    bool next( FGRunway* runway );
-    FGRunway next();
-};
 
+    // DCL - search for runway closest to desired heading in degrees
+    bool search( const string& aptid, const int hdg, FGRunway* runway );
 
-class FGRunwaysUtil {
-public:
-    typedef vector< FGRunway > container;
-    typedef container::iterator iterator;
-    typedef container::const_iterator const_iterator;
+    // Return the runway number of the runway closest to a given heading
+    string search( const string& aptid, const int tgt_hdg );
 
-private:
-    container runways;
-
-public:
-
-    // Constructor
-    FGRunwaysUtil();
-
-    // Destructor
-    ~FGRunwaysUtil();
-
-    // load the data
-    int load( const string& file );
-
-    // save the data in metakit format
-    bool dump_mk4( const string& file );
-
-    // search for the specified id.
-    // Returns true if successful, otherwise returns false.
-    // On success, runway data is returned thru "runway" pointer.
-    // "runway" is not changed if "id" is not found.
-    // bool search( const string& id, FGRunway* runway ) const;
-    // FGRunway search( const string& id ) const;
+    FGRunway search( const string& aptid );
+    bool next( FGRunway* runway );
+    FGRunway next();
 };
 
 
-#endif // _RUNWAYS_HXX
+#endif // _FG_RUNWAYS_HXX