예제 #1
0
        public void TranslateJourney_SimpleJourney_CorrectTranslation()
        {
            var depDate = new DateTime(2019, 06, 19, 10, 00, 00).ToUniversalTime();
            var tdb     = new TransitDb(0);

            var writer = tdb.GetWriter();
            var stop0  = writer.AddOrUpdateStop("https://example.org/stop0", 0, 0);
            var stop1  = writer.AddOrUpdateStop("https://example.org/stop1", 1, 1);
            var stop2  = writer.AddOrUpdateStop("https://example.org/stop2", 2, 2);

            var trip0 = writer.AddOrUpdateTrip("https://example.org/trip0",
                                               new[] { new Attribute("headsign", "Oostende") });

            var conn0 = writer.AddOrUpdateConnection(stop0, stop1, "https://example.org/conn1", depDate.AddMinutes(-10),
                                                     10 * 60,
                                                     0, 0, trip0, 0);

            writer.Close();

            var con        = tdb.Latest.ConnectionsDb;
            var connection = con.Get(conn0);

            var genesis = new Journey <TransferMetric>(stop0,
                                                       depDate.ToUnixTime(), TransferMetric.Factory,
                                                       Journey <TransferMetric> .EarliestArrivalScanJourney);

            var journey0 = genesis.ChainForward(connection);

            var journey1 = journey0.ChainSpecial(
                Journey <TransferMetric> .OTHERMODE, depDate.AddMinutes(15).ToUnixTime(),
                stop2, new TripId(uint.MaxValue, uint.MaxValue));


            var state = new State(new List <Operator>
            {
                new Operator("test", tdb, null, 0, null, null)
            }, null, null, null);

            var cache = new CoordinatesCache(new CrowsFlightTransferGenerator(), false);

            var translated = state.Operators.GetFullView().Translate(journey1, cache);

            Assert.Equal("https://example.org/stop0", translated.Segments[0].Departure.Location.Id);
            Assert.Equal("https://example.org/stop1", translated.Segments[0].Arrival.Location.Id);
            Assert.Equal("https://example.org/trip0", translated.Segments[0].Vehicle);


            Assert.Equal("https://example.org/stop1", translated.Segments[1].Departure.Location.Id);
            Assert.Equal("https://example.org/stop2", translated.Segments[1].Arrival.Location.Id);
            Assert.Null(translated.Segments[1].Vehicle);
        }