public Dictionary <string, List <Google_Trip> > cree_chainages(Dictionary <string, Google_Route> google_routes, Dictionary <string, Google_Trip> google_trips, Dictionary <string, Google_Calendar> google_calendars, Dictionary <string, SortedList <int, Google_Stop_Time> > google_stop_times) { Dictionary <string, List <Google_Trip> > chainages = new Dictionary <string, List <Google_Trip> >(); foreach (string service in google_stop_times.Keys) { string chaine = ""; foreach (int num_ordre in google_stop_times[service].Keys) { chaine += google_stop_times[service][num_ordre].num_arret.ToString() + ";"; } if (chainages.ContainsKey(chaine) == false) { chainages[chaine] = new List <Google_Trip>(); } Google_Trip trip = new Google_Trip(); chainages[chaine].Add(google_trips[service]); } return(chainages); }
public Dictionary <string, Google_Trip> lit_google_trips(string nom_trips) { Dictionary <string, Google_Trip> google_trips = new Dictionary <string, Google_Trip>(); System.IO.StreamReader fichier_trips = new System.IO.StreamReader(nom_trips); List <string> header = new List <string>((string[])(fichier_trips.ReadLine().Split(','))); Dictionary <string, int> headers = new Dictionary <string, int>(); int ii; for (ii = 0; ii < header.Count; ii++) { headers[header[ii].Trim('"')] = ii; } while (fichier_trips.EndOfStream == false) { List <string> h = new List <string>(); string[] delim = { "\"" }; List <string> head = new List <string>((string[])(fichier_trips.ReadLine()).Split(delim, StringSplitOptions.None)); foreach (string ch in head) { h.Add(ch.Replace(", ", "_ ")); } string chaine = string.Join(@"", h.ToArray()); string[] elements = chaine.Split(','); Google_Trip google_trip = new Google_Trip(); google_trip.route_id = elements[headers["route_id"]].Trim(); google_trip.service_id = elements[headers["service_id"]].Trim(); google_trip.trip_id = elements[headers["trip_id"]].Trim(); google_trips[google_trip.trip_id] = google_trip; } fichier_trips.Close(); return(google_trips); }