Class CalculationHelper
Static class providing helper methods for various calculations.
public static class CalculationHelper
- Inheritance
-
CalculationHelper
- Inherited Members
Fields
EARTH_RADIUS_KILOMETERS
The earth's radius in kilometers.
public const int EARTH_RADIUS_KILOMETERS = 6371
Field Value
MILES_PER_KILOMETER
Ratio of miles per kilometer .
public const double MILES_PER_KILOMETER = 0.621371
Field Value
Methods
CalculateHash(string)
Calculates the hash of a given string using an MD5 value as the first 32 bits.
public static int CalculateHash(string str)
Parameters
strstringThe string to be hashed.
Returns
- int
The calculated hash.
Remarks
This method is used for a quick and consistent hash function. It should not be considered cryptographically sound or used in security contexts.
CalculateHexHash(string)
Calculates the hexadecimal hash.
public static string CalculateHexHash(string str)
Parameters
strstringThe string to be hashed.
Returns
- string
The calculated 16 character hexadecimal hash.
DegreesToRadians(double)
Convers degrees to radians.
public static double DegreesToRadians(double degrees)
Parameters
degreesdoubleThe degree value.
Returns
- double
The value as radians.
GetDistance(decimal, decimal, decimal, decimal, MeasurementSystem)
Gets the distance between two points on earth using the haversine formula.
public static decimal GetDistance(decimal latitudeOrigin, decimal longitudeOrigin, decimal latitudeDestination, decimal longitudeDestination, MeasurementSystem measurementSystem = MeasurementSystem.Imperial)
Parameters
latitudeOrigindecimalThe latitude origin.
longitudeOrigindecimalThe longitude origin.
latitudeDestinationdecimalThe latitude destination.
longitudeDestinationdecimalThe longitude destination.
measurementSystemMeasurementSystem(Optional) The measurement system.
Returns
- decimal
The distance.
Remarks
Uses the haversine formula to calculate the "as-the-crow-flies" distance between two points on earth.
- See Also
GetDistance(double, double, double, double, MeasurementSystem)
Gets the distance between two points on earth using the haversine formula.
public static double GetDistance(double latitudeOrigin, double longitudeOrigin, double latitudeDestination, double longitudeDestination, MeasurementSystem measurementSystem = MeasurementSystem.Imperial)
Parameters
latitudeOrigindoubleThe latitude of the origin.
longitudeOrigindoubleThe longitude of the origin.
latitudeDestinationdoubleThe latitude destination.
longitudeDestinationdoubleThe longitude destination.
measurementSystemMeasurementSystem(Optional) The measurement system.
Returns
- double
The distance.
Remarks
Uses the haversine formula to calculate the "as-the-crow-flies" distance between two points on earth.
KilometersToMiles(double)
Converts kilometers to miles.
public static double KilometersToMiles(double kilometers)
Parameters
kilometersdoubleThe value in kilometers.
Returns
- double
The value in miles.
MilesToKilometers(double)
Converts miles to kilometers.
public static double MilesToKilometers(double miles)
Parameters
milesdoubleThe value in miles.
Returns
- double
The value in kilometers.
RadiansToDegrees(double)
Converts radians to degrees.
public static double RadiansToDegrees(double radians)
Parameters
radiansdoubleThe radian value.
Returns
- double
The value as degrees.