public static void StopTimesReader() { List <StopTime> Result = new List <StopTime>(); List <string> FileLines = new List <string>(); FileLines = File.ReadAllLines("stop_times.csv").Skip(1).ToList(); string[] field; foreach (string line in FileLines) { field = line.Split(','); Result.Add(new StopTime(field[0], field[1], field[2], field[3], field[4], field[5], field[6], field[7], field[8], GTFSData.StopRoutDic[field[0]])); } GTFSData.StopTimesFile = Result; int i; string t; List <string> r = new List <string>(); string r_id; for (i = 0; i < GTFSData.StopTimesFile.Count - 1; i++) { r_id = GTFSData.StopTimesFile[i].Route_id; r.Add(GTFSData.StopTimesFile[i].stop_id); t = GTFSData.StopTimesFile[i].trip_id; if (GTFSData.StopTimesFile[i].trip_id != GTFSData.StopTimesFile[i + 1].trip_id) { route newrout = new route(r_id, r, t, -1); if (!GTFSData.AllRoutesContaine(newrout)) { GTFSData.AllRoutes.Add(new route(newrout.route_id, new List <string>(newrout.stops), t, -1)); } r.Clear(); } } }
public static bool AllRoutesContaine(route r) { bool result = false; foreach (route croute in AllRoutes) { if (croute.route_id == r.route_id && (croute.stops.SequenceEqual(r.stops) || r.stops.SequenceEqual(croute.stops) || GTFSData.ContainsSubsequence(croute.stops, r.stops))) { result = true; } } return(result); }