Points
Skybrud.Essentials contains the IPoint
inteface, which describes a point on a map where the point is defined by latitude and longitude.
While you're free to create your own class implementing this interface, Skybrud.Essentials also contains the Point
class, which implements the interface. Instances of the class can be created as shown below:
// Initialize two points by latitude and longitude
IPoint a = new Point(55.708151, 9.536131);
IPoint b = new Point(55.708069, 9.536000);
Distance
While the more complex functionality is handled by the Skybrud.Essentials.Maps package, Skybrud.Essentials contains the static DistanceUtils
utility class.
The class allows you to calculate the distance between two points - eg. as:
// Initialize two points by latitude and longitude
IPoint a = new Point(55.708151, 9.536131);
IPoint b = new Point(55.708069, 9.536000);
// Calculate the distance in metres
double distance = DistanceUtils.GetDistance(a, b);
The result is measured in metres as it's a SI-unit.
Calculations are based on the equatorial radius of Earth, which is defined as 6378136.6
metres as specified by the United States Naval Observatory.
When comparing with various online services, they seem to use
// Initialize two points by latitude and longitude
IPoint a = new Point(55.708151, 9.536131);
IPoint b = new Point(55.708069, 9.536000);
// Calculate the distance in metres
double distance = DistanceUtils.GetDistance(a, b, 6378137);