View Source Distance.Vincenty (Distance v1.1.3)

Calculate distance per Vincenty's inverse formula (shortest travel distance on the surface of an oblate spheroid Earth) given two longitude-latitude pairs.

This method is iterative and more costly than other methods, such as the great circle method, but also potentially more accurate. It is important to note that nearly antipodal points can cause convergence issues with this method.

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.

Summary

Functions

Returns the distance in meters along a linestring defined by the List of {longitude, latitude} pairs, per Vincenty's inverse formula.

Returns the distance in meters between two points in the form of {longitude, latitude}, per Vincenty's inverse formula.

Types

coords()

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

Functions

distance(list)

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

Returns the distance in meters along a linestring defined by the List of {longitude, latitude} pairs, per Vincenty's inverse formula.

Examples

iex> Distance.Vincenty.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}])
44737835.51457705

distance(coord, coord)

@spec distance(coords(), coords()) :: float()

Returns the distance in meters between two points in the form of {longitude, latitude}, per Vincenty's inverse formula.

Examples

iex> Distance.Vincenty.distance({-105.343, 39.984}, {-105.534, 39.123})
96992.65430928342
iex> Distance.Vincenty.distance({-74.00597, 40.71429}, {-70.56656, -33.42629})
8216472.876442492