]> git.mxchange.org Git - flightgear.git/blobdiff - src/Navaids/NavDataCache.cxx
Run the filters for comm/navaids as required.
[flightgear.git] / src / Navaids / NavDataCache.cxx
index e073f863f1b0f478ecb8683297d5f217e668f642..bcc82a2609c7e7a44a62599ec2707f8fa79a00a9 100644 (file)
@@ -646,7 +646,7 @@ public:
     int range = sqlite3_column_int(loadCommStation, 0);
     int freqKhz = sqlite3_column_int(loadCommStation, 1);
     
-    CommStation* c = new CommStation(rowId, id, ty, pos, freqKhz, range);
+    CommStation* c = new CommStation(rowId, name, ty, pos, freqKhz, range);
     c->setAirport(airport);
     return c;
   }
@@ -929,10 +929,10 @@ NavDataCache::NavDataCache()
     // reached this point with no exception, success
       break;
     } catch (sg_exception& e) {
-      SG_LOG(SG_NAVCACHE, SG_WARN, "NavCache: init failed:" << e.what()
+      SG_LOG(SG_NAVCACHE, t == 0 ? SG_WARN : SG_ALERT, "NavCache: init failed:" << e.what()
              << " (attempt " << t << ")");
-      homePath.remove();
       d.reset();
+      homePath.remove();
     }
   } // of retry loop
     
@@ -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