GeoMeasure (GeoMeasure v1.2.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.PointZ{coordinates: {1, 2, 5}})
%Geo.PointZ{coordinates: {1, 2, 5}}

iex> GeoMeasure.bbox(%Geo.PointZM{coordinates: {1, 2, 5, 8}})
%Geo.PointZ{coordinates: {1, 2, 5}}

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.PointZ{coordinates: {1, 2, 5}})
%Geo.PointZ{coordinates: {1, 2, 5}}

iex> GeoMeasure.centroid(%Geo.PointZM{coordinates: 1, 2, 5, 8})
%Geo.PointZ{coordinates: {1, 2, 5}}

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({0, 0, 0}, {1, 1, 1})
1.7320508075688772

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

iex> GeoMeasure.distance(%Geo.PointZ{coordinates: {0, 0, 0}}, Geo.PointZ{coordinates: {1, 1, 1}})
1.7320508075688772

iex> GeoMeasure.distance(%Geo.PointZM{coordinates: {0, 0, 0, 8}}, Geo.PointZM{coordinates: {1, 1, 1, 6}})
1.7320508075688772

iex> GeoMeasure.distance(%Geo.PointZM{coordinates: {0, 0, 0, 8}}, %Geo.PointZ{coordinates: {1, 1, 1}})
1.7320508075688772

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.

Calculates the centroid of a Geo struct.

Calculates the distance between two coordinate pairs or points.

Calculates the extent coordinates of a Geo struct.

Calculates the perimeter of a Geo struct.

Types

geo_point()

@type geo_point() :: Geo.Point.t() | Geo.PointM.t() | Geo.PointZ.t() | Geo.PointZM.t()

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.

centroid(geometry)

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

Calculates the centroid of a Geo struct.

distance(coordinates_1, coordinates_2)

(since 0.0.1)
@spec distance({number(), number()}, {number(), number()}) :: float()
@spec distance(geo_point(), geo_point()) :: float()

Calculates the distance between two coordinate pairs or points.

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.