Distance.GreatCircle (distance v1.1.1)

Calculate great circle distances (shortest travel distance on the surface of a spherical Earth) given a two longitude-latitude pairs. This is an implementation of the Haversine formula and approximates using a spherical (non-ellipsoid) Earth with a mean radius of 6,371,008.8 meters derived from the WGS84 datum.

The function accepts two tuples in the form of {longitude, latitude} and returns the distance in meters. It will also accept a List of tuples.

Link to this section Summary

Functions

Returns the great circle distance in meters along a linestring defined by the List of {longitude, latitude} pairs.

Returns the great circle distance in meters between two points in the form of {longitude, latitude}.

Link to this section Types

Specs

coords() :: {number(), number()}

Link to this section Functions

Specs

distance([coords()]) :: float()

Returns the great circle distance in meters along a linestring defined by the List of {longitude, latitude} pairs.

Examples

iex> Distance.GreatCircle.distance([
...>  {-96.796667, 32.775833},
...>  {126.967583, 37.566776},
...>  {151.215158, -33.857406},
...>  {55.274180, 25.197229},
...>  {6.942661, 50.334057},
...>  {-97.635926, 30.134442}])
44728827.84910666
Link to this function

distance(arg1, arg2)

Specs

distance(coords(), coords()) :: float()

Returns the great circle distance in meters between two points in the form of {longitude, latitude}.

Examples

iex> Distance.GreatCircle.distance({-105.343, 39.984}, {-105.534, 39.123})
97129.22118968463
iex> Distance.GreatCircle.distance({-74.00597, 40.71427}, {-70.56656, -33.42628})
8251609.780265334