Exemple #1
0
        /// <exception cref="ArgumentException"></exception>
        public Route Analyze()
        {
            lastAwy = null;

            routeInput.Skip(1).ForEach(i =>
            {
                if (lastAwy == null)
                {
                    // This one may be airway or waypoint.

                    if (!TryParseAwy(i) && !TryParseWpt(i))
                    {
                        throw new ArgumentException(
                            $"{i} is not a valid waypoint or airway identifier");
                    }
                }
                else
                {
                    //this one must be wpt
                    if (!TryParseWpt(i))
                    {
                        throw new ArgumentException(
                            $"Cannot find waypoint {i} on airway {lastAwy}");
                    }
                }
            });

            if (lastAwy != null)
            {
                // That last string in routeInput is an airway.
                throw new ArgumentException($"There should be a waypoint after airway {lastAwy}.");
            }

            return(rte);
        }
        private RouteString RemoveIcaos(RouteString route)
        {
            bool firstIsIcao = route[0] == origIcao;
            bool lastIsIcao  = route.Last() == destIcao;

            int skipHead = firstIsIcao ? 1 : 0;
            int skipTail = lastIsIcao ? 1 : 0;

            return(route
                   .Skip(skipHead)
                   .Take(route.Count - skipHead - skipTail)
                   .ToRouteString());
        }