public static void WriteNDB(string path) { string[] strOut = new string[5]; string LineOut; DataTable NDB = Form1.NDB; DataView dataView = new DataView(NDB) { RowFilter = "[Selected]", Sort = "FacilityID" }; using (StreamWriter sw = new StreamWriter(path)) { sw.WriteLine(CycleHeader); sw.WriteLine("[NDB]"); foreach (DataRowView row in dataView) { strOut[0] = row["FacilityID"].ToString().PadRight(3); strOut[1] = string.Format("{0:000.000}", row["Frequency"]); strOut[2] = Conversions.DecDeg2SCT(Convert.ToSingle(row["Latitude"]), true); strOut[3] = Conversions.DecDeg2SCT(Convert.ToSingle(row["Longitude"]), false); strOut[4] = row["Name"].ToString(); LineOut = strOut[0] + " " + strOut[1] + " " + strOut[2] + " " + strOut[3] + " ;" + strOut[4]; if (!(strOut[2] + strOut[3]).Contains("-1 ")) // Do NOT write NDBs having no fix { sw.WriteLine(SCTstrings.NDBout(strOut)); } } dataView.Dispose(); } }
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; } } }