public static async Task <IList <Models.Travelstage> > GetDeparturesAdvanced(long placeId, String time,
                                                                                     String[] lines, params String[] transportTypes)
        {
            var joinedLines = String.Join(",", lines);
            var transport   = String.Join(",", transportTypes);

            var query = String.Format("{0}?time={1}&lines={2}&transporttypes={3}", placeId, time,
                                      joinedLines, transport);

            return(await HttpWebClient.GetDataAsync <IList <Models.Travelstage> >(Paths.Travelstage.GetDeparturesAdvanced, query));
        }
Example #2
0
        /// <summary>
        /// Gets all travel opportunities from a stop to another with specific parameters
        /// </summary>
        /// <param name="time">Time in format: ddMMyyyyHHmm</param>
        /// <param name="fromStopId">ID of stop</param>
        /// <param name="toStopId">ID of stop</param>
        /// <param name="changeMargin">Limit the times to change transportation to get there</param>
        /// <param name="changePunish"></param>
        /// <param name="walkingFactor"></param>
        /// <param name="isAfter">Specify if search is after or before given date</param>
        /// <param name="proposals">Specify a number of results to get back</param>
        /// <param name="transportTypes">Types of transportation to limit travel: Bus, Tram, Train, etc</param>
        /// <returns></returns>
        public static async Task <IList <Models.Travel> > GetTravelsAdvanced(String time, long fromStopId, long toStopId,
                                                                             int changeMargin, int changePunish, int walkingFactor, bool isAfter, int proposals, params String[] transportTypes)
        {
            var transport = String.Join(",", transportTypes);

            var query =
                String.Format("time={0}&fromstops={1}&tostops={2}&changeMargin={3}&changePunish={4}&walkingFactor={5}&" +
                              "isAfter={6}&proposals={7}&transporttypes={8}", time, fromStopId, toStopId, changeMargin, changePunish,
                              walkingFactor, isAfter, proposals, transport);

            return(await HttpWebClient.GetDataAsync <IList <Models.Travel> >(Paths.Travel.GetTravelsAdvanced, query));
        }
Example #3
0
        /// <summary>
        /// Gets all travel opportunities from one coordinate to another with specific parameters
        /// </summary>
        /// <param name="time">Time in format: ddMMyyyyHHmm</param>
        /// <param name="fromX">From X-coordinate</param>
        /// <param name="fromY">From Y-coordinate</param>
        /// <param name="toX">To X-coordinate</param>
        /// <param name="toY">To Y-coordinate</param>
        /// <param name="changeMargin">Specify how many times we can change transportation</param>
        /// <param name="changePunish"></param>
        /// <param name="walkingFactor"></param>
        /// <param name="isAfter">Specify if search is after or before given date</param>
        /// <param name="proposals">Limit results to given number</param>
        /// <param name="transportTypes">Types of transportation we want</param>
        /// <returns></returns>
        public static async Task <IList <Models.Travel> > GetTravelsAdvancedByCoordinates(String time, long fromX, long fromY,
                                                                                          long toX, long toY, int changeMargin, int changePunish, int walkingFactor, bool isAfter, int proposals,
                                                                                          params String[] transportTypes)
        {
            var transport = String.Join(",", transportTypes);

            var query =
                String.Format("time={0}&fromcoordinates=(X={1},Y={2})&tocoordinates=(X={3},Y={4})&changeMargin={5}&changePunish={6}&" +
                              "walkingFactor={7}&isAfter={8}&proposals={9}&transporttypes={10}", time, fromX, fromY, toX, toY, changeMargin, changePunish,
                              walkingFactor, isAfter, proposals, transport);

            return(await HttpWebClient.GetDataAsync <IList <Models.Travel> >(Paths.Travel.GetTravelsAdvancedByCoordinates, query));
        }
Example #4
0
        /// <summary>
        /// Gets all travel opportunities from one place to another after a specific date
        /// </summary>
        /// <param name="time">Time in format: ddMMyyyyHHmm</param>
        /// <param name="fromId">ID of place</param>
        /// <param name="toId">ID of place</param>
        /// <returns></returns>
        public static async Task <IList <Models.Travel> > GetTravelsAfter(String time, long fromId, long toId)
        {
            var query = String.Format("time={0}&from={1}&to={2}", time, fromId, toId);

            return(await HttpWebClient.GetDataAsync <IList <Models.Travel> >(Paths.Travel.GetTravelsAfter, query));
        }
Example #5
0
 /// <summary>
 /// Gets all streets starting/containing/ends in given name
 /// </summary>
 /// <param name="name">Name of a street</param>
 /// <returns></returns>
 public static async Task <IList <Models.Street> > GetStreets(String name)
 {
     return(await HttpWebClient.GetDataAsync <IList <Models.Street> >(Paths.Street.GetStreets, name));
 }
Example #6
0
        /// <summary>
        /// Returns a Place-object based on a place ID
        /// </summary>
        /// <param name="id">ID of place</param>
        /// <param name="name">Name of a place to help the search</param>
        /// <returns></returns>
        public static async Task <Models.Place> FindPlaceBasedOnPlaceId(long id, String name)
        {
            var query = String.Format("{0}?search={1}", id, name);

            return(await HttpWebClient.GetDataAsync <Models.Place>(Paths.Place.FindPlaceBasedOnPlaceId, query));
        }
Example #7
0
 /// <summary>
 /// Checks whether a name is a valid place or not
 /// </summary>
 /// <param name="name">Name of a place</param>
 /// <returns></returns>
 public static async Task <Boolean> IsValidPlace(String name)
 {
     return(await HttpWebClient.GetDataAsync <Boolean>(Paths.Realtime.IsValidPlace, name));
 }
        public static async Task <IList <Models.Travelstage> > GetArrivals(long placeId, String time)
        {
            var query = String.Format("{0}?time={1}", placeId, time);

            return(await HttpWebClient.GetDataAsync <IList <Models.Travelstage> >(Paths.Travelstage.GetArrivals, query));
        }
Example #9
0
        /// <summary>
        /// Returns a list of places based on name and type
        /// </summary>
        /// <param name="name">Name of a place</param>
        /// <param name="type">Specify a type: Map, Realtime, Stop, BetweenPlaces</param>
        /// <returns></returns>
        private static async Task <IList <Models.Place> > AutoComplete(String name, String type)
        {
            var query = String.Format("{0}?autocompleteType={1}", name, type);

            return(await HttpWebClient.GetDataAsync <IList <Models.Place> >(Paths.Place.Autocomplete, query));
        }
Example #10
0
 /// <summary>
 /// Returns a list of places based on query
 /// </summary>
 /// <param name="name">Name of a place</param>
 /// <returns></returns>
 public static async Task <IList <Models.Place> > AutoComplete(String name)
 {
     return(await HttpWebClient.GetDataAsync <IList <Models.Place> >(Paths.Place.Autocomplete, name));
 }
Example #11
0
 /// <summary>
 /// Returns all lines (train, bus, tram etc) passing a place
 /// </summary>
 /// <param name="id">ID of place</param>
 /// <returns></returns>
 public static async Task <IList <Models.Line> > GetLines(long id)
 {
     return(await HttpWebClient.GetDataAsync <IList <Models.Line> >(Paths.Place.GetLines, id));
 }
Example #12
0
        /// <summary>
        /// Returns all stops closest to given coordinates and walking distance
        /// </summary>
        /// <param name="x">Location as X-coordinate</param>
        /// <param name="y">Location as Y-coordinate</param>
        /// <param name="proposals">Number of stops to return</param>
        /// <param name="walkingDistance">Specify maximum walking distance in meters</param>
        /// <returns></returns>
        public static async Task <IList <Models.Stop> > GetClosestStopsAdvancedByCoordinates(long x, long y, int proposals, int walkingDistance)
        {
            var query = String.Format("?coordinates=(X={0}, Y={1})&proposals={2}&walkingDistance={3}", x, y, proposals, walkingDistance);

            return(await HttpWebClient.GetDataAsync <IList <Models.Stop> >(Paths.Place.GetClosestStopsAdvancedByCoordinates, query));
        }
Example #13
0
 /// <summary>
 /// Searches for places
 /// </summary>
 /// <param name="name">Name of a place</param>
 /// <returns></returns>
 public static async Task <IList <Models.Place> > FindMatches(String name)
 {
     return(await HttpWebClient.GetDataAsync <IList <Models.Place> >(Paths.Place.FindMatches, name));
 }
Example #14
0
 /// <summary>
 /// Returns all stops contained in a place
 /// </summary>
 /// <param name="id">ID of place</param>
 /// <returns></returns>
 public static async Task <IList <Models.Stop> > GetStopsByPlaceId(long id)
 {
     return(await HttpWebClient.GetDataAsync <IList <Models.Stop> >(Paths.Place.GetStopsByPlaceId, id));
 }
Example #15
0
        /// <summary>
        /// Gets all travel opportunities from a stop to another before a given date
        /// </summary>
        /// <param name="time">Time in format: ddMMyyyyHHmm</param>
        /// <param name="fromStopId">ID of stop</param>
        /// <param name="toStopId">ID of stop</param>
        /// <returns></returns>
        public static async Task <IList <Models.Travel> > GetTravelsBeforeByStops(String time, long fromStopId, long toStopId)
        {
            var query = String.Format("time={0}&fromstops={1}&tostops={2}", time, fromStopId, toStopId);

            return(await HttpWebClient.GetDataAsync <IList <Models.Travel> >(Paths.Travel.GetTravelsBeforeByStops, query));
        }
Example #16
0
        /// <summary>
        /// Searches for places but limits the search to specific counties
        /// </summary>
        /// <param name="name">Name of a place</param>
        /// <param name="counties">List of counties to include in search</param>
        /// <returns></returns>
        public static async Task <IList <Models.Place> > FindPlacesByCounties(String name, params String[] counties)
        {
            var query = String.Format("{0}?counties={1}", name, String.Join(",", counties));

            return(await HttpWebClient.GetDataAsync <IList <Models.Place> >(Paths.Place.FindPlacesByCounties, query));
        }
Example #17
0
        /// <summary>
        /// Base method for finding places with a specific type
        /// </summary>
        /// <typeparam name="T">Specify what type/class it should return</typeparam>
        /// <param name="name">Name of a place</param>
        /// <param name="type">None, Stop, Street or Area</param>
        /// <returns></returns>
        private static async Task <T> FindMatchesOfType <T>(String name, String type)
        {
            var query = String.Format("{0}?placeType={1}", name, type);

            return(await HttpWebClient.GetDataAsync <T>(Paths.Place.FindMatchesOfType, query));
        }
Example #18
0
        public static async Task <Models.Trip> GetTrip(long tripId, String time)
        {
            var query = String.Format("{0}?time={1}", tripId, time);

            return(await HttpWebClient.GetDataAsync <Models.Trip>(Paths.Trip.GetTrip, query));
        }
Example #19
0
 /// <summary>
 /// Gets realtime data from provided station id
 /// </summary>
 /// <param name="stationId">ID for a station</param>
 /// <returns></returns>
 public static async Task <IList <Models.Station> > GetRealTimeDataAsync(String stationId)
 {
     return(await HttpWebClient.GetDataAsync <IList <Models.Station> >(Paths.Realtime.GetRealTimeData, stationId));
 }