private static void WriteRWY(string path) { string[] strOut = new string[9]; string FacID = string.Empty; bool FirstLine = true; string FacName = string.Empty; DataTable DRAW = new SCTdata.DrawLabelDataTable(); DataTable RWY = Form1.RWY; DataView dvRWY = new DataView(RWY) { RowFilter = "[Selected]", Sort = "FacilityID, BaseIdentifier" }; using (StreamWriter sw = new StreamWriter(path)) { foreach (DataRowView row in dvRWY) { if (row["FacilityID"].ToString() != FacID) { if (FirstLine) { sw.WriteLine(CycleHeader); sw.WriteLine("[RUNWAY]"); FirstLine = false; } FacID = row["FacilityID"].ToString(); FacName = row["FacilityName"].ToString(); } strOut[0] = row["BaseIdentifier"].ToString().Trim().PadRight(3); strOut[1] = row["EndIdentifier"].ToString().Trim().PadRight(3); strOut[2] = row["BaseHeading"].ToString().PadRight(3); strOut[3] = row["EndHeading"].ToString().PadRight(3); strOut[4] = Conversions.DecDeg2SCT(Convert.ToSingle(row["Latitude"]), true); strOut[5] = Conversions.DecDeg2SCT(Convert.ToSingle(row["Longitude"]), false); strOut[6] = Conversions.DecDeg2SCT(Convert.ToSingle(row["EndLatitude"]), true); strOut[7] = Conversions.DecDeg2SCT(Convert.ToSingle(row["EndLongitude"]), false); strOut[8] = FacID + "-" + FacName; sw.Write(SCTstrings.RWYout(strOut, ESformat: true)); DRAW.Rows.Add(new object[] { strOut[0].ToString(), strOut[4].ToString(), strOut[5].ToString(), strOut[8].ToString() }); DRAW.Rows.Add(new object[] { strOut[1].ToString(), strOut[6].ToString(), strOut[7].ToString(), strOut[8].ToString() }); } } dvRWY.Dispose(); }
private static void WriteRWY(string path) { // Need to develop color entries string[] strOut = new string[9]; string FacID = string.Empty; double MagBHdg; double MagEHdg; bool FirstLine = true; string FacFullName = string.Empty; DataTable DRAW = new SCTdata.DrawLabelDataTable(); DataTable RWY = Form1.RWY; DataView dvRWY = new DataView(RWY) { RowFilter = "[Selected]", Sort = "FacilityID, BaseIdentifier" }; using (StreamWriter sw = new StreamWriter(path)) { foreach (DataRowView row in dvRWY) { if (row["FacilityID"].ToString() != FacID) { if (FirstLine) { sw.WriteLine(CycleHeader); sw.WriteLine("[RUNWAY]"); FirstLine = false; } FacID = row["FacilityID"].ToString(); FacFullName = FacID + '-' + row["FacilityName"].ToString(); } // FAA RWY bearings are in "True" format and must be converted to "Magnetic" // Brg = True - Declination, where W is negative. strOut[0] = row["BaseIdentifier"].ToString().Trim().PadRight(3); strOut[1] = row["EndIdentifier"].ToString().Trim().PadRight(3); MagBHdg = Convert.ToDouble(row["BaseHeading"]) - InfoSection.MagneticVariation; if (MagBHdg > 360) { MagBHdg %= 360; } else if (MagBHdg < 0) { MagBHdg = (MagBHdg + 360) % 360; } if (MagBHdg == 0) { MagBHdg = 360; } strOut[2] = Convert.ToString(MagBHdg).PadRight(3); MagEHdg = Convert.ToDouble(row["EndHeading"]) - InfoSection.MagneticVariation; if (MagEHdg > 360) { MagEHdg %= 360; } else if (MagBHdg < 0) { MagEHdg = (MagEHdg + 360) % 360; } if (MagBHdg == 0) { MagBHdg = 360; } strOut[3] = Convert.ToString(MagEHdg).PadRight(3); strOut[4] = Conversions.DecDeg2SCT(Convert.ToSingle(row["Latitude"]), true); strOut[5] = Conversions.DecDeg2SCT(Convert.ToSingle(row["Longitude"]), false); strOut[6] = Conversions.DecDeg2SCT(Convert.ToSingle(row["EndLatitude"]), true); strOut[7] = Conversions.DecDeg2SCT(Convert.ToSingle(row["EndLongitude"]), false); strOut[8] = FacFullName; sw.WriteLine(SCTstrings.RWYout(strOut)); DRAW.Rows.Add(new object[] { strOut[0].ToString(), strOut[4].ToString(), strOut[5].ToString(), "", FacFullName }); DRAW.Rows.Add(new object[] { strOut[1].ToString(), strOut[6].ToString(), strOut[7].ToString(), "", FacFullName }); } WriteLabels(DRAW, sw); } dvRWY.Dispose(); }