예제 #1
0
        private void RwyComboBoxIndexChanged(object sender, EventArgs e)
        {
            if (rwyComboBox.Items.Count > 0)
            {
                var takeoffAirport = Airports[Icao];
                int index          = rwyComboBox.SelectedIndex;

                int elevationFt = takeoffAirport.Rwys[index].Elevation;
                int lengthFt    = takeoffAirport.Rwys[index].LengthFt;

                SetLength(lengthFt);
                elevationTxtBox.Text = elevationFt.ToString();

                var heading = takeoffAirport.Rwys[index].Heading;
                rwyHeadingTxtBox.Text = heading.PadLeft(3, '0');

                var oppositeId = RwyIdentConversion.RwyIdentOppositeDir(rwyComboBox.Text);

                if (oppositeId == null)
                {
                    SetSlope(0.0);
                    return;
                }

                var opposite = takeoffAirport.FindRwy(oppositeId);

                var slope = opposite == null
                    ? 0.0
                    : (opposite.Elevation - elevationFt) * 100.0 / lengthFt;

                SetSlope(slope);
            }
        }
        // Returns null if the runway or the opposite runway cannot be found.
        public static double?GetSlopePercent(this IAirport a, string runway)
        {
            var rwy = a.FindRwy(runway);

            if (rwy == null)
            {
                return(null);
            }

            var oppositeId = RwyIdentConversion.RwyIdentOppositeDir(runway);

            if (oppositeId == null)
            {
                return(null);
            }

            var opposite = a.FindRwy(oppositeId);

            if (opposite == null)
            {
                return(null);
            }

            return((opposite.ElevationFt - rwy.ElevationFt) * 100.0 / rwy.LengthFt);
        }