示例#1
0
 /// <summary>
 /// Add one record to the table
 /// </summary>
 /// <param name="rec"></param>
 public string Add(apRec rec)
 {
     if (rec != null)
     {
         if (rec.apt_icao_code == "children")
         {
             return("");                                        // get rid of special element
         }
         AddICAOfromIATA(rec.apt_iata_code, rec.apt_icao_code); // helper to lookup ICAOs from IATA
         return(m_db.Add(rec));
     }
     return("");
 }
示例#2
0
        /// <summary>
        /// Returns a subtable with items that match the given criteria
        /// </summary>
        /// <param name="rangeLimitNm">Range Limit in nm</param>
        /// <param name="Lat">Center Lat (decimal)</param>
        /// <param name="Lon">Center Lon (decimal)</param>
        /// <param name="aptTypes">Type of airport items to include</param>
        /// <returns>A table with selected records</returns>
        public apTable GetSubtable(double rangeLimitNm, double Lat, double Lon, AptTypes[] aptTypes = null)
        {
            if (aptTypes == null)
            {
                aptTypes = new AptTypes[] { AptTypes.All }
            }
            ;

            var nT    = new apTable( );
            var myLoc = new LatLon(Lat, Lon);

            foreach (var rec in this)
            {
                var dist = myLoc.DistanceTo(new LatLon(double.Parse(rec.Value.lat), double.Parse(rec.Value.lon)), ConvConsts.EarthRadiusNm);
                if ((dist <= rangeLimitNm) && (rec.Value.IsTypeOf(aptTypes)))
                {
                    nT.Add(rec.Value);
                }
            }
            return(nT);
        }
    }