Формат координат на странице точки

This commit is contained in:
Krivchikov Dmitry 2014-12-06 15:47:32 +03:00
parent 560f09c888
commit d5474fd524
2 changed files with 4 additions and 5 deletions

View File

@ -4,12 +4,11 @@ class Coord
{ {
static function dergeeToMinute($input) static function dergeeToMinute($input)
{ {
if ($input < 0) $input = abs($input);
$input *= -1;
$degree = floor($input); $degree = floor($input);
$minute = 60 * ($input - $degree); $minute = 60 * ($input - $degree);
return $degree.'°'.$minute.'\''; return $degree.'°'.substr($minute,0,6).'\'';
} }
} }

View File

@ -5,8 +5,8 @@
<div class="coords-container"> <div class="coords-container">
Координаты:&nbsp; Координаты:&nbsp;
<nobr> <nobr>
<?= $point->lat > 0 ? 'N' : 'S' ?><?= $point->lat > 0 ? $point->lat : (-1 * $point->lat) ?>° <?= $point->lat > 0 ? 'N' : 'S' ?><?= number_format(abs($point->lat),5,'.','') ?>°
<?= $point->lng > 0 ? 'E' : 'W' ?><?= $point->lng > 0 ? $point->lng : (-1 * $point->lng) ?>° <?= $point->lng > 0 ? 'E' : 'W' ?><?= number_format(abs($point->lng),5,'.','') ?>°
</nobr> </nobr>
&nbsp;&nbsp;/&nbsp;&nbsp; &nbsp;&nbsp;/&nbsp;&nbsp;
<nobr> <nobr>