예제 #1
0
        public static RouteElement GetRouteElement(RouteElement previous, string current, string next)
        {
            // Check Direct
            if (Direct.IsValid(current))
            {
                //Create a new Direct element
                return(new Direct());
            }

            // First element
            if (previous == null)
            {
                //Either SpeedLevel or Airway
                if (SpeedLevel.IsValid(current))
                {
                    return(new SpeedLevel(current));
                }
                // Definitely airway
                else
                {
                    return(new Airway(current));
                }
            }
            // Middle element or last element
            else
            {
                // Last element
                if (next.Equals(string.Empty))
                {
                    // Either NamedPoint, CoordinatePoint or NavaidPoint or STAR(TO BE IMPLEMENTED)
                    // TODO: Implement STAR
                    return(GetSignificantPoint(current));
                }
                // Middle element
                else
                {
                    // Either ChangeOfFlightRule, ChangeOfSpeedLevelPoint, NavaidPoint, CoordinatePoint, NamedPoint or Airway
                    // Check ChangeOfFlightRule
                    if (ChangeOfFlightRule.IsValid(current))
                    {
                        return(new ChangeOfFlightRule(current));
                    }
                    // Check ChangeOfSpeedLevelPoint
                    else if (ChangeOfSpeedLevelPoint.IsValid(current))
                    {
                        string[] currentParts = current.Split('/');

                        SignificantPoint significantPoint = GetSignificantPoint(currentParts[0]);
                        SpeedLevel       speedLevel       = new SpeedLevel(currentParts[1]);

                        return(new ChangeOfSpeedLevelPoint(significantPoint, speedLevel));
                    }
                    // Check CoordinatePoint before checking airway since they can be adjacent
                    else if (CoordinatePoint.IsValid(current))
                    {
                        //Create CoordinatePoint
                        return(new CoordinatePoint(current));
                    }
                    // Either SignificantPoint or Airway
                    // Find the type of previous element
                    else if (previous is Airway | previous is SpeedLevel | previous is Direct)
                    {
                        // Current is a NamedPoint
                        return(GetSignificantPoint(current));
                    }
                    else
                    {
                        // Current is an Airway
                        return(new Airway(current));
                    }
                }
            }
        }
 public ChangeOfSpeedLevelPoint(SignificantPoint point, SpeedLevel changeOfSpeedLevel)
     : base(string.Format(CultureInfo.InvariantCulture, "{0}/{1}", point.Representation, changeOfSpeedLevel.Representation))
 {
     _point = point;
     _changeOfSpeedLevel = changeOfSpeedLevel;
 }