PHP中的GPS格式

Ada*_*dam 0 php gps

如何在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形式是微不足道的.有必要知道它是纬度还是纵向坐标才能完全转换它.方法如下:

  • 减去坐标的整数部分,留下小数部分.整数是度数.87.728055 = 87度.
  • 将剩余的小数部分乘以60.这将在整数部分产生若干分钟.0.728055 x 60 = 43.6833 = 43分钟.
  • 将分钟数的小数部分乘以60,产生若干秒.0.6833 x 60 = 40.998 = 41秒.可以将其计为40秒,截断小数,将其四舍五入为41,或保留整个数字.
  • 根据源编号是纬度坐标还是纵向坐标,以及编号的符号,添加N/S/E/W说明符.下表显示了可能性:
  Type   Dir.   Sign    Test
  Lat.   N      +       > 0
  Lat.   S      -       < 0
  Long.  E      +       > 0
  Long.  W      -       < 0

坐标为0°0'0"纬度或经度的坐标既不是北也不是南,东也不是西.它只是零纬度或零经度.

最终结果是:W 87°43'41".


Gor*_*don 7

资源

<?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)

将数组更改为所需的字符串应该是微不足道的.