From 0112b2454094b9f8147e2b8c87e9093e017c50f3 Mon Sep 17 00:00:00 2001 From: daveluff Date: Sat, 24 Oct 2009 19:36:12 +0000 Subject: [PATCH] Expand SIAP idents as found in FAA ARINC dataset to the full approach name as shown on the approach chart and possibly the GPS --- src/Instrumentation/KLN89/kln89_page_apt.cxx | 16 ++-- src/Instrumentation/dclgps.cxx | 83 ++++++++++++++++++-- src/Instrumentation/dclgps.hxx | 9 ++- 3 files changed, 92 insertions(+), 16 deletions(-) diff --git a/src/Instrumentation/KLN89/kln89_page_apt.cxx b/src/Instrumentation/KLN89/kln89_page_apt.cxx index a4ed0a6dc..db4a8c115 100644 --- a/src/Instrumentation/KLN89/kln89_page_apt.cxx +++ b/src/Instrumentation/KLN89/kln89_page_apt.cxx @@ -353,9 +353,9 @@ void KLN89AptPage::Update(double dt) { _kln89->DrawText("For This Airport", 2, 0, 0); } else { if(_iafDialog) { - _kln89->DrawText(_iaps[_curIap]->_abbrev, 2, 1, 3); + _kln89->DrawText(_iaps[_curIap]->_ident, 2, 1, 3); _kln89->DrawText(_iaps[_curIap]->_rwyStr, 2, 7, 3); - _kln89->DrawText(_iaps[_curIap]->_id, 2, 12, 3); + _kln89->DrawText(_iaps[_curIap]->_aptIdent, 2, 12, 3); _kln89->DrawText("IAF", 2, 2, 2); unsigned int line = 0; for(unsigned int i=_iafStart; i<_approachRoutes.size(); ++i) { @@ -376,9 +376,9 @@ void KLN89AptPage::Update(double dt) { _kln89->DrawEnt(); } } else if(_addDialog) { - _kln89->DrawText(_iaps[_curIap]->_abbrev, 2, 1, 3); + _kln89->DrawText(_iaps[_curIap]->_ident, 2, 1, 3); _kln89->DrawText(_iaps[_curIap]->_rwyStr, 2, 7, 3); - _kln89->DrawText(_iaps[_curIap]->_id, 2, 12, 3); + _kln89->DrawText(_iaps[_curIap]->_aptIdent, 2, 12, 3); string s = GPSitoa(_fStart + 1); _kln89->DrawText(s, 2, 2-s.size(), 2); s = GPSitoa(_kln89->_approachFP->waypoints.size()); @@ -399,9 +399,9 @@ void KLN89AptPage::Update(double dt) { } } } else if(_replaceDialog) { - _kln89->DrawText(_iaps[_curIap]->_abbrev, 2, 1, 3); + _kln89->DrawText(_iaps[_curIap]->_ident, 2, 1, 3); _kln89->DrawText(_iaps[_curIap]->_rwyStr, 2, 7, 3); - _kln89->DrawText(_iaps[_curIap]->_id, 2, 12, 3); + _kln89->DrawText(_iaps[_curIap]->_aptIdent, 2, 12, 3); _kln89->DrawText("Replace Existing", 2, 0, 2); _kln89->DrawText("Approach", 2, 4, 1); if(_uLinePos > 0 && !(_kln89->_blink)) { @@ -421,7 +421,7 @@ void KLN89AptPage::Update(double dt) { string s = GPSitoa(i+1); _kln89->DrawText(s, 2, 2 - s.size(), 2-i); if(!(selApp && _uLinePos == 5+i && _kln89->_blink)) { - _kln89->DrawText(_iaps[i]->_abbrev, 2, 3, 2-i); + _kln89->DrawText(_iaps[i]->_ident, 2, 3, 2-i); _kln89->DrawText(_iaps[i]->_rwyStr, 2, 9, 2-i); } if(selApp && _uLinePos == 5+i && !_kln89->_blink) { @@ -702,7 +702,7 @@ void KLN89AptPage::EntPressed() { _kln89->_activeFP->waypoints.insert(_kln89->_activeFP->waypoints.end(), _kln89->_approachFP->waypoints.begin(), _kln89->_approachFP->waypoints.end()); } _kln89->_approachID = _apt_id; - _kln89->_approachAbbrev = _iaps[_curIap]->_abbrev; + _kln89->_approachAbbrev = _iaps[_curIap]->_ident; _kln89->_approachRwyStr = _iaps[_curIap]->_rwyStr; _kln89->_approachLoaded = true; //_kln89->_messageStack.push_back("*Press ALT To Set Baro"); diff --git a/src/Instrumentation/dclgps.cxx b/src/Instrumentation/dclgps.cxx index da43c4970..4a2ccabf3 100644 --- a/src/Instrumentation/dclgps.cxx +++ b/src/Instrumentation/dclgps.cxx @@ -248,9 +248,9 @@ void DCLGPS::init() { const GPSWaypoint* cwp; iap = new FGNPIAP; - iap->_id = "KHAF"; - iap->_name = "RNAV (GPS) Y RWY 12"; - iap->_abbrev = "R12-Y"; + iap->_aptIdent = "KHAF"; + iap->_ident = "R12-Y"; + iap->_name = ExpandSIAPIdent(iap->_ident); iap->_rwyStr = "12"; iap->_approachRoutes.clear(); iap->_IAP.clear(); @@ -298,7 +298,7 @@ void DCLGPS::init() { wp->appType = GPS_MAP; if(wp->id.substr(0, 2) == "RW" && wp->appType == GPS_MAP) { // Assume that this is a missed-approach point based on the runway number, which appears to be standard for most approaches. - const FGAirport* apt = fgFindAirportID(iap->_id); + const FGAirport* apt = fgFindAirportID(iap->_aptIdent); if(apt) { // TODO - sanity check the waypoint ID to ensure we have a double digit number FGRunway* rwy = apt->getRunwayByIdent(wp->id.substr(2, 2)); @@ -329,7 +329,7 @@ void DCLGPS::init() { //cout << "Unable to find waypoint " << wp->id << '\n'; } // ------- - _np_iap[iap->_id].push_back(iap); + _np_iap[iap->_aptIdent].push_back(iap); } void DCLGPS::bind() { @@ -613,6 +613,79 @@ void DCLGPS::update(double dt) { } } +/* + Expand a SIAP ident to the full procedure name (as shown on the approach chart). + NOTE: Some of this is inferred from data, some is from documentation. + + Example expansions from ARINC 424-18 [and the airport they're taken from]: + "R10LY" <--> "RNAV (GPS) Y RWY 10 L" [KBOI] + "R10-Z" <--> "RNAV (GPS) Z RWY 10" [KHTO] + "S25" <--> "VOR or GPS RWY 25" [KHHR] + "P20" <--> "GPS RWY 20" [KDAN] + "NDB-B" <--> "NDB or GPS-B" [KDAW] + "NDBC" <--> "NDB or GPS-C" [KEMT] + "VDMA" <--> "VOR/DME or GPS-A" [KDAW] + "VDM-A" <--> "VOR/DME or GPS-A" [KEAG] + "VDMB" <--> "VOR/DME or GPS-B" [KDKX] + "VORA" <--> "VOR or GPS-A" [KEMT] + + It seems that there are 2 basic types of expansions; those that include + the runway and those that don't. Of those that don't, it seems that 2 + different positions within the string to encode the identifying letter + are used, i.e. with a dash and without. +*/ +string DCLGPS::ExpandSIAPIdent(const string& ident) { + string name; + bool has_rwy; + + switch(ident[0]) { + case 'N': name = "NDB or GPS"; has_rwy = false; break; + case 'P': name = "GPS"; has_rwy = true; break; + case 'R': name = "RNAV (GPS)"; has_rwy = true; break; + case 'S': name = "VOR or GPS"; has_rwy = true; break; + case 'V': + if(ident[1] == 'D') name = "VOR/DME or GPS"; + else name = "VOR or GPS"; + has_rwy = false; + break; + default: // TODO output a log message + break; + } + + if(has_rwy) { + // Add the identifying letter if present + if(ident.size() == 5) { + name += ' '; + name += ident[4]; + } + + // Add the runway + name += " RWY "; + name += ident.substr(1, 2); + + // Add a left/right/centre indication if present. + if(ident.size() > 3) { + if((ident[3] != '-') && (ident[3] != ' ')) { // Early versions of the spec allowed a blank instead of a dash so check for both + name += ' '; + name += ident[3]; + } + } + } else { + // Add the identifying letter, which I *think* should always be present, but seems to be inconsistent as to whether a dash is used. + if(ident.size() == 5) { + name += '-'; + name += ident[4]; + } else if(ident.size() == 4) { + name += '-'; + name += ident[3]; + } else { + // No suffix letter + } + } + + return(name); +} + GPSWaypoint* DCLGPS::GetActiveWaypoint() { return &_activeWaypoint; } diff --git a/src/Instrumentation/dclgps.hxx b/src/Instrumentation/dclgps.hxx index 4c0b1a6fa..9594304e6 100644 --- a/src/Instrumentation/dclgps.hxx +++ b/src/Instrumentation/dclgps.hxx @@ -126,9 +126,9 @@ public: virtual ~FGIAP() = 0; //protected: - string _id; // The ID of the airport this approach is for - string _name; // The approach name, eg "VOR/DME OR GPS-B" - string _abbrev; // The abbreviation the GPS unit uses - eg "VOR/D" in this instance. Possibly GPS model specific. + string _aptIdent; // The ident of the airport this approach is for + string _ident; // The approach ident. + string _name; // The full approach name. string _rwyStr; // The string used to specify the rwy - eg "B" in this instance. bool _precision; // True for precision approach, false for non-precision. }; @@ -200,6 +200,9 @@ public: virtual void bind(); virtual void unbind(); virtual void update(double dt); + + // Expand a SIAP ident to the full procedure name. + string ExpandSIAPIdent(const string& ident); // Render string s in display field field at position x, y // WHERE POSITION IS IN CHARACTER UNITS! -- 2.39.5