Example #1
1
        public override List<Stop> GetStopsByLocation(double latitude, double longitude, double radius)
        {
            System.Net.WebClient client = new System.Net.WebClient();
            var jsonResult = client.DownloadString("http://api.wmata.com/Rail.svc/json/JStations?api_key=" + APIKey);

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

            var data = Json.Decode(jsonResult);

            if (data != null)
            {
                foreach (var r in data.Stations)
                {
                    if (Utilities.Distance(latitude, longitude, Convert.ToDouble(r.Lat), Convert.ToDouble(r.Lon)) <= radius)
                    {
                        Stop s = new Stop();
                        s.ID = r.Code;
                        s.Name = r.Name;
                        s.Code = r.Code;
                        s.Latitude = Convert.ToDouble(r.Lat);
                        s.Longitude = Convert.ToDouble(r.Lon);

                        result.Add(s);
                    }
                }
            }

            jsonResult = client.DownloadString("http://api.wmata.com/Bus.svc/json/JStops?api_key=" + APIKey + "&lat=" + latitude + "&lon=" + longitude + "&radius=" + radius);

            data = Json.Decode(jsonResult);

            if (data != null)
            {
                foreach (var r in data.Stops)
                {
                    Stop s = new Stop();
                    s.ID = r.StopID;
                    s.Name = r.Name;
                    s.Code = r.StopID;
                    s.Latitude = Convert.ToDouble(r.Lat);
                    s.Longitude = Convert.ToDouble(r.Lon);

                    result.Add(s);
                }
            }

            return result;
        }
Example #2
0
        public override Stop GetStop(string stopid)
        {
            var stop = (from s in db.GTFS_Stops where s.PartitionKey == agency.PartitionKey &&
                                                      s.ID.ToUpper() == stopid.ToUpper() select s).Single();

            Stop result = new Stop();
            result.ID = stop.ID;
            result.Name = stop.Name;
            result.Code = stop.Code;
            result.Latitude = Convert.ToDouble(stop.Latitude);
            result.Longitude = Convert.ToDouble(stop.Longitude);

            return result;
        }
Example #3
0
        public override Stop GetStop(string stopid)
        {
            System.Net.WebClient client = new System.Net.WebClient();
            var jsonResult = client.DownloadString("http://api.routeshout.com/v1/rs.stops.getInfo?key=" + APIKey + "&agency=" + this.TransitAgency.AgencyID + "&stop=" + stopid);

            var r = Json.Decode(jsonResult).response;

            Stop result = new Stop();

            result.ID = r.id;
            result.Name = r.name;
            result.Code = r.code;
            result.Latitude = r.lat;
            result.Longitude = r.lon;

            return result;
        }
Example #4
0
        public override List<Stop> GetStops()
        {
            List<Stop> result = new List<Stop>();

            var stops = from s in db.GTFS_Stops where s.PartitionKey == agency.PartitionKey select s;
            foreach (var s in stops)
            {
                Stop st = new Stop();
                st.ID = s.ID;
                st.Name = s.Name;
                st.Code = s.Code;
                st.Latitude = Convert.ToDouble(s.Latitude);
                st.Longitude = Convert.ToDouble(s.Longitude);

                result.Add(st);
            }

            return result;
        }
Example #5
0
        public override List<Stop> GetStops()
        {
            System.Net.WebClient client = new System.Net.WebClient();
            var jsonResult = client.DownloadString("http://api.routeshout.com/v1/rs.stops.getList?key=" + APIKey + "&agency=" + this.TransitAgency.AgencyID);

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

            foreach (var r in Json.Decode(jsonResult).response)
            {
                Stop s = new Stop();
                s.ID = r.id;
                s.Name = r.name;
                s.Code = r.code;
                s.Latitude = Convert.ToDouble(r.lat);
                s.Longitude = Convert.ToDouble(r.lon);

                result.Add(s);
            }

            return result;
        }
Example #6
0
        public override List<Stop> GetStopsByLocation(double latitude, double longitude, double radius)
        {
            System.Net.WebClient client = new System.Net.WebClient();
            var jsonResult = client.DownloadString("http://api.onebusaway.org/api/where/stops-for-location.json?key=" + APIKey + "&agency=" + this.TransitAgency.AgencyID + "&lat=" + latitude + "&lon=" + longitude + "&radius=" + radius);

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

            foreach (var r in Json.Decode(jsonResult).data.stops)
            {
                Stop s = new Stop();
                s.ID = r.id;
                s.Name = r.name;
                s.Code = r.code;
                s.Latitude = Convert.ToDouble(r.lat);
                s.Longitude = Convert.ToDouble(r.lon);

                result.Add(s);
            }

            return result;
        }
Example #7
0
        public override List<Stop> GetStopsByLocation(double latitude, double longitude, double radius)
        {
            List<Stop> result = new List<Stop>();

            var stops = from s in db.GTFS_Stops where s.PartitionKey == agency.PartitionKey select s;
            foreach (var s in stops)
            {
                if (Utilities.Distance(latitude, longitude, Convert.ToDouble(s.Latitude), Convert.ToDouble(s.Longitude)) <= radius)
                {
                    Stop st = new Stop();
                    st.ID = s.ID;
                    st.Name = s.Name;
                    st.Code = s.Code;
                    st.Latitude = Convert.ToDouble(s.Latitude);
                    st.Longitude = Convert.ToDouble(s.Longitude);

                    result.Add(st);
                }
            }

            return result;
        }