function geofield_latlon_DECtoCCS in Geofield 7
Same name and namespace in other branches
- 7.2 geofield.module \geofield_latlon_DECtoCCS()
Decimal Degrees to Celestial coordinate system (CCS) units
Converts decimal latitude to DMS ( Degrees / minutes / seconds ) and decimal longitude to Angular Hours / Minutes / Seconds
1 call to geofield_latlon_DECtoCCS()
- geofield_field_formatter_view in ./
geofield.formatters.inc - Implements hook_field_formatter_view().
File
- ./
geofield.module, line 398
Code
function geofield_latlon_DECtoCCS($dec, $axis) {
// Declination (celestial latitude) should be representeted in Degrees / minutes / seconds
if ($axis == 'lat') {
$vars = explode(".", $dec);
$deg = $vars[0];
if (isset($vars[1])) {
$tempma = "0." . $vars[1];
}
else {
$tempma = "0";
}
$tempma = $tempma * 3600;
$min = floor($tempma / 60);
$sec = $tempma - $min * 60;
return $deg . "° " . $min . "' " . round($sec, 3) . "\"";
}
// Right ascension (celestial longitude) should be representeted in Hours / Minutes / Seconds
if ($axis == 'lon') {
$tempma = $dec / 15;
$vars = explode(".", $tempma);
$hrs = $vars[0];
if (isset($vars[1])) {
$tempma = "0." . $vars[1];
}
else {
$tempma = "0";
}
$tempma = $tempma * 60;
$vars = explode(".", $tempma);
$min = $vars[0];
if (isset($vars[1])) {
$tempma = "0." . $vars[1];
}
else {
$tempma = "0";
}
$sec = $tempma * 60;
return $hrs . "h " . $min . "m " . round($sec, 3) . "s";
}
}