Esempio n. 1
0
        /// <summary>
        /// Returns the great circle distance between two coordinates on a sphere. From
        /// http://en.wikipedia.org/wiki/Great-circle_distance
        /// and
        /// http://stackoverflow.com/questions/6544286/calculate-distance-of-two-geo-points-in-km-c-sharp
        /// </summary>
        private double DistanceFromBoundsInKM(double latitude, double longitude, RegionBounds bounds)
        {
            double sLat1 = Math.Sin(DegreesToRadians(latitude));
            double sLat2 = Math.Sin(DegreesToRadians(bounds.Latitude));
            double cLat1 = Math.Cos(DegreesToRadians(latitude));
            double cLat2 = Math.Cos(DegreesToRadians(bounds.Latitude));
            double cLon  = Math.Cos(DegreesToRadians(longitude) - DegreesToRadians(bounds.Longitude));

            return(EarthsRadiusInKM * Math.Acos(sLat1 * sLat2 + cLat1 * cLat2 * cLon));
        }
Esempio n. 2
0
        /// <summary>
        /// Returns the great circle distance between two coordinates on a sphere. From
        /// http://en.wikipedia.org/wiki/Great-circle_distance
        /// and
        /// http://stackoverflow.com/questions/6544286/calculate-distance-of-two-geo-points-in-km-c-sharp
        /// </summary>
        private double DistanceFromBoundsInKM(double latitude, double longitude, RegionBounds bounds)
        {
            double sLat1 = Math.Sin(DegreesToRadians(latitude));
            double sLat2 = Math.Sin(DegreesToRadians(bounds.Latitude));
            double cLat1 = Math.Cos(DegreesToRadians(latitude));
            double cLat2 = Math.Cos(DegreesToRadians(bounds.Latitude));
            double cLon = Math.Cos(DegreesToRadians(longitude) - DegreesToRadians(bounds.Longitude));

            return EarthsRadiusInKM * Math.Acos(sLat1 * sLat2 + cLat1 * cLat2 * cLon);
        }