예제 #1
0
        public override Stop GetStop(string stopid)
        {
            GTFS engine = new GTFS(this.TransitAgency);
            Stop result = engine.GetStop(stopid);

            return result;
        }
예제 #2
0
        public override List<StopTime> GetStopTimes(string stopid)
        {
            System.Net.WebClient client = new System.Net.WebClient();

            GTFS engine = new GTFS(this.TransitAgency);
            Stop stop = engine.GetStop(stopid);

            DataSet ds = new DataSet();
            ds.ReadXml(client.OpenRead("http://myride.gocitybus.com/widget/Default1.aspx?pt=30&code=" + stop.Code));

            List<StopTime> result = new List<StopTime>();

            if (ds.Tables["Bus"] == null)
            {
                return result;
            }

            foreach (DataRow r in ds.Tables["Bus"].Rows)
            {
                StopTime t = new StopTime();

                t.RouteShortName = r["RouteName"].ToString().Substring(0, r["RouteName"].ToString().IndexOf(" ")).ToUpper().Trim(); if (t.RouteShortName.Length > 3) t.RouteShortName = t.RouteShortName.Substring(0, 3);
                t.RouteLongName = r["RouteName"].ToString().Replace(t.RouteShortName, "").Trim();

                var now = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, this.TransitAgency.FriendlyTimeZone);

                if (r["TimeTillArrival"].ToString() == "DUE")
                    t.ArrivalTime = now.ToString("hh:mm tt");
                else
                    t.ArrivalTime = now.AddMinutes(Convert.ToInt32(r["TimeTillArrival"].ToString().Replace("min", "").Trim())).ToString("hh:mm tt");

                t.DepartureTime = t.ArrivalTime;
                t.Type = "realtime";

                result.Add(t);
            }

            return result;
        }