Parses the scheme-specific part of a geo URL as defined
in RFC 5870.
A geo URL carries a latitude, a longitude, an optional
altitude and optional parameters such as crs and u. The
primary API is parse/1, which URL.new/1 calls for any URL
with the geo scheme.
Summary
Types
Functions
Parses the path of a geo URI into a t/0 struct.
Arguments
uriis aURI.t/0whose:schemeis"geo".
Returns
{:ok, t:t/0}with the latitude, longitude, altitude (nilwhen absent) and parameters. Theu(uncertainty) parameter is converted to a number, or{:error, {URL.Parser.ParseError, reason}}if the path is not a validgeopayload, including an empty path.
Examples
iex> geo = URI.parse("geo:48.198634,-16.371648,3.4;crs=wgs84;u=40.0")
iex> URL.Geo.parse(geo)
{:ok,
%URL.Geo{
lat: 48.198634,
lng: -16.371648,
alt: 3.4,
params: %{"crs" => "wgs84", "u" => 40.0}
}}
iex> URL.Geo.parse(URI.parse("geo:48.198634,-16.371648"))
{:ok, %URL.Geo{lat: 48.198634, lng: -16.371648, alt: nil, params: %{}}}
iex> {:error, {URL.Parser.ParseError, _reason}} = URL.Geo.parse(URI.parse("geo:48.198634"))