Esempio n. 1
0
//------------------------------------------------------------------------------
// queryAirport() -- find airports within search area with minimum runway
// length and airport type.
//------------------------------------------------------------------------------
int AirportLoader::queryAirport(const Airport::AirportType type, const float minRwLen)
{
   double mr2(FLT_MAX);
   if (mrng > 0.0f) mr2 = mrng*mrng;
   
   // compute range**2 to ref point and select all that have range less
   // than maxRange
   nql = 0;
   for (int i = 0; i < nrl; i++) {
      AirportKey* k = static_cast<AirportKey*>(rl[i]);
      if ( type == k->type || type == Airport::ANY ) {
         k->rng2 = range2(k->lat,k->lon);
         if (k->rng2 < mr2) {
            if ( chkRwLen( k, minRwLen ) ) {
               ql[nql++] = k;
            }
         }
      }
   }

   // sort and limit by range
   rangeSort2();

   // limit number of result records
   if (qlimit > 0 && nql > qlimit) nql = qlimit;

   return nql;
}
Esempio n. 2
0
//------------------------------------------------------------------------------
// queryRunwayByChannel() -- find all airports within search area with 'chan'
// channel ILS components.
//------------------------------------------------------------------------------
int AirportLoader::queryRunwayByChannel(const int chan)
{
   double mr2(FLT_MAX);
   if (mrng > 0.0f) mr2 = mrng*mrng;
   
   // compute range**2 to ref point and select all that have range less
   // than maxRange
   nql = 0;
   for (int i = 0; i < nrl; i++) {
      AirportKey* k = static_cast<AirportKey*>(rl[i]);
      k->rng2 = range2(k->lat,k->lon);
      if (k->rng2 < mr2) {
         for (RunwayKey* rwk = k->runways; rwk != 0; rwk = rwk->next) {
            if ( chkRwIlsChan( rwk, chan ) ) {
               ql[nql++] = rwk;
            }
         }
      }
   }

   // sort and limit by range
   rangeSort2();

   // limit number of result records
   if (qlimit > 0 && nql > qlimit) nql = qlimit;

   return nql;
}
Esempio n. 3
0
//------------------------------------------------------------------------------
// queryByFreq() -- find all airports within search area with 'freq' frequency
// ILS components.
//------------------------------------------------------------------------------
int AirportLoader::queryByFreq(const float freq)
{
   double mr2(FLT_MAX);
   if (mrng > 0.0f) mr2 = mrng*mrng;
   
   // compute range**2 to ref point and select all that have range less
   // than maxRange
   nql = 0;
   for (int i = 0; i < nrl; i++) {
      Key* k = rl[i];
      k->rng2 = range2(k->lat,k->lon);
      if (k->rng2 < mr2) {
         if ( chkIlsFreq(static_cast<AirportKey*>(k), freq ) ) {
            ql[nql++] = k;
         }
      }
   }

   // sort and limit by range
   rangeSort2();

   // limit number of result records
   if (qlimit > 0 && nql > qlimit) nql = qlimit;

   return nql;
}
// rangeSort: first compute range and then uses rangeSort2() to sort.
int Database::rangeSort()
{
   // compute ranges
   for (int i = 0; i < nql; i++) {
      Key* k = ql[i];
      k->rng2 = range2(k->lat,k->lon);
   }

   return rangeSort2();
}