public async Task <IEnumerable <IncidentCluster> > FindAllClusters() { var incidentsToCluster = _objectMapper.Map <List <IncidentDto> >(await _incidentRepository.GetAllListAsync()); var clusteredIncidents = new List <IncidentDto>(); var incidentClusters = new List <IncidentCluster>(); foreach (var incident in incidentsToCluster) { if (clusteredIncidents.Any(dto => dto.Id == incident.Id)) { continue; } var nearbyIncidents = (await _incidentAppService.GetIncidentsAroundLocation(incident.Latitude, incident.Longitude, 5000)).ToList(); incidentClusters.Add(CreateCluster(nearbyIncidents)); clusteredIncidents.AddRange(nearbyIncidents); } return(incidentClusters); }
public async Task <IActionResult> NearbyIncidents(double latitude, double longitude, uint radius) => Ok(await _incidentAppService.GetIncidentsAroundLocation(latitude, longitude, radius));