Beispiel #1
0
        public void Translate_Journey_CorrectTranslation()
        {
            const ulong time         = 15761461220ul;
            const ulong previousTime = 15761454920ul;



            var tdb = new TransitDb(0);
            var wr  = tdb.GetWriter();
            var l   = wr.AddOrUpdateStop("Some Station", 4.123, 51.789, null);

            var rootL      = new StopId(1, 140860940, 184354050); // Supposed to be an OSM-location
            var connection = new Connection(new ConnectionId(0, 1),
                                            "testConnection", rootL, l, previousTime, (ushort)(time - previousTime), new TripId(0, 0));

            var connId = wr.AddOrUpdateConnection(connection);

            wr.Close();
            var genesis = new Journey <TransferMetric>(rootL, previousTime, TransferMetric.Factory);
            var j       = genesis.ChainSpecial(connId, previousTime, l, new TripId(3, 3));

            var op        = new Operator("Op", tdb, null, 500, new string[] { }, new string[] { });
            var operators = new OperatorSet(new List <Operator> {
                op
            });
            var translatedSegment =
                operators.TranslateWalkSegment(j, new CoordinatesCache(new DummyOtherMode(), false));

            Assert.Contains("openstreetmap.org", translatedSegment.Departure.Location.Id);
            Assert.DoesNotContain("openstreetmap.org", translatedSegment.Arrival.Location.Id);
        }
Beispiel #2
0
        /// <summary>
        /// Requests the next departure for the specified route, direction, stop id and route type
        /// </summary>
        /// <param name="r">Route id</param>
        /// <param name="d">Direction id</param>
        /// <param name="s">Stop id</param>
        /// <param name="t">Route type</param>
        /// <returns>The next departure in a Departure object</returns>
        public static async Task <Departure> GetNextDeparture(RouteId r, DirectionId d, RouteType t)
        {
            StopId    s         = t == RouteType.Train ? StopId.GlenferrieTrain : d == DirectionId.MelbUniViaStKilda ? StopId.GlenferrieTramMelbUni : StopId.GlenferrieTramKew;
            Departure departure = (await PTV.RequestPTVPayloadAsync($"departures/route_type/{(int)t}/stop/{(int)s}/route/{(int)r}?direction_id={(int)d}&max_results=1")).Departures[0];

            return(departure);
        }
            public TravellingTimeMinimizer Add(Journey <TravellingTimeMinimizer> journey, StopId currentLocation, ulong currentTime, TripId currentTripId,
                                               bool currentIsSpecial)
            {
                var totalTimeWalking   = _totalTimeWalking;
                var totalTimeInVehicle = _totalTimeInVehicle;
                var smallestTransfer   = _smallestTransfer;

                var journeyTime = (uint)(journey.ArrivalTime() - journey.DepartureTime());

                if (journey.SpecialConnection && journey.Connection.Equals(OTHERMODE))
                {
                    totalTimeWalking += journeyTime;
                }
                else if (journey.SpecialConnection && journey.Connection.Equals(OTHERMODE))
                {
                    smallestTransfer = Math.Min(smallestTransfer, journeyTime);
                }
                else if (!journey.SpecialConnection)
                {
                    // We simply are travelling in a vehicle
                    totalTimeInVehicle += journeyTime;
                }

                return(new TravellingTimeMinimizer(totalTimeWalking, totalTimeInVehicle, smallestTransfer));
            }
Beispiel #4
0
 public IOtherModeGenerator GetSource(StopId from, StopId to)
 {
     return(this);
 }