Add DMS value on Spot Messages

This commit is contained in:
2019-01-30 22:39:28 +01:00
parent ead0a42ae4
commit 0239bb0551
2 changed files with 23 additions and 1 deletions

View File

@@ -258,6 +258,8 @@ class Spot extends Main
$asMessage['unix_timestamp'] = (int) $asMessage['unix_timestamp'];
$asMessage['latitude'] = floatval($asMessage['latitude']);
$asMessage['longitude'] = floatval($asMessage['longitude']);
$asMessage['lat_dms'] = self::DecToDMS($asMessage['latitude'], 'lat');
$asMessage['lon_dms'] = self::DecToDMS($asMessage['longitude'], 'lon');
$asMessage['relative_time'] = Toolbox::getDateTimeDesc($asMessage['unix_timestamp'], 'fr');
$asMessage['formatted_time'] = date(self::FORMAT_TIME, $asMessage['unix_timestamp']);
$asAllFeedMessages[] = $asMessage;
@@ -477,6 +479,26 @@ class Spot extends Main
return ($asThumbInfo['error']=='')?$asThumbInfo['out']:$sPicPath;
}
public static function DecToDMS($dValue, $sType='lat') {
if($sType=='lat') $sDirection = ($dValue >= 0)?'N':'S';
else $sDirection = ($dValue >= 0)?'E':'W';
$dAbsValue = abs($dValue);
//Degrees
$iDegree = floor($dAbsValue);
$dLeft = $dAbsValue - $iDegree;
//Minutes
$iMinute = floor($dLeft * 60);
$dLeft -= $iMinute / 60;
//Seconds
$fSecond = round($dLeft * 3600, 1);
return $iDegree.'°'.$iMinute.'\''.$fSecond.'"'.$sDirection;
}
}
?>