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.
35 lines
1.5 KiB
35 lines
1.5 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 = "amritsyangtan1@gmail.com", Latitude = 47.7008, Longitude = 60.3000, AuthorityType = "Accident" },
|
|
new Authority { Name = "Police", Email = "amreitsyanf@gmail.com", Latitude = 27.7008, Longitude = 85.3000, AuthorityType = "Accident" },
|
|
new Authority { Name = "Fire Department", Email = "amAritsyangtan1@gmail.com", Latitude = 27.7110, Longitude = 85.2915, AuthorityType = "Fire" },
|
|
new Authority { Name = "Ambulance", Email = "ambulance@example.com", Latitude = 27.7052, Longitude = 85.3092, 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;
|
|
}
|
|
}
|
|
}
|
|
|