Geo.Turf.Helpers (geo_turf v0.2.0)

A collection of helper utilities. Usually users will not have to refer to this directly but it is here if the need arises.

Summary

Functions

Create a bounding box for a given Geo.geometry/0.

Flatten a t:Geo.geometry() to a simple list of coordinates

Functions

Link to this function

bbox(geometries)

@spec bbox([{Number.t(), Number.t()}] | Geo.geometry()) ::
  {Number.t(), Number.t(), Number.t(), Number.t()}

Create a bounding box for a given Geo.geometry/0.

Examples

iex> Geo.Turf.Helpers.bbox(%Geo.Polygon{coordinates: [{1,1}, {1,3}, {3,3}, {3,1}]})
{1,1,3,3}

iex> Geo.Turf.Helpers.bbox([{1,1},{2,2},{3,3}])
{1,1,3,3}
Link to this function

flatten_coords(geometry)

@spec flatten_coords(Geo.geometry()) :: [{Number.t(), Number.t()}]

Flatten a t:Geo.geometry() to a simple list of coordinates

Examples

iex> Geo.Turf.Helpers.flatten_coords(%Geo.GeometryCollection{geometries: [
...>  %Geo.Point{coordinates: {1,1}},
...>  %Geo.Point{coordinates: {2,2}}
...> ]})
[{1,1}, {2,2}]