HamRadio v0.1.0 HamRadio.Grid View Source

Converts between coordinates and Maidenhead grid locators.

Link to this section Summary

Functions

Converts a grid square into a coordinate pair.

Converts a grid square into a coordinate pair.

Converts a grid square into the boundaries of its enclosing rectangle.

Converts a grid square into the boundaries of its enclosing rectangle.

Converts a coordinate pair into a grid square.

Converts a coordinate pair into a grid square.

Normalizes the string casing of a grid square.

Determines if a grid square is legit.

Link to this section Types

Link to this type

coord()

View Source
coord() :: {lat :: float(), lon :: float()}
Link to this type

coord_bounds()

View Source
coord_bounds() ::
  {{lat_min :: float(), lat_max :: float()},
   {lon_min :: float(), lon_max :: float()}}
Link to this type

grid_length()

View Source
grid_length() :: 4 | 6

Link to this section Functions

Link to this function

decode(grid)

View Source
decode(String.t()) :: {:ok, coord()} | :error

Converts a grid square into a coordinate pair.

The coordinate is located at the center of the grid square.

Returns :error if the grid is invalid.

Converts a grid square into a coordinate pair.

Raises ArgumentError if the grid is invalid.

Link to this function

decode_bounds(grid)

View Source
decode_bounds(String.t()) :: {:ok, coord_bounds()} | :error

Converts a grid square into the boundaries of its enclosing rectangle.

Returns :error if the grid is invalid.

Link to this function

decode_bounds!(grid)

View Source
decode_bounds!(String.t()) :: coord_bounds() | no_return()

Converts a grid square into the boundaries of its enclosing rectangle.

Raises ArgumentError if the grid is invalid.

Link to this function

encode(coord, length \\ 4)

View Source
encode(coord(), grid_length()) :: {:ok, String.t()} | :error

Converts a coordinate pair into a grid square.

The length can be 4 (default) or 6, returning grids like "FN32" or "FN32ab", respectively.

Link to this function

encode!(coord, length \\ 4)

View Source
encode!(coord(), grid_length()) :: String.t() | no_return()

Converts a coordinate pair into a grid square.

Raises ArgumentError if the coordinates are invalid.

Normalizes the string casing of a grid square.

iex> HamRadio.Grid.format("fn32ab")
"FN32ab"

Determines if a grid square is legit.