Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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
        }
Exemplo n.º 3
0
        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];
                }
            }
        }
Exemplo n.º 4
0
        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);
        }