コード例 #1
0
        public static void WriteAPT(string path)
        {
            // Output looks like:
            // icao freq lat long class
            string    strOut;
            string    FacID;
            string    Lat; string Lon;
            DataTable APT   = Form1.APT;
            DataTable TWR   = Form1.TWR;
            DataView  dvTWR = new DataView(TWR);
            DataView  dvAPT = new DataView(APT)
            {
                RowFilter = "[Selected]",
                Sort      = "FacilityID"
            };
            // Output only what we need
            DataTable dataTable = dvAPT.ToTable(true, "ID", "FacilityID", "ICAO", "Latitude", "Longitude", "Name", "Public");
            DataRow   foundRow; string LCL; string Class;

            using (StreamWriter sw = new StreamWriter(path))
            {
                sw.WriteLine(CycleHeader);
                sw.WriteLine("[AIRPORT]");
                foreach (DataRow row in dataTable.AsEnumerable())
                {
                    FacID = row["FacilityID"].ToString();
                    if (row["ICAO"].ToString().Length > 0)
                    {
                        FacID = row["ICAO"].ToString();
                    }
                    LCL        = "122.800";
                    Class      = "G";
                    dvTWR.Sort = "ID";
                    foundRow   = TWR.Rows.Find(row["ID"]);
                    if (foundRow != null)
                    {
                        LCL   = foundRow["LCLfreq"].ToString();
                        Class = foundRow["Class"].ToString();
                    }
                    Lat    = Conversions.DecDeg2SCT(Convert.ToSingle(row["Latitude"]), true);
                    Lon    = Conversions.DecDeg2SCT(Convert.ToSingle(row["Longitude"]), false);
                    strOut = FacID.PadRight(4) + " " + LCL.PadRight(7) + " " + Lat + " " + Lon + " " + Class;
                    sw.WriteLine(strOut);
                }
            }
            dvAPT.Dispose();
        }
コード例 #2
0
        public static void WriteAPT(string path)
        {
            string[]  strOut = new string[7]; string ATIStype = "ATIS";
            DataTable APT   = Form1.APT;
            DataTable TWR   = Form1.TWR;
            DataView  dvTWR = new DataView(TWR);
            DataView  dvAPT = new DataView(APT)
            {
                RowFilter = "[Selected]",
                Sort      = "FacilityID"
            };
            // Output only what we need
            DataTable dataTable = dvAPT.ToTable(true, "ID", "FacilityID", "ICAO", "Latitude", "Longitude", "Name", "Public");
            DataRow   foundRow; string LCL; string ATIS;

            using (StreamWriter sw = new StreamWriter(path))
            {
                sw.WriteLine(CycleHeader);
                sw.WriteLine("[AIRPORT]");
                foreach (DataRow row in dataTable.AsEnumerable())
                {
                    strOut[0]  = Conversions.ICOA(row["FacilityID"].ToString()).PadRight(4);
                    dvTWR.Sort = "ID";
                    foundRow   = TWR.Rows.Find(row["ID"]);
                    if (foundRow != null)
                    {
                        LCL  = foundRow["LCLfreq"].ToString();
                        ATIS = foundRow["ATISfreq"].ToString();
                        if (Convert.ToBoolean(foundRow["IsD-ATIS"]))
                        {
                            ATIStype = "D-ATIS:";
                        }
                        else
                        {
                            ATIStype = "ATIS:";
                        }
                    }
                    else
                    {
                        if (Convert.ToBoolean(row["Public"]))
                        {
                            LCL = "122.8";
                        }
                        else
                        {
                            LCL = "0";
                        }
                        ATIS = string.Empty;
                    }
                    strOut[1] = LCL.PadRight(7);
                    strOut[2] = Conversions.DecDeg2SCT(Convert.ToSingle(row["Latitude"]), true);
                    strOut[3] = Conversions.DecDeg2SCT(Convert.ToSingle(row["Longitude"]), false);
                    strOut[4] = row["Name"].ToString();
                    if (Convert.ToBoolean(row["Public"]))
                    {
                        strOut[5] = " (Public) ";
                    }
                    else
                    {
                        strOut[5] = " {Private} ";
                    }
                    strOut[6] = ATIS;
                    if (ATIS.Length != 0)
                    {
                        strOut[6] = ATIStype + strOut[6];
                    }
                    else
                    {
                        strOut[6] = string.Empty;
                    }
                    if (!(strOut[2] + " " + strOut[3]).Contains("-1 "))      // Do NOT write APTs having no fix
                    {
                        sw.WriteLine(SCTstrings.APTout(strOut));
                    }
                }
            }
            dvAPT.Dispose();
        }