Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GPS longitude and latitude from geotagged photo

I have geo tagging enabled in my phone camera. It saves latitude and longitude information (I've checked). I'm trying to read it like this

import static android.provider.MediaStore.Images.ImageColumns.*;    

Uri queryPhotoUri = ...; //uri of photo
String[] photoProjection = {LATITUDE,LONGITUDE,ORIENTATION,DESCRIPTION}; 

Cursor photoData = getContext().getContentResolver().query(
            queryPhotoUri, photoProjection, null, null, null);

int latIdx = photoData.getColumnIndex(LATITUDE);
int lngIdx = photoData.getColumnIndex(LONGITUDE);
int oriIdx = photoData.getColumnIndex(ORIENTATION);
int txtIdx = photoData.getColumnIndex(DESCRIPTION);

boolean latExists = !photoData.isNull(latIdx);
boolean lngExists = !photoData.isNull(lngIdx);
boolean oriExists = !photoData.isNull(oriIdx);
boolean txtExists = !photoData.isNull(txtIdx);

oriExists evaluates to TRUE, the rest to FALSE. Why? Does the Image Content Provider write latitude and longitude as an exif attribute to the photo file, or does it store them somewhere else?

Also, I'm trying to write description of the photo to the DESCRIPTION column, but it's not saved. Where is the description stored?

Edit: This is getting stranger. I've checked the framework source and the MediaProvider class reads the exif tags from the photo and stores them in the database. However, the latitude and longitude fields are not stored for some reason.

like image 396
siamii Avatar asked Nov 14 '22 02:11

siamii


1 Answers

I suggest you to use ExifInterface

like image 55
Taras Shevchuk Avatar answered Dec 10 '22 08:12

Taras Shevchuk