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;
}
}
?>

View File

@@ -370,7 +370,7 @@ function getPost(asPost) {
{
case 'message':
$Body = $('<div>')
.append($('<p>').addIcon('fa-message', true).append('Latitude '+asPost.latitude+', Longitude '+asPost.longitude))
.append($('<p>').addIcon('fa-message', true).append(asPost.lat_dms+' '+asPost.lon_dms))
.append($('<p>').addIcon('fa-time', true).append(sAbsTime))
.append(
$('<img>', {'class':'staticmap', title: 'Click pour zoomer', src: getStaticMapUrl(asPost.latitude, asPost.longitude)})