View Source Landmark.Measurement (Landmark v0.5.1)

Summary

Functions

Computes the bounding box for an object.

Takes two Geo.Points and finds the geographic bearing between them, i.e. the angle measured in degrees from the north line (0 degrees)

Computes an object's center of mass using "Centroid of Polygon" formula

Computes the centroid as the mean of all vertices within the object.

Given a start point, initial bearing, and distance, will calculate the destina­tion point from travelling along a (shortest distance) great circle arc.

Calculates the distance between two coordinates. Uses the Haversine formula to account for global curvature.

Returns the destination point having travelled along a rhumb line from the origin point the given distance on the given bearing.

Functions

bbox(object)

Computes the bounding box for an object.

Examples

iex> Landmark.Measurement.bbox(%Geo.LineString{coordinates: [{1, 2}, {4, 6}]})
{1, 2, 4, 6}

iex> Landmark.Measurement.bbox(%Geo.LineString{coordinates: []})
nil

bearing(point1, point2)

Takes two Geo.Points and finds the geographic bearing between them, i.e. the angle measured in degrees from the north line (0 degrees)

center_of_mass(geometry)

Computes an object's center of mass using "Centroid of Polygon" formula

https://en.wikipedia.org/wiki/Centroid#Of_a_polygon

Examples

iex> polygon = %Geo.Polygon{coordinates: [[{2, 2}, {2, 4}, {6, 4}, {6, 2}, {2, 2}]]}
...> Landmark.Measurement.center_of_mass(polygon)
%Geo.Point{coordinates: {4.0, 3.0}}

centroid(geometry)

Computes the centroid as the mean of all vertices within the object.

Examples

iex> polygon = %Geo.Polygon{coordinates: [[{2, 2}, {2, 4}, {6, 4}, {6, 2}, {2, 2}]]}
...> Landmark.Measurement.centroid(polygon)
%Geo.Point{coordinates: {4.0, 3.0}}

iex> point = %Geo.Point{coordinates: {1, 1}}
...> Landmark.Measurement.centroid(point)
%Geo.Point{coordinates: {1, 1}}

destination(origin, distance, bearing, options \\ [unit: :kilometers])

@spec destination(Geo.Point.t(), number(), number(), keyword()) :: Geo.Point.t()

Given a start point, initial bearing, and distance, will calculate the destina­tion point from travelling along a (shortest distance) great circle arc.

Examples

iex> Landmark.Measurement.destination(%Geo.Point{coordinates: {-75, 39}}, 100, 90)
%Geo.Point{coordinates: {-73.84285308264721, 38.99428496242162}}

distance(from, to, unit \\ :kilometers)

Calculates the distance between two coordinates. Uses the Haversine formula to account for global curvature.

Default unit is kilometers.

rhumb_destination(origin, distance, bearing, options \\ [unit: :kilometers])

Returns the destination point having travelled along a rhumb line from the origin point the given distance on the given bearing.

See http://www.movable-type.co.uk/scripts/latlong.html#rhumblines