如何在PHP从格式52.593800,21.448850格式+ 52°35'制成37.68" ,+ 21°26' 55.86"喜欢做它谷歌http://maps.google.pl/maps?hl=pl&t=m&q=52.593800,21.448850?
and*_*dri 10
直接来自维基百科:
给定一个十进制纵向坐标,如-87.728055,将它转换为DMS形式是微不足道的.有必要知道它是纬度还是纵向坐标才能完全转换它.方法如下:
Type Dir. Sign Test Lat. N + > 0 Lat. S - < 0 Long. E + > 0 Long. W - < 0
坐标为0°0'0"纬度或经度的坐标既不是北也不是南,东也不是西.它只是零纬度或零经度.
最终结果是:W 87°43'41".
<?php
function DMStoDEC($deg,$min,$sec)
{
// Converts DMS ( Degrees / minutes / seconds )
// to decimal format longitude / latitude
return $deg+((($min*60)+($sec))/3600);
}
function DECtoDMS($dec)
{
// Converts decimal longitude / latitude to DMS
// ( Degrees / minutes / seconds )
// This is the piece of code which may appear to
// be inefficient, but to avoid issues with floating
// point math we extract the integer part and the float
// part by using a string function.
$vars = explode(".",$dec);
$deg = $vars[0];
$tempma = "0.".$vars[1];
$tempma = $tempma * 3600;
$min = floor($tempma / 60);
$sec = $tempma - ($min*60);
return array("deg"=>$deg,"min"=>$min,"sec"=>$sec);
}
Run Code Online (Sandbox Code Playgroud)
将数组更改为所需的字符串应该是微不足道的.
| 归档时间: |
|
| 查看次数: |
6701 次 |
| 最近记录: |