3.5.1.1.16 HaversineDistance

Description

This function takes the longitudes and latitudes of two points on a sphere with radius r, returns the great-circle distances between them. Option degree determines whether to use degree or radian as the unit of longitudes and latitudes.

Syntax

double HaversineDistance(double lon1, double lat1, double lon2, double lat2, double r[, bool degree])

Input Arguments

All arguments are of numeric type double

lon1

The longitude of the first point.

lat1

The latitude of the first point.

lon2

The longitude of the second point.

lat2

The latitude of the second point.

r

The radius of the sphere on which the two points locate.

degree

Optional. Determines whether to use degree or radian as the unit of longitudes and latitudes. Default uses degree.

Return

Return the great-circle distances between the two points.

Example

double dist=HaversineDistance(120, 30, 0, -60, 5000);
ff=; //Should return 11388.7402734106.