EXIF只返回纬度和放大器; LON作为整数纬度、放大器、整数、EXIF

2023-09-07 16:40:10 作者:优秀小伙

通过我的应用程序,我上传图片到数据库中。与图像我想捕捉图像的拍摄使用EXIF数据的位置。当我测试了我的手机上的纬度和经度没有上传,但只有一个圆形的正数。

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.

在我期待的纬度位置= 52.4和LON = -1.9 IM实际上得到土地增值税= 52和LON 1

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

下面是我的code;纬度和经度都是字符串:

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.

推荐答案

综观的对于ExifInterface 文档,你不应该改为使用 getLatLong(浮动[]输出)方法?

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.
}
 
精彩推荐
图片推荐