function contactinfo_coord_convert in Contact Info 7
Helper function to convert longitude or latitude points.
Convert a decimal-degree longitude or latitude point into degrees and decimal minutes.
Parameters
float $decimal: Decimal value for a longitude or latitude point.
string $direction: Strings 'longitude' or 'latitude' are the only acceptable inputs.
Return value
string String containing a single character for N, S, E, or W, the degrees as whole number, and minutes as a decimal value.
1 call to contactinfo_coord_convert()
- template_preprocess_contactinfo in ./
contactinfo.module - Theme preprocess function for the contact information block.
File
- ./
contactinfo.module, line 238 - Collects contact information and displays it in an hCard block.
Code
function contactinfo_coord_convert($decimal, $direction) {
$decimal = floatval($decimal);
if (!$decimal) {
return FALSE;
}
switch ($direction) {
case 'longitude':
$coord_direction = $decimal < 0 ? 'W' : 'E';
break;
case 'latitude':
$coord_direction = $decimal < 0 ? 'S' : 'N';
break;
default:
return FALSE;
}
$coord_degrees = intval($decimal);
$coord_minutes = abs(fmod($decimal, 1) * 60);
return $coord_direction . ' ' . $coord_degrees . '° ' . $coord_minutes . '"';
}