Run the filters for comm/navaids as required.
Apparently most filters are only filtering on type - we weren't running the filter body for navaid or comm-station lookups, causing weird ATIS bugs. Ensure that we actually run the filter at the point we have an FGPositioned* result.
This commit is contained in:
parent
bcea720db3
commit
5eb2f74e99
2 changed files with 27 additions and 6 deletions
|
@ -1530,11 +1530,16 @@ NavDataCache::findCommByFreq(int freqKhz, const SGGeod& aPos, FGPositioned::Filt
|
|||
sqlite3_bind_double(d->findCommByFreq, 5, cartPos.y());
|
||||
sqlite3_bind_double(d->findCommByFreq, 6, cartPos.z());
|
||||
|
||||
if (!d->execSelect(d->findCommByFreq)) {
|
||||
return NULL;
|
||||
while (d->execSelect(d->findCommByFreq)) {
|
||||
FGPositioned* p = loadById(sqlite3_column_int64(d->findCommByFreq, 0));
|
||||
if (aFilter && !aFilter->pass(p)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
return loadById(sqlite3_column_int64(d->findCommByFreq, 0));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PositionedIDVec
|
||||
|
|
|
@ -182,6 +182,10 @@ FGNavRecord *FGNavList::findByFreq( double freq, const SGGeod& position,
|
|||
|
||||
BOOST_FOREACH(PositionedID id, stations) {
|
||||
FGNavRecord* station = (FGNavRecord*) cache->loadById(id);
|
||||
if (!filter->pass(station)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
double d2 = distSqr(station->cart(), acCart);
|
||||
if (d2 > min_dist) {
|
||||
// since results are sorted by proximity, as soon as we pass the
|
||||
|
@ -201,13 +205,20 @@ FGNavRecord *FGNavList::findByFreq( double freq, const SGGeod& position,
|
|||
FGNavRecord *FGNavList::findByFreq( double freq, TypeFilter* filter)
|
||||
{
|
||||
flightgear::NavDataCache* cache = flightgear::NavDataCache::instance();
|
||||
int freqKhz = static_cast<int>(freq * 1000);
|
||||
int freqKhz = static_cast<int>(freq * 100);
|
||||
PositionedIDVec stations(cache->findNavaidsByFreq(freqKhz, filter));
|
||||
if (stations.empty()) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return (FGNavRecord*) cache->loadById(stations.front());
|
||||
BOOST_FOREACH(PositionedID id, stations) {
|
||||
FGNavRecord* station = (FGNavRecord*) cache->loadById(id);
|
||||
if (filter->pass(station)) {
|
||||
return station;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
nav_list_type FGNavList::findAllByFreq( double freq, const SGGeod& position,
|
||||
|
@ -220,7 +231,12 @@ nav_list_type FGNavList::findAllByFreq( double freq, const SGGeod& position,
|
|||
PositionedIDVec ids(cache->findNavaidsByFreq(freqKhz, position, filter));
|
||||
|
||||
BOOST_FOREACH(PositionedID id, ids) {
|
||||
stations.push_back((FGNavRecord*) cache->loadById(id));
|
||||
FGNavRecord* station = (FGNavRecord*) cache->loadById(id);
|
||||
if (!filter->pass(station)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
stations.push_back(station);
|
||||
}
|
||||
|
||||
return stations;
|
||||
|
|
Loading…
Add table
Reference in a new issue