2013-11-14 132 views
-1

嗨我需要将GPS跟踪器的响应值转换为经度和纬度。响应值采用十六进制格式,文档中说经度和纬度为measured in degrees with a 1x10^-7 degree lsb, signed 2’s complement。例如:经纬度从十六进制值

Hexa  Binary        decimal  longitude 
B9DCF6B1 10111001110111001111011010110001 3118266033 -117.6701263 

任何人都可以帮助我解决这个问题,使用PHP。

+0

是你的问题PHP编程,或算法GPS数据转换为L/L? –

+0

@ ring0需要使用php的alogorthm。你能帮我吗? –

+0

@SujathanR请参阅http://stackoverflow.com/a/19420991/608624希望它有帮助 – LoneWOLFs

回答

2

移植this answer到PHP:

function convert($hex) 
{ 
    $dec = hexdec($hex); 
    return ($dec < 0x7fffffff) ? $dec * 0.0000001 
           : 0 - (0xffffffff - $dec) * 0.0000001; 
} 

测试:

var_dump(convert('B9DCF6B1')); // float(-117.6701262)