View Source Landmark.Measurement (Landmark v0.5.2)
Summary
Functions
Computes the bounding box for an object.
Takes two Geo.Point
s 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 destination 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.
Calculates the total length of a geometry feature.
Returns the destination point having travelled along a rhumb line from the origin point the given distance on the given bearing.
Functions
@spec bbox(Geo.geometry() | Enumerable.t(Landmark.lng_lat())) :: Landmark.bbox() | nil
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
Takes two Geo.Point
s 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
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}}
@spec centroid(Geo.geometry() | Enumerable.t(Landmark.lng_lat())) :: Geo.Point.t()
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}}
@spec destination(Geo.Point.t(), number(), number(), keyword()) :: Geo.Point.t()
Given a start point, initial bearing, and distance, will calculate the destination 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}}
Calculates the distance between two coordinates. Uses the Haversine formula to account for global curvature.
Default unit is kilometers.
Calculates the total length of a geometry feature.
For point geometries, returns the sum of distances between consecutive points. For other geometries, extracts coordinates and calculates the total distance.
Examples
iex> line = %Geo.LineString{coordinates: [{0, 0}, {1, 1}, {2, 0}]}
...> Landmark.Measurement.length(line, :meters)
314499.1574567902
iex> coords = [{0, 0}, {1, 1}]
...> Landmark.Measurement.length(coords, :kilometers)
157.2495787283951
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