public Locality GetLocality(GeoCoordinates coordinates) { Locality locality; _localitiesByCoordinates.TryGetValue(coordinates, out locality); return(locality); }
public CountrySubdivision GetCountrySubdivision(GeoCoordinates coordinates) { CountrySubdivision subdivision; _subdivisionsByCoordinates.TryGetValue(coordinates, out subdivision); return(subdivision); }
public static double Distance(GeoCoordinates c1, GeoCoordinates c2) { const double avgEarthRadius = 6372.795; // Convert to radians. var lat1 = c1.Latitude * Math.PI / 180; var lat2 = c2.Latitude * Math.PI / 180; var dLng = (c2.Longitude - c1.Longitude) * Math.PI / 180; var sinLat = Math.Sin((lat1 - lat2) / 2); var sinLng = Math.Sin(dLng / 2); var cosLat1 = Math.Cos(lat1); var cosLat2 = Math.Cos(lat2); // Use the haversine formula (see http://en.wikipedia.org/wiki/Great-circle_distance). return(avgEarthRadius * 2 * Math.Asin(Math.Sqrt(sinLat * sinLat + cosLat1 * cosLat2 * sinLng * sinLng))); }
public double Distance(GeoCoordinates c) { return(Distance(this, c)); }
public static CountrySubdivision GetCountrySubdivision(GeoCoordinates coordinates) { return(GetFinder().GetCountrySubdivision(coordinates)); }
public static Locality GetClosestLocality(this Country country, GeoCoordinates coordinates) { return(GetCountryFinder(country.Id).GetClosestLocality(coordinates)); }
public static Locality GetLocality(GeoCoordinates coordinates) { return(GetFinder().GetLocality(coordinates)); }