Beispiel #1
0
        private static void WriteSSDrefs()
        {
            // Sends the results of BuildSSD to the designated file
            // This is the header references
            // Write the file for this SSD
            string[] strOut = new string[6];
            BigResult += cr + "[AIRPORT]" + cr;
            DataView dvAPT = new DataView(Form1.APT);
            DataView dvTWR = new DataView(Form1.TWR);

            foreach (string Arpt in APTsUsed)
            {
                dvAPT.RowFilter = "FacilityID = '" + Arpt + "'";
                dvTWR.RowFilter = "FacilityID = '" + Arpt + "'";
                strOut[0]       = Conversions.ICOA(Arpt);
                if (dvTWR.Count != 0)
                {
                    strOut[1] = string.Format("{0:000.000}", dvTWR[0]["LCLfreq"].ToString());
                }
                else
                {
                    strOut[1] = "122.8  ";
                }
                strOut[2]  = Conversions.Degrees2SCT(Convert.ToDouble(dvAPT[0]["Latitude"]), true);
                strOut[3]  = Conversions.Degrees2SCT(Convert.ToDouble(dvAPT[0]["Longitude"]), false);
                strOut[4]  = dvAPT[0]["Name"].ToString();
                BigResult += SCTstrings.APTout(strOut.ToArray()) + cr;
            }
            dvAPT.Dispose();
            dvTWR.Dispose();
            // Write the NavAids for this curFix
            // Fix, Frequency(opt), Latitude, Longitude, Name, FixType
            if (VORData.Count > 0)
            {
                // NavData: ID(opt), FacilityID, Frequency(opt), Latitude, Longitude, Name, FixType
                BigResult += cr + "[VOR]" + cr;
                foreach (object[] VORs in VORData)
                {
                    // strOut expects 0-Fix, 1-Freq, 2-Lat, 3-Lon, 4-Name, 5-Type
                    strOut[0]  = VORs[1].ToString();
                    strOut[1]  = VORs[2].ToString();
                    strOut[2]  = Conversions.Degrees2SCT(Convert.ToDouble(VORs[3]), true);
                    strOut[3]  = Conversions.Degrees2SCT(Convert.ToDouble(VORs[4]), false);
                    strOut[4]  = VORs[5].ToString();
                    strOut[5]  = VORs[6].ToString();
                    BigResult += SCTstrings.VORout(strOut) + cr;
                }
            }
            // NavData: ID(opt), FacilityID, Frequency(opt), Latitude, Longitude, Name, FixType
            if (NDBData.Count > 0)
            {
                BigResult += cr + "[NDB]" + cr;
                foreach (object[] NDBs in NDBData)
                {
                    strOut[0]  = NDBs[1].ToString();
                    strOut[1]  = NDBs[2].ToString();
                    strOut[2]  = Conversions.Degrees2SCT(Convert.ToDouble(NDBs[3]), true);
                    strOut[3]  = Conversions.Degrees2SCT(Convert.ToDouble(NDBs[4]), false);
                    strOut[4]  = NDBs[5].ToString();
                    strOut[5]  = NDBs[6].ToString();
                    BigResult += SCTstrings.NDBout(strOut) + cr;
                }
            }
            // NavData: ID(opt), FacilityID, Frequency(opt), Latitude, Longitude, FixUse, FixType
            if (FixData.Count > 0)
            {
                BigResult += cr + "[FIXES]" + cr;
                foreach (object[] FIXes in FixData)
                {
                    strOut[0]  = FIXes[1].ToString();
                    strOut[2]  = Conversions.Degrees2SCT(Convert.ToDouble(FIXes[3]), true);
                    strOut[3]  = Conversions.Degrees2SCT(Convert.ToDouble(FIXes[4]), false);
                    strOut[4]  = FIXes[5].ToString();
                    BigResult += SCTstrings.FIXout(strOut) + cr;
                }
            }
        }
Beispiel #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();
        }