public static void Main() { string line; while ((line = Console.ReadLine()) != null) { if (!line.StartsWith("NAV1")) { continue; } string type = line.Substring(8, 20).Trim(); string ident = line.Substring(28, 4).Trim(); string name = line.Substring(42, 30).Trim(); string city = line.Substring(72, 40).Trim(); string state = line.Substring(112, 30).Trim(); string cntry = line.Substring(147, 30).Trim(); double lat = DecodeLatLon(line.Substring(385, 11), 'N', 'S'); double lon = DecodeLatLon(line.Substring(410, 11), 'E', 'W'); string elev = line.Substring(472, 7).Trim(); // feet with decimal point if (elev == "") { elev = Topography.GetElevFt(lat, lon).ToString("F1"); } string magvar = line.Substring(479, 5).Trim(); if (magvar != "") { int magbin = int.Parse(magvar.Substring(0, magvar.Length - 1)); if (magvar.EndsWith("E")) { magbin = -magbin; } magvar = magbin.ToString(); } string freq = line.Substring(533, 6).Trim(); string navcls = line.Substring(281, 11).Trim(); // see plate KMLK ILS or LOC RWY 2 if ((type == "NDB") && (ident == "MKL")) { ident = "MK"; } foreach (string acceptable in acceptables) { if (type == acceptable) { if (state != "") { city += ", " + state; } if (cntry != "") { city += ", " + cntry; } string freqkhz = freq; if (freq.Contains(".")) { freqkhz = Math.Round(double.Parse(freq) * 1000.0).ToString(); } Console.WriteLine(type + "," + ident + "," + elev + ",\"" + name + " - " + freq + " - " + city + "\"," + lat + "," + lon + "," + magvar + "," + freqkhz + "," + navcls); } } } }
public static void Main() { string type = ""; string ident = ""; string name = ""; string elev = ""; string freq = ""; string city = ""; double lat = 0.0; double lon = 0.0; double thdg = 0.0; string gsalt = ""; // gs antenna elevation feet msl string gsang = ""; // angle in degrees, eg, 2.75 double gslat = 0.0; // glideslope antenna location double gslon = 0.0; string dmealt = ""; double dmelat = 0.0; double dmelon = 0.0; string aptid = ""; // faaid eg "BVY" string rwyid = ""; // eg "04R" int magvar = 0; // mhdg = thdg + magvar string line; while ((line = Console.ReadLine()) != null) { if (line.StartsWith("ILS1")) { if (type != "") { // elev gets filled in with airport elev by MakeWaypoints.cs Console.WriteLine(type + "," + ident + "," + elev + ",\"" + name + " - " + freq + " - " + city + "\"," + lat + "," + lon + "," + thdg + "," + gsalt + "," + gsang + "," + gslat + "," + gslon + "," + dmealt + "," + dmelat + "," + dmelon + "," + aptid + "," + rwyid + "," + Math.Round(double.Parse(freq) * 1000.0) + "," + magvar); type = ""; ident = ""; name = ""; elev = ""; freq = ""; city = ""; lat = 0.0; lon = 0.0; thdg = 0.0; gsalt = ""; gsang = ""; gslat = 0.0; gslon = 0.0; dmealt = ""; dmelat = 0.0; dmelon = 0.0; aptid = ""; rwyid = ""; magvar = 0; } type = line.Substring(18, 10).Trim(); ident = line.Substring(28, 6).Trim(); rwyid = line.Substring(15, 3).Trim(); name = line.Substring(44, 50).Trim() + " rwy " + rwyid; // airport name and runway number city = line.Substring(94, 40).Trim() + ", " + line.Substring(136, 20).Trim(); // city and state magvar = ParseVariation(line.Substring(287, 3).Trim()); thdg = Double.Parse(line.Substring(281, 6).Trim()) - magvar; aptid = line.Substring(159, 3).Trim(); } if (line.StartsWith("ILS2")) { lat = DecodeLatLon(line.Substring(74, 11).Trim(), 'N', 'S'); lon = DecodeLatLon(line.Substring(99, 11).Trim(), 'E', 'W'); elev = line.Substring(126, 7).Trim(); freq = line.Substring(133, 7).Trim(); } if (line.StartsWith("ILS3")) { gsalt = line.Substring(126, 7).Trim(); gsang = line.Substring(148, 5).Trim(); gslat = DecodeLatLon(line.Substring(74, 11).Trim(), 'N', 'S'); gslon = DecodeLatLon(line.Substring(99, 11).Trim(), 'E', 'W'); } if (line.StartsWith("ILS4")) { dmealt = line.Substring(126, 7).Trim(); dmelat = DecodeLatLon(line.Substring(74, 11).Trim(), 'N', 'S'); dmelon = DecodeLatLon(line.Substring(99, 11).Trim(), 'E', 'W'); } if (line.StartsWith("ILS5")) { string markertype = line.Substring(28, 2).Trim(); // IM, MM, OM double markerlat = DecodeLatLon(line.Substring(76, 11).Trim(), 'N', 'S'); double markerlon = DecodeLatLon(line.Substring(101, 11).Trim(), 'E', 'W'); string markerelev = line.Substring(128, 7).Trim(); // elevation of marker in feet string markeridnt = line.Substring(150, 2).Trim(); // short identifier (2 letters) string markername = line.Substring(152, 30).Trim(); // long name string markerfreq = line.Substring(182, 3).Trim(); // marker beacon frequency if (markerfreq == "75") { markerfreq = "75000"; } if ((markeridnt != "") && (markerfreq != "")) { if (markerelev == "") { markerelev = Topography.GetElevFt(markerlat, markerlon).ToString("F1"); } Console.WriteLine(markertype + "," + markeridnt + "," + markerelev + ",\"" + markername + " - " + markerfreq + " - " + city + "\"," + markerlat + "," + markerlon + ",,,,,,,,,,," + markerfreq + ","); } } } if (type != "") { Console.WriteLine(type + "," + ident + "," + elev + ",\"" + name + " - " + freq + " - " + city + "\"," + lat + "," + lon + "," + thdg + "," + gsalt + "," + gsang + "," + gslat + "," + gslon + "," + dmealt + "," + dmelat + "," + dmelon + "," + aptid + "," + rwyid + "," + Math.Round(double.Parse(freq) * 1000.0) + "," + magvar); } }