X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FAirports%2Frunways.hxx;h=e6f97ea95d7790c30898fbcd6e4ec9c7a5bc865d;hb=386aefe69358ce41a11c9afeb8f56e26758fe56b;hp=b2fc3533282fbeb36d55da028b6a9f847fdf9b0a;hpb=62a359cc4a338b2f8b720edf8183ab5b69710b14;p=flightgear.git diff --git a/src/Airports/runways.hxx b/src/Airports/runways.hxx index b2fc35332..e6f97ea95 100644 --- a/src/Airports/runways.hxx +++ b/src/Airports/runways.hxx @@ -16,7 +16,7 @@ // // 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$ @@ -24,102 +24,97 @@ #ifndef _FG_RUNWAYS_HXX #define _FG_RUNWAYS_HXX - -#ifndef __cplusplus -# error This library requires C++ -#endif - - -#ifdef HAVE_CONFIG_H -# include -#endif - #include -#include STL_STRING -#include - -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 _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 FGRunwayList { - -private: - - runway_map runways; - runway_map_iterator current; - +#include + +// forward decls +class FGAirport; +class FGNavRecord; +class SGPropertyNode; + +class FGRunway : public FGRunwayBase +{ + FGAirport* _airport; + bool _isReciprocal; + FGRunway* _reciprocal; + double _displ_thresh; + double _stopway; + FGNavRecord* _ils; public: - - // Constructor (new) - FGRunwayList() {} - - // Destructor - ~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. - // 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 _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 // _FG_RUNWAYS_HXX