I am trying to convert Exif longitude and latitude data to Google decimal. I read a lot of tutorials, but nothing seems to work for me. Perhaps I am completely mistaken.
I successfully get Exif data as follows:
$ exif_data = exif_read_data ($ path. '/user/images/4.jpg');
$egeoLong = $exif_data['GPSLongitude']; $egeoLat = $exif_data['GPSLatitude']; $egeoLongR = $exif_data['GPSLongitudeRef']; $egeoLatR = $exif_data['GPSLatitudeRef'];
From there, I get the following array for the values:
deg Long: 118/1 min Long: 2147/100 sec Long: 0/1 Longitude Ref: W deg Lat: 34/1 min Lat: 433/100 sec Lat: 0/1 Latitude Ref: N
And I run them through this function to get the decimal value (I got this function here in Stackoverflow).
$geoLong = gpsDecimal($egeoLong[0], $egeoLong[1], $egeoLong[2], $egeoLongR); $geoLat = gpsDecimal($egeoLat[0], $egeoLat[1], $egeoLat[2], $egeoLatR); function gpsDecimal($deg, $min, $sec, $hemi) { $d = $deg+((($min*60)+($sec))/3600); return ($hemi=='S' || $hemi=='W') ? $d*=-1 : $d; }
Which returns the following ... which sets the coordinates in the middle of the ocean ... not where I took the picture.
Latitude: 41.216666666667 Longitude: -153.78333333333
Can someone tell me what I'm doing wrong, or is the best way to achieve this. Any help is greatly appreciated.
source share