Пример #1
0
        private void ConvertStops(ConversionContext context, Schedule schedule)
        {
            foreach (var tableStop in schedule.Table.Stops)
            {
                StopAndClientData stopAndClientData;
                if (!context.StopAndClientData.TryGetValue(tableStop.Name, out stopAndClientData))
                {
                    stopAndClientData = new StopAndClientData
                    {
                        Stop = new Stop {
                            Name = tableStop.Name
                        }
                    };
                    context.StopAndClientData[tableStop.Name] = stopAndClientData;
                    context.StopNames.Add(tableStop.Name);
                }

                stopAndClientData.IsHub = tableStop.IsHub;
            }

            foreach (var mapStop in schedule.Map.Stops)
            {
                StopAndClientData stopAndClientData;
                if (!context.StopAndClientData.TryGetValue(mapStop.Name, out stopAndClientData))
                {
                    stopAndClientData = new StopAndClientData
                    {
                        Stop = new Stop {
                            Name = mapStop.Name
                        }
                    };
                    context.StopAndClientData[mapStop.Name] = stopAndClientData;
                    context.StopNames.Add(mapStop.Name);
                }

                stopAndClientData.IsHub     = mapStop.IsHub;
                stopAndClientData.Stop.Id   = mapStop.Id.ToString();
                stopAndClientData.Stop.Desc = string.Join(", ", new[] { mapStop.Address, mapStop.City, mapStop.ZipCode }.Where(x => x != null));
                stopAndClientData.Stop.Lat  = mapStop.Latitude;
                stopAndClientData.Stop.Lon  = mapStop.Longitude;
            }
        }
Пример #2
0
        private void ConvertShapes(ConversionContext context, Schedule schedule)
        {
            string shapeId = context.ShapeIds.Count.ToString();

            context.ShapeIds.Add(schedule, shapeId);

            uint sequence = 0;

            foreach (var location in schedule.Map.Polyline.MapWayPoints)
            {
                context.ShapePoints.Add(new ShapePoint
                {
                    ShapeId  = shapeId,
                    Lat      = location.Latitude,
                    Lon      = location.Longitude,
                    Sequence = sequence
                });

                sequence++;
            }
        }
Пример #3
0
        private void ConvertTripThenStopTimes(ConversionContext context, string name, Schedule schedule, Period period)
        {
            foreach (var tableTrip in schedule.Table.Trips)
            {
                var tripId = context.Trips.Count.ToString();

                // add the trip
                context.Trips.Add(new Trip
                {
                    RouteId     = context.Routes[name].Id,
                    ServiceId   = context.Service.Id,
                    Id          = tripId,
                    DirectionId = period == Period.Pm,
                    ShapeId     = context.ShapeIds[schedule]
                });

                // add the trip's stop times
                uint stopSequence = 0;
                foreach (var tableStopTime in tableTrip.StopTimes)
                {
                    var stopAndClientData = context.StopAndClientData[tableStopTime.StopName];
                    var time = new Time(tableStopTime.Hour, tableStopTime.Minute, 0);

                    PickupType  pickupType;
                    DropOffType dropOffType;

                    if ((period == Period.Am && stopAndClientData.IsHub) ||
                        (period == Period.Pm && !stopAndClientData.IsHub))
                    {
                        pickupType  = PickupType.NoPickupAvailable;
                        dropOffType = DropOffType.RegularlyScheduled;
                    }
                    else
                    {
                        pickupType  = PickupType.RegularlyScheduled;
                        dropOffType = DropOffType.NoDropOffAvailable;
                    }

                    context.StopTimes.Add(new StopTime
                    {
                        TripId        = tripId,
                        ArrivalTime   = time,
                        DepartureTime = time,
                        StopId        = stopAndClientData.Stop.Id,
                        Sequence      = stopSequence,
                        PickupType    = pickupType,
                        DropOffType   = dropOffType
                    });

                    stopSequence++;
                }
            }
        }