Skip to content
This repository has been archived by the owner on Dec 17, 2021. It is now read-only.

Commit

Permalink
Merge pull request #115 from Nikolai558/development
Browse files Browse the repository at this point in the history
Ready for Release 0.8.1
  • Loading branch information
Nikolai558 authored Aug 4, 2021
2 parents cb60d68 + cf06e83 commit fce3c77
Show file tree
Hide file tree
Showing 17 changed files with 216 additions and 98 deletions.
29 changes: 20 additions & 9 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,31 @@

## Pre-V1.0.0
---
- ## Version 0.8.1
- Change log on Update question will display all changes from user version and up to the latest release.
- FAQ button added. This will take you to a Facts And Questions google slide.
- Choosing AIRAC cycle phrase/question changed.
- Fixed bug where program crashes if the user is not connected to the internet.
- Fixed bug where program states it's complete when it really is not. This happened when a file download failed.
- Fixed Credit screen title.
- New Functionality to FAA Chart Recal Commands
- Charts without computer codes will be generated with the first 5 characters (not including spaces) of the chart name.
- Gather WX Station data from Vatsim
- This may cause issues, if so please report in issues section on github.

- ## Version 0.8.0
- Fixed Bug #98 META File Causing Crash:
- If Meta File is not available, NASR2SCT will put a WARN-README.txt file in output directory.
- Testing Update Function ( For Release of 1.0.0 )
- Fixed Bug #98 META File Causing Crash:
- If Meta File is not available, NASR2SCT will put a WARN-README.txt file in output directory.
- Testing Update Function ( For Release of 1.0.0 )

- ## Version 0.7.9:
- 0.7.8 was packaged incorrectly and would not allow fresh install of 0.7.8
- 0.7.8 was packaged incorrectly and would not allow fresh install of 0.7.8

- ## Version 0.7.8:
(WARNING)
*** FRESH INSTALL OF THIS VERSION DOES NOT WORK
- Fixed Facility Id Drop Down Alignment #92
- Duplicate Airway Alias Commands are now put in the 'OTHER' section of the Duplicate Alias Commands Text file. #94 and #81
- Added Dialog message box with more information when a user is updating NASR2SCT #93
(WARNING) *** FRESH INSTALL OF THIS VERSION DOES NOT WORK
- Fixed Facility Id Drop Down Alignment #92
- Duplicate Airway Alias Commands are now put in the 'OTHER' section of the Duplicate Alias Commands Text file. #94 and #81
- Added Dialog message box with more information when a user is updating NASR2SCT #93

- ## Version 0.7.7:
- NEW FEATURE, ARTCC Publication Parser. #83
Expand Down
40 changes: 37 additions & 3 deletions ClassData/DataAccess/GetAptData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
using System.IO.Compression;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Xml.Linq;
using System.Xml.Serialization;

namespace ClassData.DataAccess
Expand Down Expand Up @@ -195,14 +199,26 @@ private void GetOffsetRwyText()

private void ParseAndWriteWxStation(string effectiveDate)
{
string wxCrossCheckFilePathIn = $"{GlobalConfig.tempPath}\\{effectiveDate}_WX-CROSSCHECK.xml";
string filepath = $"{GlobalConfig.outputDirectory}\\VRC\\[LABELS].sct2";

StringBuilder sb = new StringBuilder();
sb.AppendLine("[LABELS]");

// DEBUGING ONLY! WX STATION
// string debugfilepath = $"{GlobalConfig.outputDirectory}\\debug.txt";
// StringBuilder debugSB = new StringBuilder();
// debugSB.AppendLine("DEBUGING ONLY! The following weather stations would have been added the old way. But now they will not be in [LABELS].\n\n");

List<string> countryCodes = new List<string> { "AS", "GU", "MP", "PR", "VI", "US" };
string id;
string final;
string final;

// string xml = new WebClient().DownloadString("https://w1.weather.gov/xml/current_obs/index.xml");
XDocument xDocSload = XDocument.Load(wxCrossCheckFilePathIn);
var sList = xDocSload.Root.Elements("station").Elements("station_id").Select(element => element.Value.Substring(1,3)).ToList();
var lList = xDocSload.Root.Elements("station").Elements("station_id").Select(element => element.Value).ToList();


foreach (string line in File.ReadAllLines($"{GlobalConfig.tempPath}\\{effectiveDate}_WXSTATIONS.txt"))
{
Expand Down Expand Up @@ -230,14 +246,32 @@ private void ParseAndWriteWxStation(string effectiveDate)
{
final = $"\"{line.Substring(20, 4)} {apt.Name.Replace('"', '-')}\" {GlobalConfig.CorrectLatLon(lat, true, GlobalConfig.Convert)} {GlobalConfig.CorrectLatLon(lon, false, GlobalConfig.Convert)} 11579568";

sb.AppendLine(final);
if (sList.Contains(id, StringComparer.OrdinalIgnoreCase) || lList.Contains(id, StringComparer.OrdinalIgnoreCase))
{
foreach (string vatsimWXLine in File.ReadLines($"{GlobalConfig.tempPath}\\{effectiveDate}_WX-VATSIM.txt"))
{
if (vatsimWXLine.Substring(0, 5).Trim() == apt.Icao)
{
sb.AppendLine(final);
//Console.WriteLine($"Added weather station for {id}");
break;
}
}
}
else
{
// Do nothing here. This is Debuging only. WX STATION
// debugSB.AppendLine(final);
}

break;
}
}
}
}
}
}
// File.WriteAllText(debugfilepath, debugSB.ToString());

File.WriteAllText(filepath, sb.ToString());
File.AppendAllText(filepath, $"\n\n\n\n\n\n");
Expand Down
31 changes: 26 additions & 5 deletions ClassData/DataAccess/GetFaaMetaFileData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,33 @@ private void ParseMetaFile()
AmdtNum = recordData.Element("amdtnum").Value,
AmdtDate = recordData.Element("amdtdate").Value
};
// - If something breaks totally move those back here.

//if ($"; {apt.AirportName}-{record.FAAChartName}" == "; OCEANA NAS/ APOLLO SOUCEK FIELD-RNAV (GPS) RWY 32L/R")
//{
// string STOPME = "";
//}
if ((string.IsNullOrEmpty(record.Faanfd18) && record.ChartCode == "DP") || (string.IsNullOrEmpty(record.Faanfd18) && record.ChartCode == "STAR"))
{
string newFaanfd18 = "";

if (record.ChartName.Trim().Replace(" ", string.Empty).Length <= 5)
{
// This apears to be redundant check. As chart name Trimed and No spaces will always be greater than 5 Chars.
newFaanfd18 = record.ChartName.Trim().Replace(" ", string.Empty);
}
else
{
newFaanfd18 = record.ChartName.Trim().Replace(" ", string.Empty).Substring(0, 5);
}

newFaanfd18 += "?";

if (record.ChartCode == "DP")
{
record.Faanfd18 = newFaanfd18 + "." + apt.AptIdent;
}
else
{
record.Faanfd18 = apt.AptIdent + "." + newFaanfd18;
}
//Console.WriteLine(apt.AptIdent + " - " + record.ChartCode + " - " + record.ChartSeq + " - " + record.ChartName);
}

if (
record.ChartName.IndexOf("CONVERGING") == -1 &&
Expand Down
3 changes: 2 additions & 1 deletion ClassData/DataAccess/GetStarDpData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,16 +174,17 @@ private void WriteAlias()

if (procedures[procSeqNumber][0].ComputerCode.IndexOf("NOT ASSIGNED") != -1)
{
// Um this might skip procedures...... Might have an issue here? We will see.
continue;
}
else if (procedures[procSeqNumber][0].Type == "S")
{
currentComputerCode = procedures[procSeqNumber][0].ComputerCode.Split('.')[1].Substring(0, procedures[procSeqNumber][0].ComputerCode.Split('.')[1].Length - 1);
//Console.WriteLine("S: " + currentComputerCode);
}
else if (procedures[procSeqNumber][0].Type == "D")
{
currentComputerCode = procedures[procSeqNumber][0].ComputerCode.Split('.')[0].Substring(0, procedures[procSeqNumber][0].ComputerCode.Split('.')[0].Length - 1);
//Console.WriteLine("D: " + currentComputerCode);
}
else
{
Expand Down
1 change: 0 additions & 1 deletion ClassData/DataAccess/PublicationParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ namespace ClassData.DataAccess
{
public class PublicationParser
{
// TODO - Populate this list from somewhere from some how.
public static List<string> allArtcc = GlobalConfig.allArtcc;

private string outputDirectory = GlobalConfig.outputDirectory + "PUBLICATIONS";
Expand Down
47 changes: 30 additions & 17 deletions ClassData/GlobalConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace NASARData
/// </summary>
public class GlobalConfig
{
public static readonly string ProgramVersion = "0.8.0";
public static readonly string ProgramVersion = "0.8.1";

public static string GithubVersion = "";

Expand Down Expand Up @@ -156,7 +156,9 @@ public static void DownloadAllFiles(string effectiveDate, string airacCycle, boo
{ $"{airacCycle}_FAA_Meta.xml", $"https://aeronav.faa.gov/d-tpp/{airacCycle}/xml_data/d-tpp_Metafile.xml"},
{ $"{effectiveDate}_FIX.zip", $"https://nfdc.faa.gov/webContent/28DaySub/{effectiveDate}/FIX.zip" },
{ $"{effectiveDate}_NAV.zip", $"https://nfdc.faa.gov/webContent/28DaySub/{effectiveDate}/NAV.zip"},
{ $"{airacCycle}_TELEPHONY.html", $"https://www.faa.gov/air_traffic/publications/atpubs/cnt_html/chap3_section_2.html" }
{ $"{airacCycle}_TELEPHONY.html", $"https://www.faa.gov/air_traffic/publications/atpubs/cnt_html/chap3_section_2.html" },
{ $"{effectiveDate}_WX-CROSSCHECK.xml", $"https://w1.weather.gov/xml/current_obs/index.xml" },
{ $"{effectiveDate}_WX-VATSIM.txt", $"http://metar.vatsim.net/metar.php?id=all" }
};
}
else
Expand Down Expand Up @@ -192,7 +194,9 @@ public static void DownloadAllFiles(string effectiveDate, string airacCycle, boo
{ $"{effectiveDate}_AWY.zip", $"https://nfdc.faa.gov/webContent/28DaySub/{effectiveDate}/AWY.zip"},
{ $"{effectiveDate}_FIX.zip", $"https://nfdc.faa.gov/webContent/28DaySub/{effectiveDate}/FIX.zip" },
{ $"{effectiveDate}_NAV.zip", $"https://nfdc.faa.gov/webContent/28DaySub/{effectiveDate}/NAV.zip"},
{ $"{airacCycle}_TELEPHONY.html", $"https://www.faa.gov/air_traffic/publications/atpubs/cnt_html/chap3_section_2.html" }
{ $"{airacCycle}_TELEPHONY.html", $"https://www.faa.gov/air_traffic/publications/atpubs/cnt_html/chap3_section_2.html" },
{ $"{effectiveDate}_WX-CROSSCHECK.xml", $"https://w1.weather.gov/xml/current_obs/index.xml" },
{ $"{effectiveDate}_WX-VATSIM.txt", $"http://metar.vatsim.net/metar.php?id=all" }
};
}

Expand All @@ -203,15 +207,24 @@ public static void DownloadAllFiles(string effectiveDate, string airacCycle, boo
{
foreach (string fileName in allURLs.Keys)
{
// TODO - We may not want to keep the data. Might want to remove this and just download it anyways.
// This Data will ALWAYS get removed when user clicks "START"
// This is pointless but I will keep in for debuging purposes.

if (!File.Exists($"{tempPath}\\{fileName}"))
try
{
if (fileName == $"{effectiveDate}_WX-CROSSCHECK.xml")
{
CreateCurlBatchFile("WXCROSSCHECK.bat", "https://w1.weather.gov/xml/current_obs/index.xml", fileName);
ExecuteCurlBatchFile("WXCROSSCHECK.bat");
}
else
{
client.DownloadFile(allURLs[fileName], $"{tempPath}\\{fileName}");
}
}
catch (Exception)
{
client.DownloadFile(allURLs[fileName], $"{tempPath}\\{fileName}");
DownloadedFilePaths.Add($"{tempPath}\\{fileName}");
MessageBox.Show($"FAILED DOWNLOADING: \n\n{fileName}\n{allURLs[fileName]}\n\nThis program will exit.\nPlease try again.");
Environment.Exit(-1);
}
DownloadedFilePaths.Add($"{tempPath}\\{fileName}");
}
}
}
Expand Down Expand Up @@ -561,20 +574,20 @@ public static string CreateDecFormat(string value, bool roundSixPlaces)
return decFormat;
}

private static void CreateCurlBatchFile()
private static void CreateCurlBatchFile(string name, string url, string outputFileName)
{
string filePath = $"{tempPath}\\getAiraccEff.bat";
string filePath = $"{tempPath}\\{name}";
string writeMe = $"cd \"{tempPath}\"\n" +
$"curl \"https://www.faa.gov/air_traffic/flight_info/aeronav/aero_data/NASR_Subscription/\">{FaaHtmlFileVariable}_FAA_NASR.HTML";
$"curl \"{url}\">{outputFileName}";
File.WriteAllText(filePath, writeMe);
}

private static void ExecuteCurlBatchFile()
private static void ExecuteCurlBatchFile(string batchFileName)
{
ProcessStartInfo ProcessInfo;
Process Process;

ProcessInfo = new ProcessStartInfo("cmd.exe", "/c " + $"\"{tempPath}\\getAiraccEff.bat\"");
ProcessInfo = new ProcessStartInfo("cmd.exe", "/c " + $"\"{tempPath}\\{batchFileName}\"");
ProcessInfo.CreateNoWindow = true;
ProcessInfo.UseShellExecute = false;

Expand All @@ -594,9 +607,9 @@ public static void GetAiracDateFromFAA()

string response;

CreateCurlBatchFile();
CreateCurlBatchFile("getAiraccEff.bat", "https://www.faa.gov/air_traffic/flight_info/aeronav/aero_data/NASR_Subscription/", $"{FaaHtmlFileVariable}_FAA_NASR.HTML");

ExecuteCurlBatchFile();
ExecuteCurlBatchFile("getAiraccEff.bat");

if (File.Exists($"{tempPath}\\{FaaHtmlFileVariable}_FAA_NASR.HTML") && File.ReadAllText($"{tempPath}\\{FaaHtmlFileVariable}_FAA_NASR.HTML").Length > 10)
{
Expand Down
2 changes: 0 additions & 2 deletions ClassData/Models/AliasCheck.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ public void CheckForDuplicates(string CompleteAliasFilePath)

private void WriteDupFile(List<string> DuplicateCommandsList, List<AptModel> AirportModels)
{
// TODO - Make more efficient

string outFilePath = $"{GlobalConfig.outputDirectory}\\ALIAS\\DUPLICATE_COMMANDS.txt";
string currentAirportIatta = "";
string aptIatta;
Expand Down
4 changes: 2 additions & 2 deletions ClassData/Models/MetaFileModels/MetaRecordModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ public void CreateAliasComand(string AptIata)
tempRecordList[missingIndex].AliasCommand = tempRecordList[missingIndex].AliasCommand.Insert(2, tempVariant);
}

// TODO - Might want to remove this
File.AppendAllText($"{NASARData.GlobalConfig.tempPath}\\MisMatchingVariants.txt", $"APT IATA: {AptIata} - {tempRecordList[missingIndex].FAAChartName}\n");
// Might want to remove this - This is to see MisMatchingVaarents inside the Temp File.
// File.AppendAllText($"{NASARData.GlobalConfig.tempPath}\\MisMatchingVariants.txt", $"APT IATA: {AptIata} - {tempRecordList[missingIndex].FAAChartName}\n");
}
}

Expand Down
2 changes: 1 addition & 1 deletion NASR_GUI/CreditsForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit fce3c77

Please sign in to comment.