跟踪设备的数据发送在$GPRMC
这不是我在我的代码中使用的将是谷歌的PHP转换为十进制格式的方法没有用。
刚刚得到的解决方案,这不得不煮沸我的头上的内容$GPRMC
样本格式eidog$GPRMC,001225,A,2832.1834,N,08101.0536,W,12,25,251211,1.2,E,A*03
其中:
RMC Recommended Minimum sentence C
123519 Fix taken at 12:35:19 UTC
A Status A=active or V=Void.
4807.038,N Latitude 48 deg 07.038' N
01131.000,E Longitude 11 deg 31.000' E
022.4 Speed over the ground in knots
084.4 Track angle in degrees True
230394 Date - 23rd of March 1994
003.1,W Magnetic Variation
*6A The checksum data, always begins with *
和代码:
$gps = $_REQUEST['gps'];
if($gps){
$buffer = $gps;
if(substr($buffer, 0, 5)=='GPRMC'){
$gprmc = explode(',',$buffer);
$data1['lattitude_decimal'] = DMStoDEC($gprmc[3],'lattitude');
$data2['longitude_decimal'] = DMStoDEC($gprmc[5],'longitude');
$data = 'http://maps.google.com/maps?q='.$data1['lattitude_decimal'].','.$data2['longitude_decimal'].'+(PHP Decoded)&iwloc=A';
print_r($data);
echo "\n\n";
}
}
function DMStoDEC($dms, $longlat){
if($longlat == 'lattitude'){
$deg = substr($dms, 0, 2);
$min = substr($dms, 2, 8);
$sec = '';
}
if($longlat == 'longitude'){
$deg = substr($dms, 0, 3);
$min = substr($dms, 3, 8);
$sec='';
}
return $deg+((($min*60)+($sec))/3600);
}
?>
希望这能帮助到一些人
2条答案
按热度按时间yh2wf1be1#
这是典型的发帖请求:
该行应该是
$gps = $_REQUEST['gprmc'];
。您确定该行吗?if(substr($buffer, 0, 5)=='GPRMC') {
不应该是:
if(substr($buffer, 1, 5)=='GPRMC') {
?而且你肯定忽略了NWSE字母!
7uzetpgm2#
formula acá