Esempio n. 1
0
        /// <summary>
        /// Checks whether a geographic point is within geographic bounds.
        /// Considers bounds spanning around the geosphere.
        /// </summary>
        public static bool Contains(this GeoBounds bounds, GeoCoords point)
        {
            bool inLatRange = (bounds.LeftTop.Latitude > bounds.RightBottom.Latitude) ?
                              (point.Latitude <= bounds.LeftTop.Latitude && point.Latitude >= bounds.RightBottom.Latitude) :
                              (point.Latitude <= bounds.LeftTop.Latitude || point.Latitude >= bounds.RightBottom.Latitude);
            bool inLngRange = (bounds.LeftTop.Longitude < bounds.RightBottom.Longitude) ?
                              (point.Longitude >= bounds.LeftTop.Longitude && point.Longitude <= bounds.RightBottom.Longitude) :
                              (point.Longitude >= bounds.LeftTop.Longitude || point.Longitude <= bounds.RightBottom.Longitude);

            return(inLatRange && inLngRange);
        }
Esempio n. 2
0
 /// <summary>
 /// Computes distance between two geographical coordinates.
 /// </summary>
 /// <returns>Distance in kilometers.</returns>
 public static double DistanceBetween(GeoCoords a, GeoCoords b)
 {
     return(DistanceBetweenPoints(a.Latitude, a.Longitude, b.Latitude, b.Longitude));
 }