GeoDistance$

Takes five parameters, Lat1, Long1, Lat2, Long2, Options

Description:

Calculates the estimated distance between two points on earth.

If both Lat1 and Long1 are blank, or if both Lat2 and Long2 are blank, the result will be blank instead of returning an error. If one parameter of a pair is missing, a runtime error will occur when used as this Top Query function, or recorded in the Error field when called via the Geo Work Query command.

The formula used is:
Dist = ACos(Sin(Lat1) * Sin(Lat2) + Cos(Lat1) * Cos(Lat2) * Cos(Long2 - Long1)) * EarthRadius

The Options parameter is able to specify the desired units and/or a Format$ string

The following units are available:

Note: This function has been designed for speed and simplicity over precision. The formula used here does not take into account the fact that the earth is not a perfect sphere and changes in elevation are not considered.

Examples:

GeoDistance$ "49.1", "-122", "49.2", "-121"
GeoDistance$ "49.1", "-122", "49.2", "-121", "0.00"
GeoDistance$ "49.1", "-122", "49.2", "-121", "Miles"
GeoDistance$ "49.1", "-122", "49.2", "-121", "Miles 0.00"
GeoDistance$ "49.1", "-122", "49.2", "-121", "Miles #,0.00"
GeoDistance$ "49.1", "-122", "49.2", "-121", "None"