Latlong

Provides a parser for latitude and longitude strings. Handles various formats for specifying a position. Parsing returns a tuple latitude and longitude in a signed decimal degree format. The parser accepts the following formats:

Example Usage

iex> LatLong.parse "39.1371°N, 88.65°W"
{39.1371, -88.65}

iex> LatLong.parse "39.1371°E", "88.65°W"
{:error, "Error Parsing Latitude"}

The second example above returns an error since latitude is NS and E was specified. The correct function call is:

iex> LatLong.parse "39.1371°N", "88.65°W"
{39.1371, -88.65}

Road Map

A formatting function needs to be provided that takes a format string such as these:

d.°D         39.1371°N
d° m' s"D     39° 20' 33"S
Sd.           39.1371
Sd m.'         39 20.5

Formatting could also be provided with parsing for a 'strict' mode. After parsing, a format string could be returned that defines the format encountered during the parse. This could be useful for reformatting in the format provided for parsing.

A mode could be added that insures both the longitude and the latitude use the same format.

Installation

If available in Hex, the package can be installed as:

  1. Add latlong to your list of dependencies in mix.exs:
```elixir
def deps do
  [{:latlong, "~> 0.1.0"}]
end
```