//
// 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 _FG_RUNWAYS_HXX
#define _FG_RUNWAYS_HXX
-
-#ifndef __cplusplus
-# error This library requires C++
-#endif
-
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
#include <simgear/compiler.h>
-#include STL_STRING
-#include <map>
-
-SG_USING_STD(string);
-SG_USING_STD(multimap);
-
-
-struct ltstr {
- bool operator()(const string s1, const string s2) const {
- return s1 < s2;
- }
-};
-
-
-struct FGRunway {
-
- string type;
- string id;
- string rwy_no;
-
- double lon;
- double lat;
- double heading;
- double length;
- double width;
-
- string surface_flags;
- string end1_flags;
- string end2_flags;
-
- double end1_displaced_threshold;
- double end2_displaced_threshold;
-
- double end1_stopway;
- double end2_stopway;
-
-};
-
-typedef multimap < string, FGRunway, ltstr > runway_map;
-typedef runway_map::iterator runway_map_iterator;
-typedef runway_map::const_iterator const_runway_map_iterator;
-
-class FGRunwayList {
-
-private:
-
- runway_map runways;
- runway_map_iterator current;
-
+#include <simgear/math/sg_geodesy.hxx>
+
+#include "Navaids/positioned.hxx"
+
+#include <string>
+
+// forward decls
+class FGAirport;
+
+class FGRunway : public FGPositioned
+{
+ FGAirport* _airport; ///< owning airport
+ bool _reciprocal;
+ double _heading;
+ double _length;
+ double _width;
+ double _displ_thresh;
+ double _stopway;
+
+ /** surface, as defined by:
+ * http://www.x-plane.org/home/robinp/Apt810.htm#RwySfcCodes
+ */
+ int _surface_code;
+
public:
-
- // Constructor
- FGRunwayList( const string& file );
-
- // Destructor
- ~FGRunwayList();
-
- // search for the specified apt id.
- // Returns true if successful, otherwise returns false.
- // On success, runway data is returned thru "runway" pointer.
- // "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 );
-
- // DCL - search for runway closest to desired heading in degrees
- bool search( const string& aptid, const int hdg, FGRunway* runway );
-
- // Return the runway number of the runway closest to a given heading
- string search( const string& aptid, const int tgt_hdg );
-
- FGRunway search( const string& aptid );
- bool next( FGRunway* runway );
- FGRunway next();
+
+ FGRunway(FGAirport* aAirport, const std::string& rwy_no,
+ const SGGeod& aGeod,
+ const double heading, const double length,
+ const double width,
+ const double displ_thresh,
+ const double stopway,
+ const int surface_code,
+ const bool reciprocal);
+
+ /**
+ * given a runway identifier (06, 18L, 31R) compute the identifier for the
+ * reciprocal heading runway (24, 36R, 13L) string.
+ */
+ static std::string reverseIdent(const std::string& aRunayIdent);
+
+ /**
+ * score this runway according to the specified weights. Used by
+ * FGAirport::findBestRunwayForHeading
+ */
+ double score(double aLengthWt, double aWidthWt, double aSurfaceWt) const;
+
+ /**
+ * Test if this runway is the reciprocal. This allows users who iterate
+ * over runways to avoid counting runways twice, if desired.
+ */
+ bool isReciprocal() const
+ { return _reciprocal; }
+
+ /**
+ * Test if this is a taxiway or not
+ */
+ bool isTaxiway() const;
+
+ /**
+ * Get the runway threshold point - this is syntatic sugar, equivalent to
+ * calling pointOnCenterline(0.0);
+ */
+ SGGeod threshold() const;
+
+ /**
+ * Get the (possibly displaced) threshold point.
+ */
+ SGGeod displacedThreshold() const;
+
+ /**
+ * Get the opposite threshold - this is equivalent to calling
+ * pointOnCenterline(lengthFt());
+ */
+ SGGeod reverseThreshold() const;
+
+ /**
+ * Retrieve a position on the extended runway centerline. Positive values
+ * are in the direction of the runway heading, negative values are in the
+ * opposited direction. 0.0 corresponds to the (non-displaced) threshold
+ */
+ SGGeod pointOnCenterline(double aOffset) const;
+
+ /**
+ * Runway length in ft
+ */
+ double lengthFt() const
+ { return _length; }
+
+ double lengthM() const
+ { return _length * SG_FEET_TO_METER; }
+
+ double widthFt() const
+ { return _width; }
+
+ double widthM() const
+ { return _width * SG_FEET_TO_METER; }
+
+ double displacedThresholdM() const
+ { return _displ_thresh * SG_FEET_TO_METER; }
+
+ double stopwayM() const
+ { return _stopway * SG_FEET_TO_METER; }
+
+ /**
+ * Runway heading in degrees.
+ */
+ double headingDeg() const
+ { return _heading; }
+
+ /**
+ * Airport this runway is located at
+ */
+ FGAirport* airport() const
+ { return _airport; }
+
+ // FIXME - should die once airport / runway creation is cleaned up
+ void setAirport(FGAirport* aAirport)
+ { _airport = aAirport; }
+
+ /**
+ * Predicate to test if this runway has a hard surface. For the moment, this
+ * means concrete or asphalt
+ */
+ bool isHardSurface() const;
+
+ /**
+ * Retrieve runway surface code, as define in Robin Peel's data
+ */
+ int surface() const
+ { return _surface_code; }
};
-
#endif // _FG_RUNWAYS_HXX