public static List <string> GetScheduleHeader(GTFSFeed feed, string route, DirectionType?dir, TimepointStrategy strat) { IEnumerable <string> timepointList; if (strat == TimepointStrategy.SpecifiedTimepoints) { timepointList = TimepointFinder.DataTimepoints(feed, route, dir, true) .Select(x => x.Item1); } else if (strat == TimepointStrategy.NullTimepoints) { timepointList = TimepointFinder.DataTimepoints(feed, route, dir, true) .Select(x => x.Item1); } else { timepointList = TimepointFinder.FirstAndLastStopList(feed, route, dir); } var timepointsOrdered = from stops in StopLister.GetStopOrder(feed, route, dir) join timepoints in timepointList on stops.Id equals timepoints select stops.Id; return(timepointsOrdered.ToList()); }
// public static bool PrintStopLists = true; // this one doesn't do anything atm static void Main(string[] args) { var reader = new GTFSReader <GTFSFeed>(); GTFSFeed feed = reader.Read("gtfs/" + GTFSFilename); TimepointStrategy strat = TimepointFinder.GetTimepointStrategy(feed); var dateRange = CalendarTester.GetFeedDateRange(feed); var allUsedServices = from trips in feed.Trips group trips by trips.ServiceId into narrowTrips let servId = narrowTrips.First().ServiceId select new { Key = servId, Value = CalendarTester.GetDescription(feed, servId, dateRange) }; Dictionary <string, string> serviceDescriptions = allUsedServices.ToDictionary(x => x.Key, x => x.Value); foreach (Route route in feed.Routes) { // What direction(s) does the route run? IEnumerable <DirectionType?> dirs = from trips in feed.Trips where trips.RouteId == route.Id group trips by trips.Direction into narrowTrips select narrowTrips.First().Direction; // What service(s) does the route run on? IEnumerable <string> services = from trips in feed.Trips where trips.RouteId == route.Id group trips by trips.ServiceId into narrowTrips select narrowTrips.First().ServiceId; if (PrintSchedules) { using StreamWriter output = new StreamWriter($"output/schedules/{route.Id}.md"); output.WriteLine("# " + (route.ShortName ?? "") + ((route.ShortName != null && route.LongName != null) ? " - " : "") + (route.LongName ?? "")); foreach (DirectionType?dir in dirs) { output.WriteLine("## " + dir switch { DirectionType.OneDirection => "Main Direction", DirectionType.OppositeDirection => "Opposite Direction", _ => "No Direction" });
public static Tuple <List <string>, List <Tuple <string, Dictionary <string, TimeOfDay> > > > GetSchedule(GTFSFeed feed, string route, DirectionType?dir, string serviceId) => GetSchedule(feed, route, dir, serviceId, TimepointFinder.GetTimepointStrategy(feed));
public static List <string> GetScheduleHeader(GTFSFeed feed, string route, DirectionType?dir) => GetScheduleHeader(feed, route, dir, TimepointFinder.GetTimepointStrategy(feed));