public IHttpActionResult GetNearbyStops(float latitude, float longitude) { var response = new List <StopCollectionDto>(); var stopApi = new StopsApi(new PTVApi.Client.Configuration(new ApiClient("http://timetableapi.ptv.vic.gov.au", _devId, _apiKey))); var trainStopsResponse = stopApi.StopsStopsByGeolocation(latitude, longitude, maxDistance: 10000, maxResults: 5, routeTypes: new List <int?> { 0 }).Stops; var trainStopsCollectionDto = new StopCollectionDto() { RouteType = 0, Stops = Mapper.Map <List <V3StopGeosearch>, List <StopDto> >(trainStopsResponse) }; response.Add(trainStopsCollectionDto); var tramStopsResponse = stopApi.StopsStopsByGeolocation(latitude, longitude, maxDistance: 10000, maxResults: 5, routeTypes: new List <int?> { 1 }).Stops; var tramsStopsCollectionDto = new StopCollectionDto() { RouteType = 1, Stops = Mapper.Map <List <V3StopGeosearch>, List <StopDto> >(tramStopsResponse) }; response.Add(tramsStopsCollectionDto); var busStopsResponse = stopApi.StopsStopsByGeolocation(latitude, longitude, maxDistance: 10000, maxResults: 5, routeTypes: new List <int?> { 2 }).Stops; var busStopsCollectionDto = new StopCollectionDto() { RouteType = 2, Stops = Mapper.Map <List <V3StopGeosearch>, List <StopDto> >(busStopsResponse) }; response.Add(busStopsCollectionDto); return(Ok(response)); }
public IHttpActionResult GetPattern(int runId, int routeType) { var patternsApi = new PatternsApi(new PTVApi.Client.Configuration(new ApiClient("http://timetableapi.ptv.vic.gov.au", _devId, _apiKey))); var patternResponse = patternsApi.PatternsGetPatternByRun(runId, routeType); var patternDepartureDtos = new List <PatternDepartureDto>(); var stopsApi = new StopsApi(new PTVApi.Client.Configuration(new ApiClient("http://timetableapi.ptv.vic.gov.au", _devId, _apiKey))); foreach (V3Departure departure in patternResponse.Departures) { var stopResponse = stopsApi.StopsStopDetails(departure.StopId, routeType); var patternStopDto = Mapper.Map <V3StopDetails, PatternStopDto>(stopResponse.Stop); var patternDepartureDto = new PatternDepartureDto() { Stop = patternStopDto, ScheduledDepartureUtc = departure.ScheduledDepartureUtc }; patternDepartureDtos.Add(patternDepartureDto); } return(Ok(patternDepartureDtos)); }