public void cree_musliw(string nom_musliw, 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> > google_chainages, Dictionary <string, Google_Stop> google_stops) { int i = 0, n; System.IO.StreamWriter fichier_musliw = new System.IO.StreamWriter(nom_musliw); /* fichier_musliw.WriteLine("t nodes"); * foreach (Google_Stop arret in google_stops.Values) * { * fichier_musliw.WriteLine(arret.numero.ToString() + ";" + arret.x.ToString() + ";" + arret.y.ToString()); * } * fichier_musliw.WriteLine("t links");*/ foreach (string chaine in google_chainages.Keys) { i++; int j = 0; foreach (Google_Trip mission in google_chainages[chaine]) { SortedList <int, Google_Stop_Time> elements = google_stop_times[mission.trip_id]; n = elements.Count; int k; j++; String textel = ""; for (k = 0; k < n - 1; k++) { if (google_stops.ContainsKey(elements.Values[k].num_arret) == false) { Google_Stop arret = new Google_Stop(); arret.nom = elements.Values[k].num_arret; arret.x = 0; arret.y = 0; google_stops[elements.Values[k].num_arret] = arret; } if (google_stops.ContainsKey(elements.Values[k + 1].num_arret) == false) { Google_Stop arret = new Google_Stop(); arret.nom = elements.Values[k + 1].num_arret; arret.x = 0; arret.y = 0; google_stops[elements.Values[k + 1].num_arret] = arret; } textel = textBox1.Text + elements.Values[k].num_arret.ToString(); textel += ";" + textBox1.Text + elements.Values[k + 1].num_arret.ToString(); textel += ";0;0"; textel += ";" + i.ToString() + ";" + j.ToString(); textel += ";" + elements.Values[k].heure_dep + ";" + elements.Values[k + 1].heure_arr; textel += ";" + google_calendars[mission.service_id].calendrier + ";"; textel += google_routes[mission.route_id].nom + "|" + google_stops[elements.Values[k].num_arret].nom + "-" + google_stops[elements.Values[k + 1].num_arret].nom + ";0;0"; if (google_calendars[mission.service_id].calendrier.Split('O').Length > 1) { fichier_musliw.WriteLine(textel); } } } } fichier_musliw.Close(); this.Cursor = Cursors.Default; this.Close(); }
public Dictionary <string, Google_Stop> lit_google_stops(string nom_stops) { Dictionary <string, Google_Stop> google_stops = new Dictionary <string, Google_Stop>(); System.IO.StreamReader fichier_stops = new System.IO.StreamReader(nom_stops); List <string> header = new List <string>((string[])(fichier_stops.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_stops.EndOfStream == false) { string[] delim = { "\"" }; //List<string> head = new List<string>((string[])(fichier_stops.ReadLine()).Split(delim,StringSplitOptions.None)); List <string> elements = new List <string>((string[])System.Text.RegularExpressions.Regex.Split(fichier_stops.ReadLine(), ",(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)")); for (int ch = 0; ch < elements.Count; ch++) { elements[ch] = elements[ch].Replace("\"", ""); } //string[] elements = chaine.Split(','); Google_Stop google_stop = new Google_Stop(); google_stop.numero = elements[headers["stop_id"]]; google_stop.nom = elements[headers["stop_name"]]; if (System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator == ",") { google_stop.x = float.Parse(elements[headers["stop_lon"]].Replace(".", ",")); google_stop.y = float.Parse(elements[headers["stop_lat"]].Replace(".", ",")); } else { google_stop.x = float.Parse(elements[headers["stop_lon"]]); google_stop.y = float.Parse(elements[headers["stop_lat"]]); } google_stops[google_stop.numero] = google_stop; } fichier_stops.Close(); return(google_stops); }