public static void Process()
        {
            ITransportInterface data = new MetroSource();

            XElement networkXML = XElement.Load(data.DefaultNetworkLocation.FullName);
            Network network = new Network(networkXML, data.TimetableName);

            foreach (Location l in network.Locations)
            {
                String lat = l.Latitude;
                l.Latitude = l.Longtitude;
                l.Longtitude = lat;
            }

            XElement new_XML = network.ToXML();
            new_XML.Save(@"D:/metro_network.xml");
        }
Ejemplo n.º 2
0
        private void network_template_button_Click(object sender, EventArgs e)
        {
            Console.WriteLine("###################################");
            Console.WriteLine("Generating network template xml");

            // download timetable
            Console.WriteLine("Downloading timetable pages: {0} pages", data.TimetableUrls.Count);
            ITimetableSource source = new TimetableSource();
            Timetable timetable = source.BuildTimetable(data);
            Console.WriteLine("Timetable loaded");

            // extract unique station locations
            string[] stops = timetable.AllStops;

            Network network = new Network(data.Transport_Type.ToString());
            foreach (String s in stops)
            {
                network.AddLocation(new Location(s, new string[] { s }, "0", "0", data.Transport_Type));
            }
            Console.WriteLine("{0} unique stops", stops.Length);

            // generate XML
            XElement xml = network.ToXML();
            Console.WriteLine("XML Generated");

            // save
            SaveFileDialog saveFileDialog1 = new SaveFileDialog();
            saveFileDialog1.FileName = data.DefaultNetworkLocation.Name;
            saveFileDialog1.Filter = "XML file (*.xml)|*.xml|All Files (*.*)|*.*";
            saveFileDialog1.FilterIndex = 1;

            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                if (File.Exists(saveFileDialog1.FileName))
                {
                    File.Delete(saveFileDialog1.FileName);
                }
                xml.Save(saveFileDialog1.FileName);
                Console.WriteLine("Saved");
            }
            else
            {
                Console.WriteLine("Canceled");
            }
        }