X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FAirports%2Frunways.hxx;h=e6f97ea95d7790c30898fbcd6e4ec9c7a5bc865d;hb=386aefe69358ce41a11c9afeb8f56e26758fe56b;hp=5512097d8d44e3c41e709d6db9ee437f79249c21;hpb=aea664cd1589e8170261f45413f3cd30788fe98b;p=flightgear.git diff --git a/src/Airports/runways.hxx b/src/Airports/runways.hxx index 5512097d8..e6f97ea95 100644 --- a/src/Airports/runways.hxx +++ b/src/Airports/runways.hxx @@ -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 @@ -16,151 +16,105 @@ // // 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 __cplusplus -# error This library requires C++ -#endif - - -#ifdef HAVE_CONFIG_H -# include -#endif +#ifndef _FG_RUNWAYS_HXX +#define _FG_RUNWAYS_HXX #include -#ifdef SG_HAVE_STD_INCLUDES -# include -#elif defined( SG_HAVE_NATIVE_SGI_COMPILERS ) -# include -#elif defined( __BORLANDC__ ) -# include -#else -# include -#endif - -#include STL_STRING -#include - -#ifndef _MSC_VER -#define NDEBUG // she don't work without it. -#endif // !_MSC_VER - -#include -#include - -#ifndef _MSC_VER -#undef NDEBUG -#endif // !_MSC_VER - -SG_USING_STD(string); -SG_USING_STD(vector); - -#if ! defined( SG_HAVE_NATIVE_SGI_COMPILERS ) -SG_USING_STD(istream); -#endif - +#include -class FGRunway { +// forward decls +class FGAirport; +class FGNavRecord; +class SGPropertyNode; -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(); - -}; - -inline istream& -operator >> ( istream& in, FGRunway& a ) +class FGRunway : public FGRunwayBase { - 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; -} - - -class FGRunways { - -private: - - c4_Storage *storage; - c4_View *vRunway; - int next_index; - -public: - - // Constructor - FGRunways( const string& file ); - - // Destructor - ~FGRunways(); - - // 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 ); - FGRunway search( const string& aptid ); - bool next( FGRunway* runway ); - FGRunway next(); -}; - - -class FGRunwaysUtil { -public: - typedef vector< FGRunway > container; - typedef container::iterator iterator; - typedef container::const_iterator const_iterator; - -private: - container runways; - + FGAirport* _airport; + bool _isReciprocal; + FGRunway* _reciprocal; + double _displ_thresh; + double _stopway; + FGNavRecord* _ils; 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(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 _isReciprocal; } + + /** + * Get the runway begining point - this is syntatic sugar, equivalent to + * calling pointOnCenterline(0.0); + */ + SGGeod begin() const; + + /** + * Get the (possibly displaced) threshold point. + */ + SGGeod threshold() const; + + /** + * Get the 'far' end - this is equivalent to calling + * pointOnCenterline(lengthFt()); + */ + SGGeod end() const; + + double displacedThresholdM() const + { return _displ_thresh * SG_FEET_TO_METER; } + + double stopwayM() const + { return _stopway * SG_FEET_TO_METER; } + + /** + * 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; } + + FGNavRecord* ILS() const { return _ils; } + void setILS(FGNavRecord* nav) { _ils = nav; } + + FGRunway* reciprocalRunway() const + { return _reciprocal; } + void setReciprocalRunway(FGRunway* other); + + /** + * Helper to process property data loaded from an ICAO.threshold.xml file + */ + void processThreshold(SGPropertyNode* aThreshold); }; - -#endif // _RUNWAYS_HXX +#endif // _FG_RUNWAYS_HXX