private string OutputText(string Lat0, string Lon0, string Lat1, string Lon1) { string result = string.Empty; if ((Lat0.Length > 0) && (Lon0.Length > 0) && (Lat1.Length > 0) && (Lon1.Length > 0)) { switch (SectionComboBox.SelectedIndex) { case 0: // SIDSTAR result = SCTstrings.SSDout(Lat0, Lon0, Lat1, Lon1) + cr; break; case 1: // ARTCC result = SCTstrings.BoundaryOut(PrefixTextBox.Text, Lat0, Lon0, Lat1, Lon1) + cr; break; case 2: // Airway (prefix textbox req'd) result = SCTstrings.AWYout(PrefixTextBox.Text, Lat0, Lon0, Lat1, Lon1, "", "") + cr; break; case 3: // GEO format result = SCTstrings.GeoOut(Lat0, Lon0, Lat1, Lon1, ColorValueTextBox.Text) + cr; break; } } return(result); }
private static void WriteLabels(DataTable dtSTL, StreamWriter sw) { string strText; string Lat; string Long; string TextColor; string Comment; string Output; // string colorValue = dtColors.Rows[0]["ColorValue"].ToString(); sw.WriteLine("[LABELS]"); sw.WriteLine("; Runway labels"); foreach (DataRow row in dtSTL.AsEnumerable()) { strText = row["LabelText"].ToString(); Lat = row["Latitude"].ToString(); Long = row["Longitude"].ToString(); TextColor = row["TextColor"].ToString(); Comment = row["Comment"].ToString(); if (row["Comment"].ToString().Length != 0) { Output = SCTstrings.LabelOut(strText, Lat, Long, TextColor, Comment); } else { Output = SCTstrings.LabelOut(strText, Lat, Long, TextColor); } sw.WriteLine(Output); } }
private static void WriteRWYLabels(DataTable dtSTL, StreamWriter sw) { string strText; string Lat; string Long; string Facility; string Comment; string Output; // string colorValue = dtColors.Rows[0]["ColorValue"].ToString(); Debug.WriteLine("WriteRWYLabels..."); sw.WriteLine("[LABELS]"); sw.WriteLine("; Runway labels"); foreach (DataRow row in dtSTL.AsEnumerable()) { strText = row["LabelText"].ToString(); Lat = row["Latitude"].ToString(); Long = row["Longitude"].ToString(); Facility = row["TextColor"].ToString(); // This is actually the Facility ID in ESE if (row["Comment"].ToString().Length != 0) { Comment = row["Comment"].ToString(); Output = SCTstrings.LabelOut(strText, Lat, Long, Facility, Comment); } else { Output = SCTstrings.LabelOut(strText, Lat, Long, Facility); } sw.WriteLine(Output); } }
public static void WriteFixes(string path) { string[] strOut = new string[5]; DataTable FIX = Form1.FIX; DataView dataView = new DataView(FIX) { RowFilter = "[Selected]", Sort = "FacilityID" }; using (StreamWriter sw = new StreamWriter(path)) { sw.WriteLine(CycleHeader); sw.WriteLine("[FIXES]"); foreach (DataRowView row in dataView) { strOut[0] = row["FacilityID"].ToString(); strOut[2] = Conversions.DecDeg2SCT(Convert.ToSingle(row["Latitude"]), true); strOut[3] = Conversions.DecDeg2SCT(Convert.ToSingle(row["Longitude"]), false); strOut[4] = row["Use"].ToString(); sw.WriteLine(SCTstrings.FIXout(strOut)); // Uses 0, 2, 3, and 4 } } dataView.Dispose(); }
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(); } }
public static void WriteVOR(string path) { string[] strOut = new string[6]; DataView dataView = new DataView(Form1.VOR) { RowFilter = "[Selected]", Sort = "FacilityID" }; using (StreamWriter sw = new StreamWriter(path)) { sw.WriteLine(CycleHeader); sw.WriteLine("[VOR]"); foreach (DataRowView row in dataView) { strOut[0] = row["FacilityID"].ToString(); 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(); strOut[5] = row["FixType"].ToString(); if (!(strOut[2] + strOut[3]).Contains("-1 ")) // Do NOT write VORs having no fix { sw.WriteLine(SCTstrings.VORout(strOut)); } } dataView.Dispose(); } }
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 string DrawChar(char c, int[] hFont, PointF origin, int Angle, float Scale) { // Each vector needs to be (a) rotate to the angle of the line of text and (b) Scaled // One unit vector = 1 second or 90-100 feet. Use the Scale function to adjust. string result = string.Empty; float X; float Y; bool isFirst = true; string cr = Environment.NewLine; int angle = (int)InfoSection.MagneticVariation + Angle; float scale = Scale / 3600F; PointF end; PointF start = PointF.Empty; // Rotate through vectors in usual manner for (int i = 2; i < hFont.Length; i += 2) { Y = hFont[i + 1]; X = hFont[i]; // X-Lon, Y-Lat if ((X == -1) || (Y == -1)) // Next point is a break { end = PointF.Empty; } else // Get next vector (which will get moved to Start) { SizeF vector = new SizeF(X * scale, Y * scale); end = PointF.Add(origin, vector); end = LatLongCalc.RotatePoint(end, origin, angle); } if (!(start.IsEmpty) && !(end.IsEmpty)) { result += SCTstrings.CharOut(Conversions.DecDeg2SCT(start.Y, true), Conversions.DecDeg2SCT(start.X, false), Conversions.DecDeg2SCT(end.Y, true), Conversions.DecDeg2SCT(end.X, false)); if (isFirst) { result += ";" + c.ToString(); isFirst = false; } result += cr; } start = end; // No matter what happened, move End to Start } return(result); // Lat Long string to draw ONE character! (Sheesh) }
private void AddLine() { // Purpose - to Output a series of lines based upon user options // RETURNS - Nothing; writes a string to the Output Textbox string cr = Environment.NewLine; string Msg; // Create the list of points for the line (if not dashed, returns original points) string[] strOut = new string[4]; strOut[0] = strOut[1] = strOut[2] = strOut[3] = string.Empty; double[][] Lines = DashedLine(DashedLineRadioButton.Checked); if (SSDRadioButton.Checked) { foreach (double[] Line in Lines) { if (Line[0] == -1) { strOut[2] = string.Empty; strOut[3] = string.Empty; } else { strOut[2] = Conversions.Degrees2SCT(Line[0], true); strOut[3] = Conversions.Degrees2SCT(Line[1], false); } if ((strOut[0].Length != 0) && (strOut[2].Length != 0)) { switch (OutputType) { case "SSD": OutputTextBox.Text += SCTstrings.SSDout(strOut[0], strOut[1], strOut[2], strOut[3]) + cr; break; case "AWY": if (PrefixTextBox.TextLength != 0) { OutputTextBox.Text += SCTstrings.AWYout(PrefixTextBox.Text, strOut[0], strOut[1], strOut[2], strOut[3], StartFixTextBox.Text, EndFixTextBox.Text) + cr; } else { Msg = "The Airway identifier is required for this format." + cr + "(Place in the prefix text box.)"; SCTcommon.SendMessage(Msg); PrefixTextBox.Focus(); } break; case "ARTCC": if (PrefixTextBox.TextLength != 0) { OutputTextBox.Text += SCTstrings.BoundaryOut(PrefixTextBox.Text, strOut[0], strOut[1], strOut[2], strOut[3]); if (SuffixTextBox.TextLength != 0) { OutputTextBox.Text += SuffixTextBox.Text; } OutputTextBox.Text += cr; } else { Msg = "The ARTCC identifier is required for this format." + cr + "(Place in the prefix text box.)"; SCTcommon.SendMessage(Msg); PrefixTextBox.Focus(); } break; case "GEO": OutputTextBox.Text += SCTstrings.GeoOut(strOut[0], strOut[1], strOut[2], strOut[3], SuffixTextBox.Text) + cr; break; } } strOut[0] = strOut[2]; strOut[1] = strOut[3]; } } }
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; } } }
private static void BuildSSD(DataView dvSSD) { // Builds ONE SID or STAR from ONE SSD dataview (preselected) // RETURNS a string for the diagram // Everything goes in List<string>s first object[] NavData; // Various and sundry variables for the loop double Lat1 = -1; double Lon1 = -1; string space = new string(' ', 27); double Lat0 = -1; double Lon0 = -1; string lastFix = string.Empty; string curFix; string FixType0; string FixType1; string SSDname; string TransitionName; string SSDcode; string TransitionCode; int FixCount0; int FixCount1; // Get the name and code for this SSD SSDname = dvSSD[0]["SSDName"].ToString(); SSDcode = dvSSD[0]["SSDcode"].ToString(); SSDlines.Add(cr); SSDlines.Add(SSDHeader(SSDcode, "(" + SSDname + ")", 1, '-')); // Now loop the entire SSD to get the lines, etc. foreach (DataRowView SSDrow in dvSSD) { // Get the basics - usual process: Lat1, shift to Lat0 or not, print... // Regardless, do a shift at the end (Making values empty indicates pen up) curFix = SSDrow["NavAid"].ToString(); // The FixType tells us what to do next FixType1 = SSDrow["FixType"].ToString(); // If it's an airport, record the APT ICOA and move to next row if (FixType1 == "AA" || FixType1 == "NA") { // Save the APTs for later... Add2ListIfNew(APTsUsed, curFix); curFix = string.Empty; // Pen up next 2 loops } else { // Save the FIX for later if new... FixCount0 = FixesUsed.Count; Add2ListIfNew(FixesUsed, curFix); FixCount1 = FixesUsed.Count; // NavData: ID(opt), FacilityID, Frequency(opt), Latitude, Longitude, NameOrFixUse, FixType NavData = SCTcommon.GetNavData(curFix); if (FixCount1 > FixCount0) { if (NavData[6].ToString().IndexOf("FIX") != -1) { FixData.Add(NavData); } if (NavData[6].ToString().IndexOf("VOR") != -1) { VORData.Add(NavData); } if (NavData[6].ToString().IndexOf("NDB") != -1) { NDBData.Add(NavData); } } Lat1 = Convert.ToDouble(NavData[3]); Lon1 = Convert.ToDouble(NavData[4]); } // If there's a Transition Name, it starts a new line set. // Keep these coordinates to start the line TransitionName = SSDrow["TransitionName"].ToString(); TransitionCode = SSDrow["TransitionCode"].ToString(); if (TransitionName.Length != 0) { SSDlines.Add(space + "; " + TransitionName); } else { // Finally get the line between waypoints if ((lastFix.Length != 0) && (curFix.Length != 0) && (lastFix != curFix)) { SSDlines.Add(SCTstrings.SSDout(Lat0, Lon0, Lat1, Lon1, lastFix, curFix, InfoSection.UseFixesAsCoords)); // Draw the fix names. Angle and Scale not used for SSDs } } // Shift the values for the next item Lat0 = Lat1; Lon0 = Lon1; lastFix = curFix; FixType0 = FixType1; TransitionCode = TransitionName = string.Empty; } // Lastly insert the symbols and labels if (InfoSection.DrawFixSymbolsOnDiagrams || InfoSection.DrawFixLabelsOnDiagrams) { SSDlines.Add(DrawFixInfo(FixesUsed)); } // Need to add the ALT and Speed items here }
public static void WriteARB(string path, bool High) { // This doesn't work as designed. Need to search for affected ARTCCs, // then draw all the ARTCCs (filter ARTCC =) with ANY borders in the area. // MAY want to do that in the "SELECTED" phase (dgvARB), then sort by ARTCC. DataTable ARB = Form1.ARB; string FacID0 = string.Empty; string FacID1; string ARBname; string HL; string filter; string Sector; string Lat1; string Long1; string Descr1; string Descr0 = string.Empty; string Lat0 = string.Empty; string Long0 = string.Empty; string LatFirst = string.Empty; string LongFirst = string.Empty; string Output = Environment.NewLine; if (High) { filter = "[Selected] AND (" + " ([DECODE] = 'UTA') OR " + " ([DECODE] = 'FIR ONLY') OR " + " ([DECODE] = 'BDRY') OR " + " ([DECODE] = 'HIGH') )"; HL = "_H_CTR"; Sector = "HIGH"; } else { filter = "([DECODE] = 'LOW') AND [Selected]"; // HL = "_L_CTR"; Sector = "LOW"; } // First, find all the ARBs in the group (may be more than one) DataView ARBview = new DataView(ARB) { RowFilter = filter, Sort = "Sequence", }; Console.WriteLine("ARB lines found: " + ARBview.Count); using (StreamWriter sw = new StreamWriter(path)) { Output += "[ARTCC " + Sector + "]" + cr; if (ARBview.Count != 0) { // Build a list of the boundaries. The last one always has "To Point of Beginning" // OR... It's a different ARTCC var ARBlist = new List <string>(); foreach (DataRowView ARBdataRowView in ARBview) { if (Lat0.Length == 0) // First point of line { Lat1 = Conversions.DecDeg2SCT(Convert.ToSingle(ARBdataRowView["Latitude"]), true); Long1 = Conversions.DecDeg2SCT(Convert.ToSingle(ARBdataRowView["Longitude"]), false); LatFirst = Lat1; LongFirst = Long1; // Save the first point Descr1 = ARBdataRowView["Description"].ToString(); ARBname = ARBdataRowView["Name"].ToString(); // Initialize AARTC name FacID1 = ARBdataRowView["ARTCC"].ToString(); // Initialize FacID Output += "; " + ARBname + cr; } else { FacID1 = ARBdataRowView["ARTCC"].ToString(); Descr1 = ARBdataRowView["Description"].ToString(); Lat1 = Conversions.DecDeg2SCT(Convert.ToSingle(ARBdataRowView["Latitude"]), true); Long1 = Conversions.DecDeg2SCT(Convert.ToSingle(ARBdataRowView["Longitude"]), false); if ((FacID0.Length != 0) && (FacID0 == FacID1)) { Output += SCTstrings.BoundaryOut(FacID1 + HL, Lat0, Long0, Lat1, Long1, Descr0) + cr; } } if (Descr1.IndexOf("POINT OF BEGINNING") != -1) // Last line in this group { Output += SCTstrings.BoundaryOut(FacID1 + HL, Lat0, Long0, Lat1, Long1, Descr0) + cr; Output += SCTstrings.BoundaryOut(FacID1 + HL, Lat1, Long1, LatFirst, LongFirst) + cr; sw.WriteLine(Output); Lat1 = Long1 = FacID1 = Descr1 = Output = string.Empty; } if ((FacID0.Length != 0) && (FacID0 != FacID1)) // Changed ARTCC { // Do NOT add a line to close boundary // Check for dual condition; end of group AND new ARTCC... if (Output.Length != 0) { sw.WriteLine(Output); } Output = string.Empty; } Lat0 = Lat1; Long0 = Long1; FacID0 = FacID1; Descr0 = Descr1; } } } ARBview.Dispose(); }
public static void WriteAWY(string path, bool IsLow) { DataTable AWY = Form1.AWY; string Awy0 = string.Empty; string Awy1; string NavAid0 = string.Empty; string NavAid1; double Lat0 = -1; double Lat1 = -1; double Lon0 = -1; double Lon1 = -1; bool IsBreak; string filter = "[Selected]"; if (IsLow) { filter += " AND [IsLow]"; } else { filter += " AND NOT [IsLow]"; } DataView dvAWY = new DataView(AWY) { RowFilter = filter, Sort = "AWYID, Sequence", }; // Rotate output as in other output loops using (StreamWriter sw = new StreamWriter(path)) { sw.WriteLine(CycleHeader); if (IsLow) { sw.WriteLine("[LOW AIRWAY]"); } else { sw.WriteLine("[HIGH AIRWAY]"); } foreach (DataRowView rowAWY in dvAWY) { Awy1 = rowAWY["AWYID"].ToString(); NavAid1 = rowAWY["NAVAID"].ToString(); IsBreak = (bool)rowAWY["IsBreak"]; Lat1 = Convert.ToSingle(rowAWY["Latitude"]); Lon1 = Convert.ToSingle(rowAWY["Longitude"]); if (IsBreak) { Lat1 = -1f; // Break in awy; restart sequence with next } if (Awy1 != Awy0) { Lat0 = -1f; // New air, last segment was written (but save this coord) } { if ((Lat0 != -1) && (Lat1 != -1)) { sw.WriteLine(SCTstrings.AWYout(Awy1, Conversions.DecDeg2SCT(Convert.ToSingle(Lat0), true), Conversions.DecDeg2SCT(Convert.ToSingle(Lon0), false), Conversions.DecDeg2SCT(Convert.ToSingle(Lat1), true), Conversions.DecDeg2SCT(Convert.ToSingle(Lon1), false), NavAid0, NavAid1)); } } // Shift all items Awy0 = Awy1; NavAid0 = NavAid1; Lat0 = Lat1; Lon0 = Lon1; } } dvAWY.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(); }
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(); }
public static string DrawSymbol(object[] FixData) { // FixData contains: ID(opt), FacilityID, Frequency(opt), Latitude, Longitude, NameOrUse, FixType string Lat0; string Lon0; string Lat1; string Lon1; string cr = Environment.NewLine; string space = new string(' ', 27); int angle = (int)InfoSection.MagneticVariation; string Fix = FixData[1].ToString(); string FixType = FixData[6].ToString(); if (FixType == "FIX") { FixType = FixData[5].ToString(); } float lat = Convert.ToSingle(FixData[3]); float lon = Convert.ToSingle(FixData[4]); int[] Symbol = SymbolRef(FixType); // Declare values used in loop below PointF[] Coords = new PointF[Symbol[0]]; float myX; float myY; // Loop through the symbol points, creating the initial pattern int Counter = 0; for (int i = 2; i <= Symbol[0] * 2; i += 2) { myX = Symbol[i + 1]; myY = Symbol[i]; // Lat is Y, Lon is X if ((myY != -1) && (myX != -1)) { Coords[Counter] = new PointF(myX /= 3600F, myY /= 3600F); } else { Coords[Counter] = new PointF(-1F, -1F); } Counter++; } // Rotate the symbol to True North - with the first point as the origin (skip breaks) // WHY is Mag Var correct, but rotation is NOT? PointF PenUp = new PointF(-1, -1); for (int i = 0; i < Coords.Length; i++) { if (Coords[i] != PenUp) { Coords[i] = LatLongCalc.RotatePoint(Coords[i], Coords[0], angle); } } // Get the centroid PointF centroid = LatLongCalc.Centroid(Coords); // Find the offset of the centroid from the FIX SizeF CentOffset = new SizeF(lon - centroid.X, lat - centroid.Y); // Move the symbol so it appears over the FIX for (int i = 0; i < Coords.Length; i++) { if (Coords[i] != PenUp) { Coords[i] = PointF.Add(Coords[i], CentOffset); } } // Now write out the symbol strings in typical end-to-start rotation PointF start = PointF.Empty; PointF end; string Result = space + "; Symbol for " + FixType + " " + Fix + cr; foreach (PointF pointF in Coords) { if (pointF != PenUp) { end = pointF; } else { end = PointF.Empty; } if (!(start.IsEmpty) && !(end.IsEmpty)) { Lat0 = Conversions.DecDeg2SCT(start.Y, true); Lat1 = Conversions.DecDeg2SCT(end.Y, true); Lon0 = Conversions.DecDeg2SCT(start.X, false); Lon1 = Conversions.DecDeg2SCT(end.X, false); Result += SCTstrings.SSDout(Lat0, Lon0, Lat1, Lon1) + cr; } start = end; } return(Result); }