Beispiel #1
0
        public static int  NavRTE()
        {
            // Add NaviGraph routes (wpNavRTE)
            // Returns number of rows read to datatable (0 if failed, no file)
            string   FullFilename = SCTcommon.GetFullPathname(FolderMgt.DataFolder, "wpNavRTE.txt");
            DataView dv           = new DataView(wpNavRTE);
            int      result       = 0;

            if (FullFilename.IndexOf("Error") == -1)
            {
                using (StreamReader sr = new StreamReader(FullFilename))
                {
                    while ((Line = sr.ReadLine()) != null)   // Until EOF
                    {
                        if (Line.Substring(0, 1) != ";")     // Check for comment
                        {
                            AddRTE(dv);
                        }
                    }
                    result = dv.Count;
                    Console.WriteLine(result + " rows added to" + dv.Table.TableName);
                }
            }
            dv.Dispose();
            return(result);
        }
Beispiel #2
0
        public static int  NavFIX()
        {
            string   FullFilename = SCTcommon.GetFullPathname(FolderMgt.DataFolder, "wpNavFIX.txt");
            DataView dv           = new DataView(FIXes);
            int      result       = 0;

            if (FullFilename.IndexOf("Error") == -1)
            {
                using (StreamReader sr = new StreamReader(FullFilename))
                {
                    while ((Line = sr.ReadLine()) != null)
                    {
                        if (Line.Substring(0, 1) != ";")
                        {
                            DataRowView drv = dv.AddNew();
                            drv = dv.AddNew();
                            drv["FacilityID"] = Line.Substring(0, 5).Trim();
                            drv[1]            = Convert.ToDouble(Line.Substring(29, 10).Trim());
                            drv[2]            = Convert.ToDouble(Line.Substring(39, 11).Trim());
                            drv.EndEdit();
                        }
                    }
                    result = dv.Count;
                    Console.WriteLine(result + " rows added to " + dv.Table.TableName);
                }
            }
            dv.Dispose();
            return(result);
        }
Beispiel #3
0
        public static int NavAID()
        {
            string   FullFilename = SCTcommon.GetFullPathname(FolderMgt.DataFolder, "wpNavAID.txt");
            DataView dv           = new DataView(wpNavAID);
            int      result       = 0;

            if (FullFilename.IndexOf("Error") == -1)
            {
                wpNavAID.Clear();
                using (StreamReader sr = new StreamReader(FullFilename))
                {
                    while ((Line = sr.ReadLine()) != null)
                    {
                        if (Line.Substring(0, 1) != ";")
                        {
                            DataRowView drv = dv.AddNew();
                            drv["Name"]       = Line.Substring(0, 14).Trim();
                            drv["FacilityID"] = Line.Substring(24, 5).Trim();
                            drv["Type"]       = Line.Substring(29, 4).Trim();
                            drv["Latitude"]   = Convert.ToDouble(Line.Substring(33, 10).Trim());
                            drv["Longitude"]  = Convert.ToDouble(Line.Substring(43, 11).Trim());
                            drv["Frequency"]  = Line.Substring(54, 6).Trim();
                            drv.EndEdit();
                        }
                    }
                }
                result = dv.Count;
                Console.WriteLine(result + " rows added to" + dv.Table.TableName);
            }
            dv.Dispose();
            return(result);
        }
Beispiel #4
0
        public static int Airports()
        {
            // Add the Airports index (has only ICAO and Lat/Lon)
            // Use the wpNavAPT file for runways and Airport names
            // RETURNS number of rows added (0 for no file or failed)
            int      result = 0; const int ICOA = 0; const int Lat = 1; const int Lon = 2;
            string   FullFilename = SCTcommon.GetFullPathname(FolderMgt.DataFolder, "airports.dat");
            DataView dv           = new DataView(airports);

            if (FullFilename.IndexOf("Error") == -1)
            {
                using (StreamReader sr = new StreamReader(FullFilename))
                {
                    while ((Line = sr.ReadLine()) != null)   // Until EOF
                    {
                        if (Line.Substring(0, 1) != ";")     // Check for comment
                        {
                            DataRowView drv = dv.AddNew();
                            drv[ICOA] = Line.Substring(0, 4);
                            drv[Lat]  = Convert.ToDouble(Line.Substring(4, 10).Trim());
                            drv[Lon]  = Convert.ToDouble(Line.Substring(14, 11).Trim());
                            drv.EndEdit();
                        }
                    }
                    result = dv.Count;
                    Console.WriteLine(result + " rows added to" + dv.Table.TableName);
                }
            }
            dv.Dispose();
            return(result);
        }
Beispiel #5
0
        public static void NavRTE()
        {
            // Add NaviGraph routes that are NOT in FAA table
            // That is - Ultra, Oceanic, and World routes
            string   curID; string prevID = string.Empty;
            bool     IDexists = false; bool Adding;
            string   FullFilename = SCTcommon.GetFullPathname(FolderMgt.DataFolder, "wpNavRTE.txt");
            DataView dvRTE        = new DataView(NGRTE);

            if (FullFilename.IndexOf("Error") != -1)
            {
                using (StreamReader sr = new StreamReader(FullFilename))
                {
                    while ((Line = sr.ReadLine()) != null)   // Until EOF
                    {
                        if (Line.Substring(0, 1) != ";")     // Check for comment
                        {
                            curID  = Line.Substring(0, Line.IndexOf(" ")).Trim();
                            Adding = curID == prevID;
                            if (!Adding)
                            {
                                dvRTE.RowFilter = "[AWYID] = '" + curID + "'";
                                IDexists        = (dvRTE.Count != 0);
                            }
                            if (Adding || !IDexists)
                            {
                                AddRTE(dvRTE);
                            }
                            prevID = curID;
                        }
                    }
                }
            }
        }
Beispiel #6
0
        public static void NavFIX()
        {
            string      FullFilename = SCTcommon.GetFullPathname(FolderMgt.DataFolder, "wpNavFIX.txt");
            DataView    dvNGFIX      = new DataView(NGFixes);
            DataRowView datarow;

            if (FullFilename.IndexOf("Error") == -1)
            {
                using (StreamReader sr = new StreamReader(FullFilename))
                {
                    while ((Line = sr.ReadLine()) != null)
                    {
                        if (Line.Substring(0, 1) != ";")
                        {
                            datarow = dvNGFIX.AddNew();
                            datarow["FacilityID"] = Line.Substring(0, 5).Trim();
                            datarow[1]            = Convert.ToDouble(Line.Substring(29, 10).Trim());
                            datarow[2]            = Convert.ToDouble(Line.Substring(39, 11).Trim());
                            datarow.EndEdit();
                        }
                    }
                    Debug.WriteLine(NGFixes.Rows.Count + " rows added to NGFixes");
                }
            }
            dvNGFIX.Dispose();
        }
Beispiel #7
0
        public static void NavAID()
        {
            string      FullFilename = SCTcommon.GetFullPathname(FolderMgt.DataFolder, "wpNavAID.txt");
            DataView    dvNGNavAid   = new DataView(NGNavAID);
            DataRowView dataRow;

            if (FullFilename.IndexOf("Error") == -1)
            {
                NGNavAID.Clear();
                using (StreamReader sr = new StreamReader(FullFilename))
                {
                    while ((Line = sr.ReadLine()) != null)
                    {
                        if (Line.Substring(0, 1) != ";")
                        {
                            dataRow               = dvNGNavAid.AddNew();
                            dataRow["Name"]       = Line.Substring(0, 14).Trim();
                            dataRow["FacilityID"] = Line.Substring(24, 5).Trim();
                            dataRow["Type"]       = Line.Substring(29, 4).Trim();
                            dataRow["Latitude"]   = Convert.ToDouble(Line.Substring(33, 10).Trim());
                            dataRow["Longitude"]  = Convert.ToDouble(Line.Substring(43, 11).Trim());
                            dataRow["Frequency"]  = Line.Substring(54, 6).Trim();
                            dataRow.EndEdit();
                        }
                    }
                }
                Debug.Print(NGNavAID.Rows.Count + " rows added to NGNavAid table.");
            }
            dvNGNavAid.Dispose();
        }
Beispiel #8
0
        public static int AIRAC()
        {
            // Find the cycleinfo.txt file.  -1 if doesnt exist (bad folder) or return AIRAC
            int    result = -1; string Line; string sResult; string sTemp;
            string FullFilename = SCTcommon.GetFullPathname(FolderMgt.DataFolder, "cycle_info.txt");

            if (FullFilename.IndexOf("ERROR") != -1)
            {
                return(result);
            }
            DataView    dv  = new DataView(cycleinfo);
            DataRowView drv = dv.AddNew();

            using (StreamReader reader = new StreamReader(FullFilename))
            {
                Line = reader.ReadLine();
                if (result == -1)
                {
                    if (Line.IndexOf("AIRAC") != -1)
                    {
                        sResult      = Line.Substring(Line.IndexOf(":") + 1);
                        result       = Convert.ToInt32(sResult.Trim());
                        drv["AIRAC"] = Convert.ToInt32(result);
                    }
                    if (Line.IndexOf("Version") != -1)
                    {
                        sResult        = Line.Substring(Line.IndexOf(":") + 1);
                        result         = Convert.ToInt32(sResult.Trim());
                        drv["Version"] = Convert.ToInt32(result);
                    }
                    if (Line.IndexOf("Valid") != -1)
                    {
                        sResult          = Line.Substring(Line.IndexOf(":") + 1).Trim();
                        sTemp            = Line.Substring(0, Line.IndexOf("-") - 1).Trim();
                        drv["BeginDate"] = DateTime.ParseExact(sTemp, "dd/MMM/yyyy", CultureInfo.InvariantCulture);
                        sResult          = Line.Substring(Line.IndexOf("-")).Trim();
                        drv["EndDate"]   = DateTime.ParseExact(sResult, "dd/MMM/yyyy", CultureInfo.InvariantCulture);
                    }
                    if (Line.IndexOf("Files parsed") != -1)
                    {
                        sResult           = Line.Substring(Line.IndexOf(":") + 1).Trim();
                        drv["ParsedDate"] = DateTime.ParseExact(sResult, "dd/mm/yyyy", CultureInfo.InvariantCulture);
                    }
                }
            }
            drv.EndEdit();
            dv.Dispose();
            return(result);
        }
Beispiel #9
0
        public static int ReadPOFfile(string filepath = "")
        {
            int    result;
            string line; string FullFilename;

            Form1.POFdata.Clear();
            if (filepath.Length == 0)
            {
                FullFilename = SCTcommon.GetFullPathname(FolderMgt.DataFolder, "ARTCC.pof");
                string msg = "In order to generate the [POSITIONS] section of the ESE file, " + cr +
                             "you must place a copy of your POF file in the SCT Builder resource folder." + cr +
                             "Name the file ARTCC.pof. You can do this now." + cr + cr +
                             "Click OK to continue or Cancel to skip creating the [POSITIONS] section";
                while (FullFilename == "ERROR")
                {
                    DialogResult dialogResult = SCTcommon.SendMessage(msg, MessageBoxIcon.Warning, MessageBoxButtons.OKCancel);;
                    if (dialogResult == DialogResult.Cancel)
                    {
                        break;
                    }
                    FullFilename = SCTcommon.GetFullPathname(FolderMgt.DataFolder, "ARTCC.pof");
                }
            }
            else
            {
                FullFilename = filepath;
            }
            using (StreamReader sr = new StreamReader(FullFilename))
            {
                while ((line = sr.ReadLine()) != null)
                {
                    if ((line.Length != 0) && (line.Substring(0, 1) != ";"))
                    {
                        LoadPOFrow(line);
                    }
                }
            }
            result = Form1.POFdata.Rows.Count;
            if (result > 0)
            {
                AddCoordsToPOF();
            }
            Console.WriteLine("ReadPOF.ReadPOFfile added " + result + " rows to POFdata table.");
            return(result);
        }
Beispiel #10
0
        public static int NavAPT()
        {
            // Add the NavAPT file to the DataTable
            // Because this file is column-delimited, cannot use ParseLine
            // RETURNS number of rows read (0 if no file or failed)
            int       result = 0;
            const int FacID = 0; const int Name = 1; const int RWY = 2; const int Length = 3; const int Brg = 4;
            const int FinalBrg = 8;  const int Lat = 5; const int Lon = 6; const int Freq = 7; const int Elev = 9;

            string   FullFilename = SCTcommon.GetFullPathname(FolderMgt.DataFolder, "wpNavAPT.txt");
            DataView dv           = new DataView(wpNavAPT);

            if (FullFilename.IndexOf("Error") == -1)
            {
                using (StreamReader sr = new StreamReader(FullFilename))
                {
                    while ((Line = sr.ReadLine()) != null)   // Until EOF
                    {
                        if (Line.Substring(0, 1) != ";")     // Check for comment
                        {
                            DataRowView drv = dv.AddNew();
                            drv[Name]     = Line.Substring(0, 24);
                            drv[FacID]    = Line.Substring(24, 4);
                            drv[RWY]      = Line.Substring(28, 3).Trim();
                            drv[Length]   = Convert.ToInt32(Line.Substring(31, 5));
                            drv[Brg]      = Convert.ToInt32(Line.Substring(36, 3));
                            drv[Lat]      = Convert.ToDouble(Line.Substring(39, 10).Trim());
                            drv[Lon]      = Convert.ToDouble(Line.Substring(49, 11).Trim());
                            drv[Freq]     = Convert.ToDouble(Line.Substring(60, 6).Trim());
                            drv[FinalBrg] = Convert.ToInt32(Line.Substring(66, 3));
                            drv[Elev]     = Convert.ToInt32(Line.Substring(69, 5));
                            drv.EndEdit();
                        }
                    }
                    result = dv.Count;
                    Console.WriteLine(result + " rows added to" + dv.Table.TableName);
                }
            }
            dv.Dispose();
            return(result);
        }
Beispiel #11
0
        public static int AIRAC()
        {
            // Find the cycleinfo.txt file.  -1 if doesnt exist (bad folder) or return AIRAC
            int    result = -1; string Line; string sResult;
            string FullFilename = SCTcommon.GetFullPathname(FolderMgt.DataFolder, "cycle_info.txt");

            if (FullFilename.IndexOf("ERROR") != -1)
            {
                return(result);
            }
            using (StreamReader reader = new StreamReader(FullFilename))
            {
                Line = reader.ReadLine();
                if (result == -1)
                {
                    if (Line.IndexOf("AIRAC") == -1)
                    {
                        sResult = Line.Substring(Line.IndexOf(":") + 1);
                        result  = Convert.ToInt32(sResult.Trim());
                    }
                }
            }
            return(result);
        }
Beispiel #12
0
        private static void WriteSIDSTAR(string path)
        {
            // ESE's SIDSTAR format is VERY different than VRCs
            // <SID/STAR>:<AIRPORT ICAO>:<RUNWAY>:<TRANSITIONxPROCEDURE>:<ROUTE>
            // Example:
            // SID:PHNL:08L:PALAY2xLNY:PALAY ROSHE LNY
            // STAR:PHNL:08L:APACKxMAGGI3:APACK TOADS SOPIW MAGGI BAMBO GRITL CKH
            // Calling routine for SID and STAR diagrams
            // SSD = Either SID or STAR, depending on flag
            string        ICOAapt;
            List <string> SSDcodes = new List <string>();
            string        SIDout = string.Empty; string STARout = string.Empty;
            DataTable     APT                = Form1.APT;
            DataView      dvNGSID            = new DataView(ReadNaviGraph.NGSID);
            DataView      dvNGSIDTransition  = new DataView(ReadNaviGraph.NGSIDTransition);
            DataView      dvNGSTAR           = new DataView(ReadNaviGraph.NGSTAR);
            DataView      dvNGSTARTransition = new DataView(ReadNaviGraph.NGSTARTransition);
            DataView      dvNGRWYS           = new DataView(ReadNaviGraph.NGRWYS);
            // Using the SELECTED airports, select the SIDS from NG
            // Get the list of Selected Airports
            DataView dvAPT = new DataView(APT)
            {
                RowFilter = "[Selected] AND (LEN([ICOA]) > 0)",
                Sort      = "SSDcode, Sequence",
            };

            // Read each NG file as needed to build the ESE text
            using (StreamWriter sw = new StreamWriter(path))
            {
                foreach (DataRowView drvAPT in dvAPT)
                {
                    ICOAapt = drvAPT["ICAO"].ToString();
                    string FullFilename = SCTcommon.GetFullPathname(FolderMgt.DataFolder, ICOAapt + ".txt");
                    if (FullFilename.IndexOf("ERROR") == -1)
                    {
                        if (ReadNaviGraph.SIDSTARS(ICOAapt, FullFilename))
                        {
                            // Now we have ONE airport of SIDS and STARS in their respective tables
                            if (dvNGSID.Count > 0)
                            {
                                // Loop the SIDs
                                foreach (DataRowView dvrNGSID in dvNGSID)
                                {
                                    SSDcodes = AddUniqueToList(SSDcodes, dvrNGSID["SSDcode"].ToString());
                                }
                                foreach (string SSDcode in SSDcodes)
                                {
                                    Debug.WriteLine("ESEoutput-WriteSSD: Processing " + SSDcode + " in " + ICOAapt);
                                    dvNGSID.RowFilter           = "[SSDCode] = '" + SSDcode + "'";
                                    dvNGSIDTransition.RowFilter = "[SSDCode] = '" + SSDcode + "'";
                                    SIDout += OutputSID(ICOAapt, dvNGSID, dvNGSIDTransition, dvNGRWYS);
                                }
                            }
                            if (dvNGSTAR.Count > 0)
                            {
                                // Loop the STARS
                                SSDcodes.Clear();
                                foreach (DataRowView dvrNGSTAR in dvNGSTAR)
                                {
                                    SSDcodes = AddUniqueToList(SSDcodes, dvrNGSTAR["SSDcode"].ToString());
                                }
                                foreach (string SSDcode in SSDcodes)
                                {
                                    Debug.WriteLine("ESEoutput-WriteSSD: Processing " + SSDcode + " in " + ICOAapt);
                                    dvNGSTAR.RowFilter           = "[SSDCode] = '" + SSDcode + "'";
                                    dvNGSTARTransition.RowFilter = "[SSDCode] = '" + SSDcode + "'";
                                    // STARout += OutputSTAR(ICOAapt, dvNGSTAR, dvNGSTARTransition, dvNGRWYS);
                                }
                            }
                        }
                    }
                    else
                    {
                        Debug.WriteLine("Skipped " + drvAPT["FacilityID"]);
                    }
                }
            }
        }