Exemplo n.º 1
0
        public override List<Stop> GetStops()
        {
            GTFS engine = new GTFS(this.TransitAgency);
            List<Stop> result = engine.GetStops();

            return result;
        }
Exemplo n.º 2
0
        public override Stop GetStop(string stopid)
        {
            GTFS engine = new GTFS(this.TransitAgency);
            Stop result = engine.GetStop(stopid);

            return result;
        }
Exemplo n.º 3
0
        public override List<Route> GetRoutes()
        {
            GTFS engine = new GTFS(this.TransitAgency);
            List<Route> result = engine.GetRoutes();

            return result;
        }
Exemplo n.º 4
0
        public override List<Stop> GetStopsByLocation(double latitude, double longitude, double radius)
        {
            GTFS engine = new GTFS(this.TransitAgency);
            List<Stop> result = engine.GetStopsByLocation(latitude, longitude, radius);

            return result;
        }
Exemplo n.º 5
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;
        }
        private IWebService SelectWebService(string agencyid)
        {
            DatabaseDataContext db = new DatabaseDataContext();
            var agency = new Agency((from a in db.GTFS_Agencies where a.ID == agencyid select a).Single());

            IWebService webService;
            switch (agency.AgencyID)
            {
                case "bart":
                    webService = new BART(agency);
                    break;
                case "citybus":
                    webService = new CityBus(agency);
                    break;
                case "cta":
                    webService = new CTA(agency);
                    break;
                case "mta":
                    webService = new MTA(agency);
                    break;
                case "seattle":
                    webService = new Seattle(agency);
                    break;
                case "wmata":
                    webService = new WMATA(agency);
                    break;
                default:
                    webService = new GTFS(agency);
                    break;
            }

            webService.TransitAgency = agency;

            return webService;
        }