Add DMS value on Spot Messages
This commit is contained in:
22
inc/spot.php
22
inc/spot.php
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -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)})
|
||||
|
||||
Reference in New Issue
Block a user