Fix test: find airways.
Fix handling of ‘both’ level option in several places, and amend the test to make it explicit that we want Clacton VOR, not NDB.
This commit is contained in:
parent
ae5b17920c
commit
2f4b2153ef
3 changed files with 30 additions and 22 deletions
|
@ -2275,13 +2275,15 @@ NavDataCache::findILS(PositionedID airport, const string& aRunway, const string&
|
|||
|
||||
int NavDataCache::findAirway(int network, const string& aName, bool create)
|
||||
{
|
||||
sqlite3_bind_int(d->findAirwayNet, 1, network);
|
||||
sqlite_bind_stdstring(d->findAirwayNet, 2, aName);
|
||||
assert((network == 1) || (network == 2));
|
||||
|
||||
int airway = 0;
|
||||
if (d->execSelect(d->findAirwayNet)) {
|
||||
// already exists
|
||||
airway = sqlite3_column_int(d->findAirwayNet, 0);
|
||||
sqlite3_bind_int(d->findAirwayNet, 1, network);
|
||||
sqlite_bind_stdstring(d->findAirwayNet, 2, aName);
|
||||
|
||||
int airway = 0;
|
||||
if (d->execSelect(d->findAirwayNet)) {
|
||||
// already exists
|
||||
airway = sqlite3_column_int(d->findAirwayNet, 0);
|
||||
} else if (create) {
|
||||
d->reset(d->insertAirway);
|
||||
sqlite_bind_stdstring(d->insertAirway, 1, aName);
|
||||
|
|
|
@ -123,6 +123,7 @@ Airway::Airway(const std::string& aIdent,
|
|||
_topAltitudeFt(aTop),
|
||||
_bottomAltitudeFt(aBottom)
|
||||
{
|
||||
assert((level == HighLevel) || (level == LowLevel));
|
||||
static_airwaysCache.push_back(this);
|
||||
}
|
||||
|
||||
|
@ -302,15 +303,25 @@ AirwayRef Airway::findByIdent(const std::string& aIdent, Level level)
|
|||
return *it;
|
||||
}
|
||||
|
||||
NavDataCache* ndc = NavDataCache::instance();
|
||||
int airwayId = ndc->findAirway(level, aIdent, false);
|
||||
if (airwayId == 0) {
|
||||
return {};
|
||||
auto ndc = NavDataCache::instance();
|
||||
int airwayId = 0;
|
||||
if (level == Both) {
|
||||
airwayId = ndc->findAirway(HighLevel, aIdent, false);
|
||||
if (airwayId == 0) {
|
||||
level = LowLevel; // not found in HighLevel, try LowLevel
|
||||
} else {
|
||||
level = HighLevel; // fix up, so Airway ctro see a valid value
|
||||
}
|
||||
}
|
||||
|
||||
AirwayRef awy(new Airway(aIdent, level, airwayId, 0, 0));
|
||||
static_airwaysCache.push_back(awy);
|
||||
return awy;
|
||||
if (airwayId == 0) {
|
||||
airwayId = ndc->findAirway(level, aIdent, false);
|
||||
if (airwayId == 0) {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
return ndc->loadAirway(airwayId);
|
||||
}
|
||||
|
||||
AirwayRef Airway::loadByCacheId(int cacheId)
|
||||
|
@ -321,14 +332,9 @@ AirwayRef Airway::findByIdent(const std::string& aIdent, Level level)
|
|||
if (it != static_airwaysCache.end()) {
|
||||
return *it;
|
||||
}
|
||||
|
||||
NavDataCache* ndc = NavDataCache::instance();
|
||||
AirwayRef awy = ndc->loadAirway(cacheId);
|
||||
if (awy) {
|
||||
static_airwaysCache.push_back(awy);
|
||||
}
|
||||
|
||||
return awy;
|
||||
|
||||
return NavDataCache::instance()->loadAirway(cacheId);
|
||||
;
|
||||
}
|
||||
|
||||
void Airway::loadWaypoints() const
|
||||
|
|
|
@ -302,7 +302,7 @@ void FPNasalTests::testAirwaysAPI()
|
|||
unitTest.assert(airwayStore.id == airwayIdent, "Incorrect airway found");
|
||||
|
||||
airwayIdent = "UL620";
|
||||
var cln = findNavaidsByID("CLN")[0];
|
||||
var cln = findNavaidsByID("CLN", "VOR")[0];
|
||||
airwayStore = airway(airwayIdent, cln);
|
||||
unitTest.assert(airwayStore != nil, "Airway " ~ airwayIdent ~ " not found");
|
||||
unitTest.assert(airwayStore.id == airwayIdent, "Incorrect airway found");
|
||||
|
|
Loading…
Add table
Reference in a new issue