public async Task <List <RoadAndAirTempData> > GetDataLocation(LocationRadiusDTO locationInfo) { List <RoadAndAirTempData> retList = new List <RoadAndAirTempData>(); var data = _unitOfWork.CassandraSession.Execute(_cassandraService.SelectAllQuery(_unitOfWork.TemperatureTable)); RoadAndAirTempData newest = null; foreach (var instance in data) { RoadAndAirTempData roadData = _cassandraService.ConvertCassandraTempRow(instance); if (_geolocationService.CalculateDistance(locationInfo.CenterLatitude, locationInfo.CenterLongitude, roadData.Latitude, roadData.Longitude) <= locationInfo.RadiusMeters) { if (!locationInfo.Newest) { retList.Add(roadData); } else if (newest == null || newest.Timestamp < roadData.Timestamp) { newest = roadData; } } } if (locationInfo.Newest) { retList.Add(newest); } return(retList); }
public async Task <List <RoadAndAirTempData> > GetFilteredLocation(double latitude, double longitude, double radius, bool newest) { LocationRadiusDTO locationInfo = new LocationRadiusDTO(); locationInfo.CenterLatitude = latitude; locationInfo.CenterLongitude = longitude; locationInfo.RadiusMeters = radius; locationInfo.Newest = newest; HttpResponseMessage response = await _unitOfWork.HttpClient.PostAsync(_unitOfWork.DataLocation + _APILocation + _locationEndpoint, new StringContent(JsonSerializer.Serialize(locationInfo), Encoding.UTF8, "application/json")); return(await JsonSerializer.DeserializeAsync <List <RoadAndAirTempData> >(await response.Content.ReadAsStreamAsync())); }
public async Task <ActionResult> GetDataLocation([FromBody] LocationRadiusDTO locationRadius) { List <RoadAndAirTempData> retVal = await _tempService.GetDataLocation(locationRadius); return(Ok(retVal)); }