PlusCodes v1.0.0 PlusCodes.OpenLocationCode View Source
Implements the Google Open Location Code(Plus+Codes) algorithm.
Link to this section Summary
Functions
Decodes an Open Location Code(Plus+Codes) into a PlusCodes.CodeArea struct. Returns an :ok/:error tuple
Decodes an Open Location Code(Plus+Codes) into a PlusCodes.CodeArea struct. Raises an exception on argument error
Converts a latitude and longitude into a Open Location Code(Plus+Codes). Returns an :ok/:error tuple
Converts a latitude and longitude into a Open Location Code(Plus+Codes). Raises an exception on argument error
Determines if a string is a valid full Open Location Code(Plus+Codes)
Recovers a full Open Location Code(Plus+Codes) from a short code and a reference location. Returns an :ok/:error tuple
Recovers a full Open Location Code(Plus+Codes) from a short code and a reference location. Raises an exception on argument error
Determines if a string is a valid short Open Location Code(Plus+Codes)
Removes four, six or eight digits from the front of an Open Location Code(Plus+Codes) given a reference location. Returns an :ok/:error tuple
Removes four, six or eight digits from the front of an Open Location Code(Plus+Codes) given a reference location. Raises an exception on argument error
Determines if a string is a valid sequence of Open Location Code(Plus+Codes) characters
Link to this section Functions
decode(String.t()) :: {:ok, PlusCodes.CodeArea.t()} | {:error, String.t()}
Decodes an Open Location Code(Plus+Codes) into a PlusCodes.CodeArea struct. Returns an :ok/:error tuple
Decodes an Open Location Code(Plus+Codes) into a PlusCodes.CodeArea struct. Raises an exception on argument error.
Converts a latitude and longitude into a Open Location Code(Plus+Codes). Returns an :ok/:error tuple
Examples
iex> PlusCodes.OpenLocationCode.encode(33.978938, -118.393812)
{:ok, "8553XJH4+HF"}
Converts a latitude and longitude into a Open Location Code(Plus+Codes). Raises an exception on argument error.
Examples
iex> PlusCodes.OpenLocationCode.encode!(33.978938, -118.393812)
"8553XJH4+HF"
Determines if a string is a valid full Open Location Code(Plus+Codes).
Examples
iex> PlusCodes.OpenLocationCode.full?("8553XJH4+HF")
true
iex> PlusCodes.OpenLocationCode.full?("XJH4+HF")
false
Recovers a full Open Location Code(Plus+Codes) from a short code and a reference location. Returns an :ok/:error tuple
Examples
iex> PlusCodes.OpenLocationCode.recover_nearest("XJH4+HF", 33.978938, -118.393812)
{:ok, "8553XJH4+HF"}
Recovers a full Open Location Code(Plus+Codes) from a short code and a reference location. Raises an exception on argument error.
Examples
iex> PlusCodes.OpenLocationCode.recover_nearest!("XJH4+HF", 33.978938, -118.393812)
"8553XJH4+HF"
Determines if a string is a valid short Open Location Code(Plus+Codes).
Examples
iex> PlusCodes.OpenLocationCode.short?("XJH4+HF")
true
iex> PlusCodes.OpenLocationCode.short?("8553XJH4+HF")
false
Removes four, six or eight digits from the front of an Open Location Code(Plus+Codes) given a reference location. Returns an :ok/:error tuple
Examples
iex> PlusCodes.OpenLocationCode.shorten("8553XJH4+HF", 33.978938, -118.393812)
{:ok, "+HF"}
iex> PlusCodes.OpenLocationCode.shorten("8553XJH4+HF", 33.978, -118.393)
{:ok, "H4+HF"}
iex> PlusCodes.OpenLocationCode.shorten("8553XJH4+HF", 33.9, -118.3)
{:ok, "XJH4+HF"}
Removes four, six or eight digits from the front of an Open Location Code(Plus+Codes) given a reference location. Raises an exception on argument error.
Examples
iex> PlusCodes.OpenLocationCode.shorten!("8553XJH4+HF", 33.978938, -118.393812)
"+HF"
iex> PlusCodes.OpenLocationCode.shorten!("8553XJH4+HF", 33.978, -118.393)
"H4+HF"
iex> PlusCodes.OpenLocationCode.shorten!("8553XJH4+HF", 33.9, -118.3)
"XJH4+HF"
Determines if a string is a valid sequence of Open Location Code(Plus+Codes) characters.
Examples
iex> PlusCodes.OpenLocationCode.valid?("8553XJH4+HF")
true
iex> PlusCodes.OpenLocationCode.valid?("Not a valid code")
false