예제 #1
0
        public static void FillStopsList()
        {
            foreach (Stop s in GTFSData.StopsFile)
            {
                Stopdata NewStop = new Stopdata();
                NewStop.Stop_id             = s.Stop_id;
                NewStop.Stop_name           = s.Stop_name;
                NewStop.Stop_shortname      = s.Stop_shortname;
                NewStop.Stop_desc           = s.Stop_desc;
                NewStop.Stop_comment        = s.Stop_comment;
                NewStop.Stop_street         = s.Stop_street;
                NewStop.Stop_lat            = s.Stop_lat;
                NewStop.Stop_lon            = s.Stop_lon;
                NewStop.Location_type       = s.Location_type;
                NewStop.Parent_station      = s.Parent_station;
                NewStop.Wheelchair_boarding = s.Wheelchair_boarding;
                NewStop.routes = new List <route>();

                GTFSData.Stops.Add(NewStop);
            }
            int i = 0;

            for (i = 0; i < GTFSData.Stops.Count; i++)
            {
                GTFSData.StopsIndex.Add(GTFSData.Stops[i].Stop_id, i);
            }
        }
예제 #2
0
 public static void CheckStop(path passedway, string cs_id, int trans_number)// current stop id is passed here
 {
     if (trans_number <= GTFSData.Trans_Number_limit && cs_id != passedway.destination_id)
     {
         Stopdata cs          = GTFSData.Stops[GTFSData.StopsIndex[cs_id]];// cs stand for current stop (the stop to be checked by the function
         Stopdata destination = GTFSData.Stops[GTFSData.StopsIndex[passedway.destination_id]];
         foreach (route r in cs.routes)
         {
             if (r.stops.IndexOf(cs_id) < r.visited_index || r.visited_index == -1)
             {
                 if (r.stops.Contains(destination.Stop_id) && r.stops.IndexOf(cs_id) < r.stops.IndexOf(destination.Stop_id))
                 {
                     two_stops_solutions_list.Add(MakeMove((path)passedway.Clone(), cs, destination, r));
                 }
                 int i;
                 for (i = r.stops.IndexOf(cs_id) + 1; i < r.stops.Count && r.stops.IndexOf(cs_id) != r.stops.Count - 1; i++)
                 {
                     Stopdata nextstop     = GTFSData.Stops[GTFSData.StopsIndex[r.stops[i]]];
                     path     newpassedway = MakeMove((path)passedway.Clone(), cs, nextstop, r);
                     Qeueu    newq         = new Qeueu((path)newpassedway.Clone(), nextstop.Stop_id, trans_number + 1);
                     CallQeueu.Add(newq);//هنا اسوي الكول من ستاك
                 }
             }
         }
         update_vistiedindex(cs_id);
     }
 }
예제 #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            Stop.ReadStopsFile();
            Trip.ReadTripFile();
            StopTime.StopTimesReader();
            RouteFile.ReadRouteFile();
            // The next funcation contain multipul function call
            // and convert it to Stops data object in te GTFSData.Stops  List
            // and calculate the Distance and add it to the AllRoutes list
            // and found the routes list which belong to each list
            // so its must called after read all other files
            List <path> RL = new List <path>();

            System.Diagnostics.Stopwatch t1 = new System.Diagnostics.Stopwatch();
            System.Diagnostics.Stopwatch t2 = new System.Diagnostics.Stopwatch();
            RL = RL;
            Stop.FindWalkableAndTranstionRoutes();
            ServiceData.FillServiceDataList();
            GTFSData.RoutsFile      = GTFSData.RoutsFile;
            GTFSData.RouteFileIndex = GTFSData.RouteFileIndex;
            GTFSData.StopsFile      = GTFSData.StopsFile;
            GTFSData.TripsFile      = GTFSData.TripsFile;
            GTFSData.StopTimesFile  = GTFSData.StopTimesFile;
            GTFSData.AllRoutes      = GTFSData.AllRoutes;
            int i;
            int j;

            i = GTFSData.StopsIndex["2400205"];
            j = GTFSData.StopsIndex["2300507"];
            GTFSData.Stops = GTFSData.Stops;
            Stop.Removedublicatewalk();
            Stopdata s1 = GTFSData.Stops[i];
            Stopdata s2 = GTFSData.Stops[j];
            double   d  = Stop.GetDistanceBetweenPoints(Convert.ToDouble(s1.Stop_lat), Convert.ToDouble(s1.Stop_lon), Convert.ToDouble(s2.Stop_lat), Convert.ToDouble(s2.Stop_lon));

            t1.Start();
            Algorithm.Findpaths("1502307", "7100607");
            t1.Stop();
            textBox1.Text = t1.Elapsed.ToString();
            //RedisActions.InsertTORedis(Algorithm.two_stops_solutions_list);
            //RedisActions.InsertAllSolToRedis();
            List <PathWithTime> Pl  = new List <PathWithTime>();
            List <PathWithTime> Pl2 = new List <PathWithTime>();
            DateTime            t   = new DateTime(2020, 01, 01, 13, 00, 00);

            GTFSData.search_d    = 29;
            GTFSData.search_m    = 05;
            GTFSData.search_year = 2019;
            t2.Start();
            RL = RedisActions.GetSolFromRedis("1502307", "7100607");
            t2.Stop();
            textBox2.Text = t2.Elapsed.ToString();
            Pl            = timecalculator.GetPathTime(Algorithm.two_stops_solutions_list, t);
            Pl2           = timecalculator.GetPathTime(RL, t);
            Algorithm.two_stops_solutions_list = Algorithm.two_stops_solutions_list;
        }
예제 #4
0
        public static path MakeMove(path p, Stopdata cs, Stopdata des, route r)
        {
            if (r.route_id == "walk")
            {
                p.way.Add(new move(cs.Stop_id, cs.Stop_name, des.Stop_id, des.Stop_name, r.route_id, "walk", "walk"));
                goto a;
            }
            move newmove = new move(cs.Stop_id, cs.Stop_name, des.Stop_id, des.Stop_name, r.route_id, GTFSData.RoutsFile[GTFSData.RouteFileIndex[r.route_id]].route_short_name, GTFSData.trip_service[r.tripid]);

            p.way.Add(newmove);
a:
            return((path)p.Clone());
        }
예제 #5
0
        public static void update_vistiedindex(string stopid)
        {
            Stopdata s = GTFSData.Stops[GTFSData.StopsIndex[stopid]];

            foreach (route r in s.routes)
            {
                int newindex = r.stops.IndexOf(stopid);
                int i;
                for (i = newindex; i < r.stops.Count; i++)
                {
                    string sid = r.stops[i];
                    updateroute(sid, stopid);
                }
            }
        }
예제 #6
0
        public static void updateroute(string stopid, string istop_id)
        {
            Stopdata s = GTFSData.Stops[GTFSData.StopsIndex[stopid]];

            foreach (route r in s.routes)
            {
                if (r.stops.Contains(istop_id))
                {
                    int newindex = r.stops.IndexOf(istop_id);
                    if ((r.visited_index > newindex || r.visited_index == -1) && r.route_id != "walk")
                    {
                        r.visited_index = newindex;
                    }
                }
            }
        }