View Source LibLatLon.Coords (LibLatLon v0.8.0)
Main struct to be used as coordinates representation.
One might cast nearly everything to LibLatLon.Coord
with
LibLatLon.Coord.borrow/1
and/or LibLatLon.Coord.borrow/2
.
This struct implements both String.Chars
and Inspect
protocols.
The fancy string representation of any lat/lon pair might be get by
Kernel.to_string/1
:
iex> to_string(LibLatLon.Coords.borrow(lat: 41.38, lon: 2.19))
"41°22´48.0˝N,2°11´24.0˝E"
Note, that this representation might be used as is when querying any
geolocation services and/or GoogleMaps
. Try:
Summary
Types
Degrees, minutes and seconds as a tuple
Degrees, minutes and seconds as a list
Degrees, minutes and seconds with an optional semisphere reference
The type to store coordinates.
Functions
Converts literally any input to LibLatLon.Coords
instance.
Converts {{degree, minute, second}, semisphere}
or
{[degree, minute, second], semisphere}
representation into
LibLatLon.Coords
.
Converts degree, minute, second, semisphere
representation into
LibLatLon.Coords
. When the last parameter semisphere
is not one of:
"S"
or "W"
or -1
or :south
or west
, it is implicitly
considered to be in NE
semisphere.
Retrieves coordinates from barely anything.
Same as LibLatLon.Coords.coordinate/1
, but banged.
Converts literally anything, provided as combined latlon
value
to two tuples {{degree, minute, second}, semisphere}
. Barely used
from the outside the package, since LibLatLon.Coords.t
is obviously
better type to work with coordinates by all means.
Converts literally anything, provided as latitude and longitude values
to two tuples {{degree, minute, second}, semisphere}
. Barely used
from the outside the package, since LibLatLon.Coords.t
is obviously
better type to work with coordinates by all means.
Types
Degrees, minutes and seconds as a tuple
@type dms_list() :: [number()]
Degrees, minutes and seconds as a list
Degrees, minutes and seconds with an optional semisphere reference
@type t() :: %LibLatLon.Coords{ lat: number(), lon: number(), alt: number(), direction: number(), magnetic?: boolean() }
The type to store coordinates.
Mostly used fields are lat
and lon
, stored as Float.t
. Also
might contain altitude
and direction
to calculate the latitude
and langitude for the destination point (mostly used when dealing with
EXIF
information from images.)
Functions
@spec borrow( {number(), number()} | nil | {dms_ss(), dms_ss()} | dms_ss() | [number()] | map() | binary() | keyword() | %Exexif.Data.Gps{ gps_altitude: term(), gps_altitude_ref: term(), gps_area_information: term(), gps_date_stamp: term(), gps_dest_bearing: term(), gps_dest_bearing_ref: term(), gps_dest_distance: term(), gps_dest_distance_ref: term(), gps_dest_latitude: term(), gps_dest_latitude_ref: term(), gps_dest_longitude: term(), gps_dest_longitude_ref: term(), gps_differential: term(), gps_dop: term(), gps_h_positioning_errorl: term(), gps_img_direction: term(), gps_img_direction_ref: term(), gps_latitude: term(), gps_latitude_ref: term(), gps_longitude: term(), gps_longitude_ref: term(), gps_map_datum: term(), gps_measure_mode: term(), gps_processing_method: term(), gps_satellites: term(), gps_speed: term(), gps_speed_ref: term(), gps_status: term(), gps_time_stamp: term(), gps_track: term(), gps_track_ref: term(), gps_version_id: term() } ) :: t() | number() | nil | {:error, any()}
Converts literally any input to LibLatLon.Coords
instance.
Examples
iex> LibLatLon.Coords.borrow("41°23´16˝N,2°11´50˝E")
%LibLatLon.Coords{lat: 41.38777777777778, lon: 2.197222222222222}
iex> LibLatLon.Coords.borrow("41°23´16.222˝N,2°11´50.333˝E")
%LibLatLon.Coords{lat: 41.387839444444445, lon: 2.197314722222222}
iex> LibLatLon.Coords.borrow({{{41, 23, 16.0}, "N"}, {{2, 11, 50.0}, "E"}})
%LibLatLon.Coords{lat: 41.38777777777778, lon: 2.197222222222222}
iex> LibLatLon.Coords.borrow(lat: 41.38, lon: 2.19)
%LibLatLon.Coords{lat: 41.38, lon: 2.19}
Converts {{degree, minute, second}, semisphere}
or
{[degree, minute, second], semisphere}
representation into
LibLatLon.Coords
.
Converts degree, minute, second, semisphere
representation into
LibLatLon.Coords
. When the last parameter semisphere
is not one of:
"S"
or "W"
or -1
or :south
or west
, it is implicitly
considered to be in NE
semisphere.
Retrieves coordinates from barely anything.
iex> {:ok, result} = LibLatLon.Coords.coordinate("test/inputs/1.jpg")
...> result
#Coord<[lat: 41.37600333333334, lon: 2.1486783333333332, fancy: "41°22´33.612˝N,2°8´55.242˝E"]>
iex> LibLatLon.Coords.coordinate("test/inputs/unknown.jpg")
{:error, {:weird_input, [nil]}}
Same as LibLatLon.Coords.coordinate/1
, but banged.
Examples
iex> LibLatLon.Coords.coordinate!("test/inputs/1.jpg")
#Coord<[lat: 41.37600333333334, lon: 2.1486783333333332, fancy: "41°22´33.612˝N,2°8´55.242˝E"]>
Converts literally anything, provided as combined latlon
value
to two tuples {{degree, minute, second}, semisphere}
. Barely used
from the outside the package, since LibLatLon.Coords.t
is obviously
better type to work with coordinates by all means.
Examples
iex> LibLatLon.Coords.lend({41.38777777777778, 2.197222222222222})
{{{41, 23, 16.0}, "N"}, {{2, 11, 50.0}, "E"}}
iex> LibLatLon.Coords.lend([41.38777777777778, 2.197222222222222])
{{{41, 23, 16.0}, "N"}, {{2, 11, 50.0}, "E"}}
Converts literally anything, provided as latitude and longitude values
to two tuples {{degree, minute, second}, semisphere}
. Barely used
from the outside the package, since LibLatLon.Coords.t
is obviously
better type to work with coordinates by all means.
Examples
iex> LibLatLon.Coords.lend(41.38777777777778, 2.197222222222222)
{{{41, 23, 16.0}, "N"}, {{2, 11, 50.0}, "E"}}