Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
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());
        }
Exemplo n.º 3
0
        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();
                }
            }
        }