/// <summary> /// Get a list of Event Clusters in a specific geolocation radius /// </summary> /// <param name="eventClusterGeolocationObj">EventClusterGeolocationModel</param> /// <returns>List of Event Clusters Ids</returns> public async Task <IEnumerable <Guid> > GetClustersInRadius(EventClusterGeolocationModel eventClusterGeolocationObj) { if (eventClusterGeolocationObj == null || eventClusterGeolocationObj.ResponseGeolocationPointLocation == null) { return(new List <Guid>()); } IEnumerable <EventClusterDAO> eventClusters = await _repoEventClusters.GetItemsAsync( p => p.ClosureDate.Value == null, p => new EventClusterDAO() { Id = p.Id, EventType = p.EventType, Device = new EventClusterDeviceDAOObject() { Geolocation = p.Device.Geolocation } } ); List <Guid> output = new List <Guid>(); GeolocationDAOObject daoGeocodeCenterPoint = _mapper.Map <GeolocationDAOObject>(eventClusterGeolocationObj.ResponseGeolocationPointLocation); foreach (EventClusterDAO eventClusterObj in eventClusters) { if (RadiusHelper.IsWithinRadius(eventClusterObj.Device.Geolocation, daoGeocodeCenterPoint, eventClusterGeolocationObj.Radius)) { output.Add(new Guid(eventClusterObj.Id)); } } return(output); }
public async Task <IEnumerable <Guid> > GetClustersInRadius(EventClusterGeolocationModel eventClusterGeocodeCenterUpdate) { RestRequest request = await PrepareQuery("EventClusters/Radius", Method.POST); request.AddParameter("application/json", JsonConvert.SerializeObject(eventClusterGeocodeCenterUpdate), ParameterType.RequestBody); var queryResult = await _client.ExecuteTaskAsync <IEnumerable <Guid> >(request); if (queryResult.IsSuccessful) { return(queryResult.Data); } else { _logger.LogError($"GetEventClusters: Error while adding an event: {queryResult.StatusCode}"); } return(null); }
public async Task <IActionResult> GetClustersInRadius([FromBody] EventClusterGeolocationModel eventClusterGeolocationObj) { IEnumerable <Guid> eventClusterIds = await _eventDataManager.GetClustersInRadius(eventClusterGeolocationObj); return(Ok(eventClusterIds)); }