From d4d1d827d0e7543091516479c8d370b2361ab2c4 Mon Sep 17 00:00:00 2001 From: jmt Date: Wed, 16 Sep 2009 00:17:12 +0000 Subject: [PATCH] Make FGRunway track reciprocal runways. --- src/Airports/apt_loader.cxx | 9 +++++++++ src/Airports/runways.cxx | 12 +++++++++++- src/Airports/runways.hxx | 9 +++++++-- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/Airports/apt_loader.cxx b/src/Airports/apt_loader.cxx index a8af8ca47..320a57150 100644 --- a/src/Airports/apt_loader.cxx +++ b/src/Airports/apt_loader.cxx @@ -286,6 +286,9 @@ private: displ_thresh2, stopway2, surface_code, true); runways.push_back(reciprocal); + + rwy->setReciprocalRunway(reciprocal); + reciprocal->setReciprocalRunway(rwy); } } @@ -335,6 +338,9 @@ private: pos, heading_2, length, width, displ_thresh2, stopway2, surface_code, true); runways.push_back(reciprocal); + + rwy->setReciprocalRunway(reciprocal); + reciprocal->setReciprocalRunway(rwy); } void parseWaterRunwayLine850(const vector& token) @@ -373,6 +379,9 @@ private: pos, heading_2, length, width, 0.0, 0.0, 13, true); runways.push_back(reciprocal); + + rwy->setReciprocalRunway(reciprocal); + reciprocal->setReciprocalRunway(rwy); } void parseHelipadLine850(const vector& token) diff --git a/src/Airports/runways.cxx b/src/Airports/runways.cxx index f97cd14e8..c076d8cfc 100644 --- a/src/Airports/runways.cxx +++ b/src/Airports/runways.cxx @@ -71,7 +71,8 @@ FGRunway::FGRunway(FGAirport* aAirport, const string& aIdent, bool reciprocal) : FGRunwayBase(RUNWAY, cleanRunwayNo(aIdent), aGeod, heading, length, width, surface_code, true), _airport(aAirport), - _reciprocal(reciprocal), + _isReciprocal(reciprocal), + _reciprocal(NULL), _displ_thresh(displ_thresh), _stopway(stopway), _ils(NULL) @@ -158,3 +159,12 @@ void FGRunway::processThreshold(SGPropertyNode* aThreshold) SGGeodesy::direct(newThreshold, _heading, offsetFt * SG_FEET_TO_METER, newCenter, dummy); mPosition = newCenter; } + +void FGRunway::setReciprocalRunway(FGRunway* other) +{ + assert(_reciprocal==NULL); + assert((other->_reciprocal == NULL) || (other->_reciprocal == this)); + + _reciprocal = other; +} + diff --git a/src/Airports/runways.hxx b/src/Airports/runways.hxx index 15d39c2af..e6f97ea95 100644 --- a/src/Airports/runways.hxx +++ b/src/Airports/runways.hxx @@ -36,7 +36,8 @@ class SGPropertyNode; class FGRunway : public FGRunwayBase { FGAirport* _airport; - bool _reciprocal; + bool _isReciprocal; + FGRunway* _reciprocal; double _displ_thresh; double _stopway; FGNavRecord* _ils; @@ -68,7 +69,7 @@ public: * over runways to avoid counting runways twice, if desired. */ bool isReciprocal() const - { return _reciprocal; } + { return _isReciprocal; } /** * Get the runway begining point - this is syntatic sugar, equivalent to @@ -106,6 +107,10 @@ public: 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 */