James
James

Reputation: 486

Exif only returning lat & lon as whole numbers

Through my app I upload images to a database. With the images I want to capture the location the image was taken by using the exif data. When I tested on my phone the lat and lon did upload but only to a rounded positive number.

When I'm expecting a location of Lat = 52.4 and lon = -1.9 im actually getting lat = 52 and lon 1

Here is my code; lat and lon are both String:

ExifInterface exif = new ExifInterface(mainMenu.filename);    
lat = exif.getAttribute(ExifInterface.TAG_GPS_LATITUDE);
lon = exif.getAttribute(ExifInterface.TAG_GPS_LONGITUDE);

My database values for holding the lat and lon are doubles and I've also tried float.

Upvotes: 2

Views: 1070

Answers (1)

Chris Shaffer
Chris Shaffer

Reputation: 32575

Looking at the documentation for ExifInterface, shouldn't you instead be using the getLatLong(float[] output) method?

float[] latLong = new float[2];
if (exif.getLatLong(latLong)) {
    // latLong[0] holds the Latitude value now.
    // latLong[1] holds the Longitude value now.
}
else {
    // Latitude and Longitude were not included in the Exif data.
}

Upvotes: 4

Related Questions