1
0
Fork 0

KLN89: Fix ARINC 424 loader for airports with parallel runways.

To load approach data into the KLN89, drop an ARINC 424 format file
named "rnav.dat" into the data/Navaids directory.  The loader has
been tested on the 424-18 data revision, so may need tweaking for
the latest data.  Currently about 97% of the listed US non-precision
approaches are loaded, the majority of the failures appear to be due
to 1-digit runway code offsets between the flightgear airport data
and the ARINC data due to magnetic variation changes.
This commit is contained in:
Dave Luff 2010-12-05 10:57:36 +00:00
parent ca7f9dec76
commit d1601ff8b2

View file

@ -601,7 +601,8 @@ string DCLGPS::ExpandSIAPIdent(const string& ident) {
} }
/* /*
Load instrument approaches from an ARINC 424-18 file. Load instrument approaches from an ARINC 424 file.
Tested on ARINC 424-18.
Known / current best guess at the format: Known / current best guess at the format:
Col 1: Always 'S'. If it isn't, ditch it. Col 1: Always 'S'. If it isn't, ditch it.
Col 2-4: "Customer area" code, eg "USA", "CAN". I think that CAN is used for Alaska. Col 2-4: "Customer area" code, eg "USA", "CAN". I think that CAN is used for Alaska.
@ -672,10 +673,10 @@ void DCLGPS::LoadApproachData() {
path.append("Navaids/rnav.dat"); path.append("Navaids/rnav.dat");
fin.open(path.c_str(), ios::in); fin.open(path.c_str(), ios::in);
if(!fin) { if(!fin) {
cout << "Unable to open input file " << path.c_str() << '\n'; //cout << "Unable to open input file " << path.c_str() << '\n';
return; return;
} else { } else {
cout << "Opened " << path.c_str() << " for reading\n"; //cout << "Opened " << path.c_str() << " for reading\n";
} }
char tmp[256]; char tmp[256];
string s; string s;
@ -726,7 +727,7 @@ void DCLGPS::LoadApproachData() {
if(last_apt_ident != apt_ident) { if(last_apt_ident != apt_ident) {
if(iap_in_progress) { if(iap_in_progress) {
if(iap_error) { if(iap_error) {
cout << "ERROR: Unable to load approach " << iap->_ident << " at " << iap->_aptIdent << '\n'; //cout << "ERROR: Unable to load approach " << iap->_ident << " at " << iap->_aptIdent << '\n';
nErrors++; nErrors++;
} else { } else {
_np_iap[iap->_aptIdent].push_back(iap); _np_iap[iap->_aptIdent].push_back(iap);
@ -756,7 +757,7 @@ void DCLGPS::LoadApproachData() {
// This is a new approach - store the last one and trigger // This is a new approach - store the last one and trigger
// starting afresh by setting the in progress flag to false. // starting afresh by setting the in progress flag to false.
if(iap_error) { if(iap_error) {
cout << "ERROR: Unable to load approach " << iap->_ident << " at " << iap->_aptIdent << '\n'; //cout << "ERROR: Unable to load approach " << iap->_ident << " at " << iap->_aptIdent << '\n';
nErrors++; nErrors++;
} else { } else {
_np_iap[iap->_aptIdent].push_back(iap); _np_iap[iap->_aptIdent].push_back(iap);
@ -803,13 +804,21 @@ void DCLGPS::LoadApproachData() {
// Note: Currently fgFindAirportID returns NULL on error, but getRunwayByIdent throws an exception. // Note: Currently fgFindAirportID returns NULL on error, but getRunwayByIdent throws an exception.
const FGAirport* apt = fgFindAirportID(iap->_aptIdent); const FGAirport* apt = fgFindAirportID(iap->_aptIdent);
if(apt) { if(apt) {
string rwystr;
try { try {
// TODO - sanity check the waypoint ID to ensure we have a double digit number rwystr = w.id.substr(2, 2);
FGRunway* rwy = apt->getRunwayByIdent(w.id.substr(2, 2)); // TODO - sanity check the rwystr at this point to ensure we have a double digit number
if(w.id.size() > 4) {
if(w.id[4] == 'L' || w.id[4] == 'C' || w.id[4] == 'R') {
rwystr += w.id[4];
}
}
FGRunway* rwy = apt->getRunwayByIdent(rwystr);
w.lat = rwy->begin().getLatitudeRad(); w.lat = rwy->begin().getLatitudeRad();
w.lon = rwy->begin().getLongitudeRad(); w.lon = rwy->begin().getLongitudeRad();
} catch(const sg_exception&) { } catch(const sg_exception&) {
SG_LOG(SG_GENERAL, SG_WARN, "Unable to find runway " << w.id.substr(2, 2) << " at airport " << iap->_aptIdent); SG_LOG(SG_GENERAL, SG_WARN, "Unable to find runway " << w.id.substr(2, 2) << " at airport " << iap->_aptIdent);
//cout << "Unable to find runway " << w.id.substr(2, 2) << " at airport " << iap->_aptIdent << " ( w.id = " << w.id << ", rwystr = " << rwystr << " )\n";
wp_error = true; wp_error = true;
} }
} else { } else {
@ -850,7 +859,7 @@ void DCLGPS::LoadApproachData() {
if(iap->_IAP[iap->_IAP.size() - 1]->appType == GPS_APP_NONE) { if(iap->_IAP[iap->_IAP.size() - 1]->appType == GPS_APP_NONE) {
iap->_IAP[iap->_IAP.size() - 1]->appType = GPS_MAHP; iap->_IAP[iap->_IAP.size() - 1]->appType = GPS_MAHP;
} else { } else {
cout << "Waypoint is MAHP and another type! " << w.id << " [" << apt_ident << ", " << iap_ident << "]\n"; //cout << "Waypoint is MAHP and another type! " << w.id << " [" << apt_ident << ", " << iap_ident << "]\n";
} }
} }
} }
@ -922,7 +931,7 @@ void DCLGPS::LoadApproachData() {
// This is a new approach - store the last one and trigger // This is a new approach - store the last one and trigger
// starting afresh by setting the in progress flag to false. // starting afresh by setting the in progress flag to false.
if(iap_error) { if(iap_error) {
cout << "ERROR: Unable to load approach " << iap->_ident << " at " << iap->_aptIdent << '\n'; //cout << "ERROR: Unable to load approach " << iap->_ident << " at " << iap->_aptIdent << '\n';
nErrors++; nErrors++;
} else { } else {
_np_iap[iap->_aptIdent].push_back(iap); _np_iap[iap->_aptIdent].push_back(iap);
@ -940,7 +949,7 @@ void DCLGPS::LoadApproachData() {
// TODO - sanity check that the approach has all the required elements // TODO - sanity check that the approach has all the required elements
if(iap_in_progress) { if(iap_in_progress) {
if(iap_error) { if(iap_error) {
cout << "ERROR: Unable to load approach " << iap->_ident << " at " << iap->_aptIdent << '\n'; //cout << "ERROR: Unable to load approach " << iap->_ident << " at " << iap->_aptIdent << '\n';
nErrors++; nErrors++;
} else { } else {
_np_iap[iap->_aptIdent].push_back(iap); _np_iap[iap->_aptIdent].push_back(iap);
@ -949,9 +958,9 @@ void DCLGPS::LoadApproachData() {
} }
} }
cout << "Done loading approach database\n"; //cout << "Done loading approach database\n";
cout << "Loaded: " << nLoaded << '\n'; //cout << "Loaded: " << nLoaded << '\n';
cout << "Failed: " << nErrors << '\n'; //cout << "Failed: " << nErrors << '\n';
fin.close(); fin.close();
} }