Oct 19, 2011

Convert GPS tag of ExifInterface to degree

If there are GPS info in Exif of JPG, it can be read using ExifInterface.getAttribute(). Refer to the source code in last post, Read Exif of JPG file using ExifInterface.

Read GPS of JPG using ExifInterface.getAttribute()

TAG_GPS_LATITUDE and TAG_GPS_LONGITUDE return String in format of "num1/denom1,num2/denom2,num3/denom3". It can be converted to degree using folowing method:

Latitude (TAG_GPS_LATITUDE)
= 22/1,16/1,5935883/125557
= 22/1 + 16/(1*60) + 5935883/(125557*3600)
= 22 + 0.266666666667 + 0.0131323334333
= 22.2797990001
if TAG_GPS_LATITUDE_REF == "N", it's positive; otherwise it's negative.

Longitude (TAG_GPS_LONGITUDE)
= 114/1,7/1,1429891026/483594097
= 114/1 + 7/(1*60) + 1429891026/(483594097*3600)
= 114 + 0.116666666667 + 0.000821333333328
= 114.117488
if TAG_GPS_LONGITUDE_REF == "E", it's positive; otherwise it's negative.

Related:
- Get latitude and longitude of Exif



No comments:

Post a Comment

Infolinks In Text Ads