GeoMeasure (GeoMeasure v1.1.0)

View Source

Calculates properties of Geo structs.

area

Calculates the area of Geo struct.

Examples:

iex> GeoMeasure.area(%Geo.Polygon{coordinates: [[{0, 0}, {0, 2}, {2, 2}, {2, 0}, {0, 0}]]})
4.0

bbox

Calculates the bounding box of a Geo struct.

Examples:

iex> GeoMeasure.bbox(%Geo.Point{coordinates: {1, 2}})
%Geo.Point{coordinates: {1, 2}}

iex> GeoMeasure.bbox(%Geo.PointM{coordinates: {1, 2, 5}})
%Geo.Point{coordinates: {1, 2}}

iex> GeoMeasure.bbox(%Geo.LineString{coordinates: [{1, 2}, {3, 4}]})
%Geo.Polygon{coordinates: [[{1, 2}, {1, 4}, {3, 4}, {3, 2}, {1, 2}]]}

iex> GeoMeasure.bbox(%Geo.Polygon{coordinates: [[{0, 0}, {0, 2}, {2, 2}, {2, 0}, {0, 0}]]})
%Geo.Polygon{coordinates: [[{0, 0}, {0, 2}, {2, 2}, {2, 0}, {0, 0}]]}

centroid

Calculates the centroid of a Geo struct.

Examples:

iex> GeoMeasure.centroid(%Geo.Point{coordinates: {1, 2}})
%Geo.Point{coordinates: {1, 2}}

iex> GeoMeasure.centroid(%Geo.PointM{coordinates: {1, 2, 5}})
%Geo.Point{coordinates: {1, 2}}

iex> GeoMeasure.centroid(%Geo.LineString{coordinates: [{1, 2}, {3, 4}]})
%Geo.Point{coordinates: {2.0, 3.0}}

iex> GeoMeasure.centroid(%Geo.Polygon{coordinates: [[{0, 0}, {0, 2}, {2, 2}, {2, 0}, {0, 0}]]})
%Geo.Point{coordinates: {1.0, 1.0}}

distance

Calculates distance between two coordinate pairs or Geo.Point structs.

Examples:

iex> GeoMeasure.distance({0, 0}, {5, 0})
5.0

iex> GeoMeasure.distance({0, 0}, {3, 4})
5.0

iex> GeoMeasure.distance(%Geo.Point{coordinates: {0, 0}}, %Geo.Point{coordinates: {3, 4}})
5.0

iex> GeoMeasure.distance(%Geo.PointM{coordinates: {0, 0, 5}}, %Geo.PointM{coordinates: {3, 4, 10}})
5.0

iex> GeoMeasure.distance(%Geo.PointM{coordinates: {0, 0, 5}}, %Geo.Point{coordinates: {3, 4}})
5.0

extent

Calculates the extent of a Geo struct.

Examples:

iex> GeoMeasure.extent(%Geo.LineString{coordinates: [{1, 2}, {3, 4}]})
{1, 3, 2, 4}

iex> GeoMeasure.extent(%Geo.Polygon{coordinates: [[{0, 0}, {0, 2}, {2, 2}, {2, 0}, {0, 0}]]})
{0, 2, 0, 2}

perimeter

Calculates the perimeter of a Geo struct.

Examples:

iex> GeoMeasure.perimeter(%Geo.Polygon{coordinates: [[{0, 0}, {0, 2}, {2, 2}, {2, 0}, {0, 0}]]})
8.0

Summary

Functions

Calculates the area of a Geo struct.

Calculates the bounding box of a Geo struct as a Geo.Polygon.

Calculates the centroid of a Geo struct as a Geo.Point.

Calculates the distance between two coordinate pairs or Geo.Point structs.

Calculates the extent coordinates of a Geo struct.

Calculates the perimeter of a Geo struct.

Functions

area(geometry)

(since 0.0.1)
@spec area(Geo.geometry()) :: number()

Calculates the area of a Geo struct.

bbox(geometry)

(since 0.0.1)
@spec bbox(Geo.geometry()) :: Geo.geometry()

Calculates the bounding box of a Geo struct as a Geo.Polygon.

centroid(geometry)

(since 0.0.1)
@spec centroid(Geo.geometry()) :: Geo.Point.t()

Calculates the centroid of a Geo struct as a Geo.Point.

distance(coordinates_1, coordinates_2)

(since 0.0.1)
@spec distance({number(), number()}, {number(), number()}) :: float()
@spec distance(Geo.Point.t() | Geo.PointM.t(), Geo.Point.t() | Geo.PointM.t()) ::
  float()

Calculates the distance between two coordinate pairs or Geo.Point structs.

extent(geometry)

(since 0.0.1)
@spec extent(Geo.geometry()) :: {number(), number(), number(), number()}

Calculates the extent coordinates of a Geo struct.

perimeter(geometry)

(since 0.0.1)
@spec perimeter(Geo.geometry()) :: float()

Calculates the perimeter of a Geo struct.