/// <summary> /// Initializes object. /// </summary> /// <param name="id">Trip ID.</param> /// <param name="headsign">Headsign.</param> /// <param name="routeInfo">Route Info.</param> /// <param name="service">Service.</param> public Trip(int id, string headsign, RoutesInfo.RouteInfo routeInfo, Calendar.Service service) { StopTimes = new List <StopTimes.StopTime>(); ID = id; Headsign = headsign; RouteInfo = routeInfo; Service = service; }
/// <summary> /// Initializes object using GTFS data feed. /// </summary> /// <param name="calendar">Calendar.</param> /// <param name="calendarDates">Calendar Dates.</param> public GtfsCalendarDates(System.IO.StreamReader calendarDates, Calendar calendar) { // Get order of field names. string[] fieldNames = calendarDates.ReadLine().Split(','); Dictionary <string, int> dic = new Dictionary <string, int>(); for (int i = 0; i < fieldNames.Length; i++) { dic.Add(fieldNames[i].Replace("\"", ""), i); } // These fields are required for our purpose. if (!dic.ContainsKey("service_id")) { throw new FormatException("Service ID field name missing."); } if (!dic.ContainsKey("date")) { throw new FormatException("Date field name missing."); } if (!dic.ContainsKey("exception_type")) { throw new FormatException("Exception type field name missing."); } while (!calendarDates.EndOfStream) { IList <string> tokens = GtfsDataFeed.SplitGtfs(calendarDates.ReadLine()); Calendar.Service service = null; try { service = calendar[tokens[dic["service_id"]]]; } catch { DataFeed.LogError($"Preprocessor tried to parse an exception, but the service with ID { tokens[dic["service_id"]] } does not exist. Skipping this item to recover the parsing process."); continue; } bool type = tokens[dic["exception_type"]] == "1" ? true : false; service.ExtraordinaryEvents.Add(new Tuple <string, bool>(tokens[dic["date"]], type)); ExtraordinaryEvent ev = new ExtraordinaryEvent(service, tokens[dic["date"]], type); list.Add(ev); } calendarDates.Dispose(); }
/// <summary> /// Initializes object. /// </summary> /// <param name="service">Service.</param> /// <param name="date">Date.</param> /// <param name="type">Type Of Event.</param> public ExtraordinaryEvent(Calendar.Service service, string date, bool type) { Service = service; Date = date; Type = type; }