Beispiel #1
0
 public void RemoveBusStop(BusStopData busStop)
 {
     if (MyBusStopps.Contains(busStop))
     {
         MyBusStopps.Remove(busStop);
     }
     else
     {
         Debug.LogError(busStop + " not found in collection of MyBusStopps");
     }
 }
        public IList <RouteStop> GetByBusStop(int busStopId, int numberOfTimes)
        {
            if (busStopId > 0 && busStopId <= 10)
            {
                var stop = new BusStopData
                {
                    Id         = busStopId,
                    Name       = $"Bus Stop {busStopId}",
                    RouteStops = new List <RouteStop>()
                };

                for (var routeId = 1; routeId <= 3; routeId++)
                {
                    var routeStop = new RouteStop
                    {
                        BusStopId = busStopId,
                        BusStop   = stop,
                        RouteId   = routeId,
                        Route     = new Route
                        {
                            Id         = routeId,
                            Name       = $"Route {routeId}",
                            RouteStops = stop.RouteStops
                        },
                        ArrivalTimes = new List <DateTime>()
                    };

                    // Each route starts running 2 minutes after the previous one
                    var timeOffset = (routeStop.RouteId - 1) * 2;
                    // Each stop is 2 minutes away from the previous one
                    timeOffset += (routeStop.BusStopId - 1) * 2;
                    // Each stop is serviced every 15 minutes per route
                    timeOffset = timeOffset % 15;
                    var nearestMultiple = this.FindNearestMultipleOfFifteen();
                    var nextStop        = this.FindNearestTimeWithOffset(nearestMultiple, timeOffset);

                    for (var num = 0; num < numberOfTimes; num++)
                    {
                        routeStop.ArrivalTimes.Add(nextStop);
                        nextStop = nextStop.AddMinutes(15);
                    }

                    stop.RouteStops.Add(routeStop);
                }

                return(stop.RouteStops);
            }
            else
            {
                return(new List <RouteStop>());
            }
        }
Beispiel #3
0
        protected override object Converter(JToken busStop)
        {
            var busStopData = new BusStopData()
            {
                Day   = DateTime.Parse(busStop.Path),
                Stops = new List <Stop>()
            };

            foreach (var item in busStop.Children())
            {
                busStopData.LastUpdate = item.Value <DateTime>("lastUpdate");

                var stopList = item.Value <JArray>("stops");

                foreach (var stop in stopList.Children <JObject>())
                {
                    var stopToAdd = new Stop()
                    {
                        StopId           = stop.Value <int>("stopId"),
                        StopCode         = stop.Value <string>("stopCode"),
                        StopName         = stop.Value <string>("stopName"),
                        StopShortName    = stop.Value <string>("stopShortName"),
                        StopDesc         = stop.Value <string>("stopDesc"),
                        SubName          = stop.Value <string>("subName"),
                        Date             = stop.Value <DateTime>("date"),
                        StopLat          = stop.Value <double>("stopLat"),
                        StopLon          = stop.Value <double>("stopLon"),
                        ZoneId           = stop.Value <int?>("zoneId") ?? 0,
                        ZoneName         = stop.Value <string>("zoneName"),
                        VirtualBusStop   = stop.Value <bool?>("virtual") ?? false,
                        NonPassenger     = stop.Value <bool?>("nonpassenger") ?? false,
                        Depot            = stop.Value <bool?>("depot") ?? false,
                        TicketZoneBorder = stop.Value <bool?>("ticketZoneBorder") ?? false,
                        OnDemand         = stop.Value <bool?>("onDemand") ?? false,
                        ActivationDate   = stop.Value <DateTime>("activationDate")
                    };

                    busStopData.Stops.Add(stopToAdd);
                }
            }

            return(busStopData);
        }
Beispiel #4
0
    //Params: Coverage range, max clients,
    //List of all the parts installed


    public void CreateBusStation(Vector3Int place)
    {
        myData = new BusStopData();
        gameObject.transform.position = place + CellCenterOffset.Value;  //need to place BusStop in the correct place in the grid
    }
        TripsWithBusStops Map(BusLineData busLine, ExpeditionData expeditionObject, TripData tripData, BusStopData busStopData, StopInTripData stopInTripData)
        {
            var tripsWithBusStops = new TripsWithBusStops()
            {
                Day   = busLine.Day,
                Trips = new List <Trip>()
            };

            busLine.Routes.ForEach(route =>
            {
                var tripListByRouteId = tripData.Trips.Where(x => x.RouteId == route.RouteId).ToList();

                tripListByRouteId.ForEach(tripByRouteId =>
                {
                    var expedition = expeditionObject.Expeditions
                                     .FirstOrDefault(exp => exp.RouteId == tripByRouteId.RouteId &&
                                                     exp.TripId == tripByRouteId.TripId &&
                                                     (exp.StartDate.Date == busLine.Day.Date || exp.StartDate.Date < busLine.Day.Date));

                    if (expedition == null || expedition.TechnicalTrip)
                    {
                        return;
                    }

                    tripsWithBusStops.Trips.Add(
                        new Trip()
                    {
                        Id           = tripByRouteId.Id,
                        TripId       = tripByRouteId.TripId,
                        RouteId      = tripByRouteId.RouteId,
                        AgencyId     = route.AgencyId,
                        BusLineName  = route.RouteShortName,
                        MainRoute    = expedition.MainRoute,
                        TripHeadsign = tripByRouteId.TripHeadsign,
                        DirectionId  = tripByRouteId.DirectionId,
                        Stops        = _stopHelper.GetStopList(tripByRouteId, stopInTripData.StopsInTrip.Where(x => x.RouteId == tripByRouteId.RouteId && x.TripId == tripByRouteId.TripId).ToList(), expedition.MainRoute, busStopData.Stops)
                    });
                });
            });

            tripsWithBusStops.Trips = tripsWithBusStops.Trips.OrderBy(x => x.BusLineName).ToList();

            return(tripsWithBusStops);
        }
Beispiel #6
0
 public void AddBusStop(BusStopData busStop)
 {
     MyBusStopps.Add(busStop);
 }