Example #1
0
        /// <summary>
        /// Reads one file to fill the db
        /// </summary>
        /// <param name="db">The navDatabase to fill</param>
        /// <param name="fName">The qualified filename</param>
        /// <returns>The result string, either empty or error</returns>
        private static string ReadDbFile(ref navDatabase db, string fName)
        {
            var    icaoPre = Path.GetFileNameWithoutExtension(fName);
            string ret     = "";

            using (var sr = new StreamReader(fName)) {
                string buffer = sr.ReadLine( ); // header line
                buffer = sr.ReadLine( );        // header line 2
                buffer = sr.ReadLine( );
                while (!sr.EndOfStream)
                {
                    if (buffer.StartsWith("99"))
                    {
                        break;
                    }
                    var rec = FromNative(buffer);
                    if (rec != null && rec.IsValid)
                    {
                        ret += db.Add(rec); // collect adding information
                    }
                    buffer = sr.ReadLine( );
                }
                //
            }
            return(ret);
        }
Example #2
0
        /// <summary>
        /// Reads the XPlane 11 earth_nav.dat file and populates the supplied database
        /// </summary>
        /// <param name="db">The navDatabase to fill</param>
        /// <param name="fName">The file to read</param>
        /// <returns>The result string, either empty or error</returns>
        public static string ReadDb(ref navDatabase db, string fName)
        {
            if (!File.Exists(fName))
            {
                return($"File does not exist\n");
            }

            return(ReadDbFile(ref db, fName));
        }