namespace LeanCloud { /// /// Represents a distance between two AVGeoPoints. /// public struct AVGeoDistance { private const double EarthMeanRadiusKilometers = 6371.0; private const double EarthMeanRadiusMiles = 3958.8; /// /// Creates a AVGeoDistance. /// /// The distance in radians. public AVGeoDistance(double radians) : this() { Radians = radians; } /// /// Gets the distance in radians. /// public double Radians { get; private set; } /// /// Gets the distance in miles. /// public double Miles { get { return Radians * EarthMeanRadiusMiles; } } /// /// Gets the distance in kilometers. /// public double Kilometers { get { return Radians * EarthMeanRadiusKilometers; } } /// /// Gets a AVGeoDistance from a number of miles. /// /// The number of miles. /// A AVGeoDistance for the given number of miles. public static AVGeoDistance FromMiles(double miles) { return new AVGeoDistance(miles / EarthMeanRadiusMiles); } /// /// Gets a AVGeoDistance from a number of kilometers. /// /// The number of kilometers. /// A AVGeoDistance for the given number of kilometers. public static AVGeoDistance FromKilometers(double kilometers) { return new AVGeoDistance(kilometers / EarthMeanRadiusKilometers); } /// /// Gets a AVGeoDistance from a number of radians. /// /// The number of radians. /// A AVGeoDistance for the given number of radians. public static AVGeoDistance FromRadians(double radians) { return new AVGeoDistance(radians); } } }