예제 #1
0
        public PacificTrack Parse()
        {
            var result = new TdmParser(text).Parse();

            var mainRoute = result.MainRoute.Split(
                new char[] { ' ', '\n', '\r', '\t' },
                StringSplitOptions.RemoveEmptyEntries)
                            .ToRouteString();

            var connectRoutes = ConnectionRouteInterpreter.Convert(
                mainRoute,
                result.ConnectionRoutes,
                airportList);

            return(new PacificTrack(
                       PacotDirection.Westbound,
                       result.Ident,
                       result.TimeStart,
                       result.TimeEnd,
                       CutOffTextAfterParenthesis(result.Remarks),
                       mainRoute,
                       connectRoutes.RouteFrom,
                       connectRoutes.RouteTo,
                       Constants.JapanLatlon,
                       Constants.USLatlon));
        }
        /// <summary>
        /// Returns null is the given string represents a track which is
        /// currently not available.
        /// </summary>
        /// <exception cref="TrackParseException"></exception>
        public AusTrack Parse()
        {
            var result = new TdmParser(text).Parse();

            var mainRoute = result.MainRoute.Split(
                new char[] { ' ', '\t', '\n', '\r' },
                StringSplitOptions.RemoveEmptyEntries)
                            .ToRouteString();

            var connectRoutes = ConnectionRouteInterpreter.Convert(
                mainRoute,
                result.ConnectionRoutes,
                airportList);

            if (TrackAvailble(mainRoute, result.Ident))
            {
                return(new AusTrack(
                           result.Ident,
                           result.TimeStart,
                           result.TimeEnd,
                           result.Remarks,
                           mainRoute,
                           connectRoutes.RouteFrom,
                           connectRoutes.RouteTo,
                           PreferredLatLon,
                           PreferredLatLon));
            }

            return(null);
        }
예제 #3
0
        private PacificTrack[] CreateEastboundTracks(string item)
        {
            var timeInfo  = TrackValidPeriod.GetValidPeriod(item);
            var tracksStr = new Splitter(item).Split();
            var result    = new PacificTrack[tracksStr.Count];

            for (int i = 0; i < result.Length; i++)
            {
                var trk       = Interpreter.Parse(tracksStr[i]);
                var mainRoute = trk.FlexRoute.ToRouteString();

                var connectionRoutes = ConnectionRouteInterpreter.Convert(
                    mainRoute,
                    ConnectionRouteSeperator.Seperate(trk.ConnectionRoute),
                    airportList);

                result[i] = new PacificTrack(
                    PacotDirection.Eastbound,
                    trk.ID.ToString(),
                    timeInfo.Start,
                    timeInfo.End,
                    trk.Remark,
                    mainRoute,
                    connectionRoutes.RouteFrom,
                    connectionRoutes.RouteTo,
                    Constants.JapanLatlon,
                    Constants.USLatlon);
            }

            return(result);
        }
        public void RecongnizeToOrFromCorrectly()
        {
            var result = ConnectionRouteInterpreter.Convert(
                new[] { "P1", "P2", "P3" },
                new[] { "Q P1", "P3 R" },
                new AirportManager());

            Assert.AreEqual(1, result.RouteFrom.Count);
            Assert.AreEqual(1, result.RouteTo.Count);

            Assert.IsTrue(result.RouteFrom[0].SequenceEqual(new[] { "Q", "P1" }));
            Assert.IsTrue(result.RouteTo[0].SequenceEqual(new[] { "P3", "R" }));
        }
        public void RemovesAirportsCorrectly()
        {
            var airports = new AirportManager();

            airports.Add(GetAirport("ABCD"));
            airports.Add(GetAirport("EFGH"));

            var result = ConnectionRouteInterpreter.Convert(
                new[] { "P1", "P2", "P3" },
                new[] { "ABCD Q P1", "P3 R EFGH" },
                airports);

            Assert.AreEqual(1, result.RouteFrom.Count);
            Assert.AreEqual(1, result.RouteTo.Count);

            Assert.IsTrue(result.RouteFrom[0].SequenceEqual(new[] { "Q", "P1" }));
            Assert.IsTrue(result.RouteTo[0].SequenceEqual(new[] { "P3", "R" }));
        }