proj v0.2.2 Proj.Geodesic

Provides functions to solve problems involving geodesic lines.

Common problems this can solve:

  • Finding the distance between two locations

  • Finding the bearings between two locations

  • Finding the resulting location after moving x metres forwards facing a certain bearing from a given location

  • Plotting a set of points in a line between two locations

Summary

Functions

Calculates the resultant coordinates and bearing after travelling a given distance forwards along a geodesic line through a given starting point and azimuth (bearing)

Calculates the distance in metres between two points

Creates a new Proj.Geodesic specification for the planet’s ellipsoid parameters, where a represents the equatorial radius in metres, and f represents the flattening

Calculates the length of the geodesic line between two points and the bearing of the line at each point

Gets the equatorial radius in metres and flattening of a given Proj.Geodesic ellipsoid specification

Calculates the resulting position after travelling distance metres forwards from coords facing a bearing of azimuth

Returns a Proj.Geodesic specification for the Earth’s ellipsoid parameters as specified by WGS84

Functions

direct(geod, coords, azimuth, distance)

Calculates the resultant coordinates and bearing after travelling a given distance forwards along a geodesic line through a given starting point and azimuth (bearing).

Return value is in the format {{lat, lng}, bearing}.

All coordinates and bearings are given in degrees. distance is in metres.

iex> wgs84 = Proj.Geodesic.wgs84
iex> Proj.Geodesic.direct(wgs84, {51.501476, -0.140634}, 60, 100)
{{51.50192539979596, -0.1393868003258145}, 60.00097609168357}
distance(coords_a, coords_b)

Calculates the distance in metres between two points.

This is a convenience wrapper around Proj.Geodesic.inverse/3 which uses the WGS84 ellipsoid and only returns the resulting distance.

All coordinates are given in degrees.

iex> Proj.Geodesic.distance({51.501476, -0.140634}, {48.8584, 2.2945})
341549.6819692767
init(a, f)

Creates a new Proj.Geodesic specification for the planet’s ellipsoid parameters, where a represents the equatorial radius in metres, and f represents the flattening.

iex> Proj.Geodesic.init(6378137, 1 / 298.257223563)
#Proj.Geodesic<6378137.0, 0.0033528106647474805>
inverse(geod, coords_a, coords_b)

Calculates the length of the geodesic line between two points and the bearing of the line at each point.

Return value is in the format {distance, bearing_a, bearing_b}.

All coordinates and bearings are given in degrees. distance is in metres.

iex> wgs84 = Proj.Geodesic.wgs84
iex> Proj.Geodesic.inverse(wgs84, {51.501476, -0.140634}, {48.8584, 2.2945})
{341549.6819692767, 148.44884919324866, 150.31979086555856}
load()
params(geod)

Gets the equatorial radius in metres and flattening of a given Proj.Geodesic ellipsoid specification.

Return value is in the format {equatorial_radius, flattening}

iex> wgs84 = Proj.Geodesic.wgs84
iex> Proj.Geodesic.params(wgs84)
{6378137.0, 0.0033528106647474805}
travel(coords, azimuth, distance)

Calculates the resulting position after travelling distance metres forwards from coords facing a bearing of azimuth.

This is a convenience wrapper around Proj.Geodesic.direct/4 which uses the WGS84 ellipsoid and only returns the resulting coordinates.

Return value is in the format {lat, lng}.

All coordinates and bearings are given in degrees.

iex> Proj.Geodesic.travel({51.501476, -0.140634}, 60, 100)
{51.50192539979596, -0.1393868003258145}
wgs84()

Returns a Proj.Geodesic specification for the Earth’s ellipsoid parameters as specified by WGS84.