private List <TimeSpan> CalculateStartingTimes(TrafiApiTimeJSON trafiApiTimeJSON) { var departureTimes = new List <TimeSpan>(); var departureTime = 0; for (int i = 0; i < trafiApiTimeJSON.TimeDiffsCounts.Count; i++) { for (int j = 0; j < trafiApiTimeJSON.TimeDiffsCounts[i]; j++) { departureTime += trafiApiTimeJSON.TimeDiffsValues[i]; departureTimes.Add(new TimeSpan(0, departureTime, 0)); } } return(departureTimes); }
public Schedule Parse(TrafiApiTimeJSON timeJSON, TrafiApiDurationJSON durationJSON, List <TrafiApiTimetableStopJSON> stops) { var schedule = new Schedule(); var transportStartingTimes = CalculateStartingTimes(timeJSON); var durationTimes = CalculateArrivalTimes(durationJSON); for (int stopNumber = 0; stopNumber < stops.Count; stopNumber++) { var departingBusNumberWithTimes = new List <Tuple <int, TimeSpan> >(); for (int departingBusNumber = 0; departingBusNumber < transportStartingTimes.Count; departingBusNumber++) { departingBusNumberWithTimes.Add(Tuple.Create(departingBusNumber, transportStartingTimes[departingBusNumber] + durationTimes[departingBusNumber + transportStartingTimes.Count * stopNumber])); } schedule.InsertTime(stops[stopNumber].StopId, departingBusNumberWithTimes); } return(schedule); }