PHP提取GPS EXIF数据

PHP提取GPS EXIF数据,第1张

PHP提取GPS EXIF数据

根据http://en.wikipedia.org/wiki/Geotagging,

([0] => 46/1 [1] => 5403/100 [2] => 0/1 )
应表示46/1度,5403/100分钟,0/1秒,即46°54.03′0″
N。对秒进行归一化得到46°54′1.8″ N。

只要您没有得到负坐标(只要您将N / S和E /
W作为单独的坐标,就永远不要有负坐标),下面的代码就可以工作。让我知道是否存在错误(目前没有方便的PHP环境)。

//Pass in GPS.GPSLatitude or GPS.GPSLongitude or something in that formatfunction getGps($exifCoord){  $degrees = count($exifCoord) > 0 ? gps2Num($exifCoord[0]) : 0;  $minutes = count($exifCoord) > 1 ? gps2Num($exifCoord[1]) : 0;  $seconds = count($exifCoord) > 2 ? gps2Num($exifCoord[2]) : 0;  //normalize  $minutes += 60 * ($degrees - floor($degrees));  $degrees = floor($degrees);  $seconds += 60 * ($minutes - floor($minutes));  $minutes = floor($minutes);  //extra normalization, probably not necessary unless you get weird data  if($seconds >= 60)  {    $minutes += floor($seconds/60.0);    $seconds -= 60*floor($seconds/60.0);  }  if($minutes >= 60)  {    $degrees += floor($minutes/60.0);    $minutes -= 60*floor($minutes/60.0);  }  return array('degrees' => $degrees, 'minutes' => $minutes, 'seconds' => $seconds);}function gps2Num($coordPart){  $parts = explode('/', $coordPart);  if(count($parts) <= 0)// jic    return 0;  if(count($parts) == 1)    return $parts[0];  return floatval($parts[0]) / floatval($parts[1]);}


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5065218.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-16
下一篇 2022-11-16

发表评论

登录后才能评论

评论列表(0条)

保存