You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
Seekers/Services/AuthorityService.cs

37 lines
1.7 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Justice.Models;
using Justice.Services;
using Justice.Helpers;
namespace Justice.Services
{
public class AuthorityService
{
private List<Authority> _authorities = new List<Authority>
{
new Authority { Name = "Police", Email = "", Latitude = 27.7008, Longitude = 27.7008, AuthorityType = "Accident" },
new Authority { Name = "Police", Email = "policed282@gmail.com", Latitude = 27.7008, Longitude = 85.3000, AuthorityType = "Accident" },
new Authority { Name = "Fire Department", Email = "", Latitude = 27.7008, Longitude = 27.7008, AuthorityType = "Fire" },
new Authority { Name = "Crime", Email = "amreitsyanf@gmail.com", Latitude = 27.7008, Longitude = 27.7008, AuthorityType = "Police" },
new Authority { Name = "Crime", Email = "", Latitude = 27.7008, Longitude = 27.7008, AuthorityType = "Police" },
new Authority { Name = "Ambulance", Email = "", Latitude = 27.7008, Longitude = 27.7008, AuthorityType = "Ambulance" }
};
public List<Authority> GetNearByAuthorities(double incidentLatitude, double incidentLongitude, double radiusKm = 10)
{
List<Authority> nearbyAuthorities = new List<Authority>();
foreach (var authority in _authorities)
{
double distance = GeoHelper.CalculateDistance(incidentLatitude, incidentLongitude, authority.Latitude, authority.Longitude);
if (distance <= radiusKm)
{
nearbyAuthorities.Add(authority);
}
}
return nearbyAuthorities;
}
}
}