]> git.mxchange.org Git - flightgear.git/blobdiff - src/Airports/runways.hxx
This should apply, and everything should build cleanly, in isolation from the
[flightgear.git] / src / Airports / runways.hxx
index 5512097d8d44e3c41e709d6db9ee437f79249c21..6dcf4e76d9370a9d04178551fdaf49102d54103d 100644 (file)
@@ -2,7 +2,7 @@
 //
 // Written by Curtis Olson, started August 2000.
 //
-// Copyright (C) 2000  Curtis L. Olson  - curt@flightgear.org
+// Copyright (C) 2000  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
 //
 // 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.
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 //
 // $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>
-
-#ifndef _MSC_VER
-#define NDEBUG                 // she don't work without it.
-#endif // !_MSC_VER
-
-#include <mk4.h>
-#include <mk4str.h>
-
-#ifndef _MSC_VER
-#undef NDEBUG
-#endif // !_MSC_VER
+#include <string>
+#include <map>
 
 SG_USING_STD(string);
-SG_USING_STD(vector);
-
-#if ! defined( SG_HAVE_NATIVE_SGI_COMPILERS )
-SG_USING_STD(istream);
-#endif
-
-
-class FGRunway {
+SG_USING_STD(multimap);
 
-public:
-
-    string id;
-    string rwy_no;
-
-    double lon;
-    double lat;
-    double heading;
-    double length;
-    double width;
-    
-    string surface_flags;
-    string end1_flags;
-    string end2_flags;
-
-public:
-
-    FGRunway();
-    ~FGRunway();
 
+struct ltstr {
+    bool operator()(const string& s1, const string& s2) const {
+        return s1 < s2;
+    }
 };
 
-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;
-}
+struct FGRunway {
+
+    string _id;
+    string _rwy_no;
+    string _type;                // runway / taxiway
+
+    double _lon;
+    double _lat;
+    double _heading;
+    double _length;
+    double _width;
+    double _displ_thresh1;
+    double _displ_thresh2;
+    double _stopway1;
+    double _stopway2;
+
+    string _lighting_flags;
+    int _surface_code;
+    string _shoulder_code;
+    int _marking_code;
+    double _smoothness;
+    bool   _dist_remaining;
+};
 
+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 );
+    // Constructor (new)
+    FGRunwayList() {}
 
     // Destructor
-    ~FGRunways();
+    ~FGRunwayList();
+
+    // add an entry to the list
+    void add( const string& id, const string& rwy_no,
+              const double longitude, const double latitude,
+              const double heading, const double length, const double width,
+              const double displ_thresh1, const double displ_thresh2,
+              const double stopway1, const double stopway2,
+              const string& lighting_flags, const int surface_code,
+              const string& shoulder_code, const int marking_code,
+              const double smoothness, const bool dist_remaining );
 
     // search for the specified apt id.
     // Returns true if successful, otherwise returns false.
@@ -125,42 +109,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;
-
-private:
-    container runways;
+    // Return the runway number of the runway closest to a given heading
+    string search( const string& aptid, const int tgt_hdg );
 
-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