示例#1
0
        /// <summary>
        /// Reads the XPlane 11 earth_awy.dat file and populates the supplied database
        /// </summary>
        /// <param name="db">The awyDatabase to fill</param>
        /// <param name="path">The file to read</param>
        /// <returns>The result string, either empty or error</returns>
        public static string ReadDb(ref aptDatabase db, string path)
        {
            if (!Directory.Exists(path))
            {
                return($"Directory does not exist\n");
            }

            string ret = "";

            foreach (var f in Directory.EnumerateFiles(path))
            {
                var e = ReadDbFile(ref db, f);
                if (!string.IsNullOrEmpty(e))
                {
                    ret += $"{e}\n"; // collect errors
                }
            }
            return(ret);
        }
示例#2
0
        /// <summary>
        /// Reads one file to fill the db
        /// </summary>
        /// <param name="db">The awyDatabase to fill</param>
        /// <param name="fName">The qualified filename</param>
        /// <returns>The result string, either empty or error</returns>
        private static string ReadDbFile(ref aptDatabase db, string fName)
        {
            var    icaoPre = Path.GetFileNameWithoutExtension(fName);
            string ret     = "";

            using (var sr = new StreamReader(fName)) {
                do
                {
                    string buffer = sr.ReadLine( );
                    if (buffer.StartsWith("RWY:"))
                    {
                        var rec = FromNative(buffer, Path.GetFileNameWithoutExtension(fName));
                        if (rec != null && rec.IsValid)
                        {
                            ret += db.Add(rec); // collect adding information
                        }
                    }
                } while (!sr.EndOfStream);
                //
            }
            return(ret);
        }