++ed by:
Walter Mankowski

# NAME

Geo::Coordinates::DecimalDegrees - convert between degrees/minutes/seconds and decimal degrees

# SYNOPSIS

``````  use Geo::Coordinates::DecimalDegrees;
(\$degrees, \$minutes, \$seconds, \$sign) = decimal2dms(\$decimal_degrees);
(\$degrees, \$minutes, \$sign) = decimal2dm(\$decimal_degrees);
\$decimal_degrees = dms2decimal(\$degrees, \$minutes, \$seconds);
\$decimal_degrees = dm2decimal(\$degrees, \$minutes);``````

# DESCRIPTION

Latitudes and longitudes are most often presented in two common formats: decimal degrees, and degrees, minutes and seconds. There are 60 minutes in a degree, and 60 seconds in a minute. In decimal degrees, the minutes and seconds are presented as a fractional number of degrees. For example, 1 degree 30 minutes is 1.5 degrees, and 30 minutes 45 seconds is 0.5125 degrees.

This module provides functions for converting between these two formats.

# FUNCTIONS

This module provides the following functions, which are all exported by default when you call `use Geo::Coordinates::DecimalDegrees;`:

decimal2dms(\$decimal_degrees)

Converts a floating point number of degrees to the equivalent number of degrees, minutes, and seconds, which are returned as a 3-element list. Typically used as follows:

``  (\$degrees, \$minutes, \$seconds) = decimal2dms(\$decimal_degrees);``

If \$decimal_degrees is negative, only \$degrees will be negative. \$minutes and \$seconds will always be positive.

If \$decimal_degrees is between 0 and -1, \$degrees will be returned as 0. If you need to know the sign in these cases, you can use this longer version, where \$sign is 1, 0, or -1 depending on whether \$decimal_degrees is positive, 0, or negative:

``  (\$degrees, \$minutes, \$seconds, \$sign) = decimal2dms(\$decimal_degrees);``
decimal2dm(\$decimal_degrees)

Converts a floating point number of degrees to the equivalent number of degrees and minutes which are returned as a 2-element list. Typically used as follows:

``  (\$degrees, \$minutes) = decimal2dm(\$decimal_degrees);``

If \$decimal_degrees is negative, only \$degrees will be negative. \$minutes will always be positive.

If \$decimal_degrees is between 0 and -1, \$degrees will be returned as 0. If you need to know the sign in these cases, you can use this longer version, where \$sign is 1, 0, or -1 depending on whether \$decimal_degrees is positive, 0, or negative:

``  (\$degrees, \$minutes, \$sign) = decimal2dm(\$decimal_degrees);``
dms2decimal(\$degrees, \$minutes, \$seconds)

Converts degrees, minutes, and seconds to the equivalent number of decimal degrees:

``  \$decimal_degrees = dms2decimal(\$degrees, \$minutes, \$seconds);``

If \$degrees is negative, then \$decimal_degrees will also be negative.

dm2decimal(\$degrees, \$minutes)

Converts degrees and minutes to the equivalent number of decimal degrees:

``  \$decimal_degrees = dm2decimal(\$degrees, \$minutes);``

If \$degrees is negative, then \$decimal_degrees will also be negative.

# CAVEATS

The functions don't do any sanity checks on their arguments. If you have a good reason to convert 61 minutes -101 seconds to decimal, go right ahead.

# AUTHOR

Walt Mankowski, <waltman@cpan.org>