通过我的应用程序,我将图像上传到数据库。对于图像,我想使用 exif 数据捕获图像的拍摄位置。当我在手机上测试时,纬度和经度确实上传,但只是四舍五入的正数。
当我期待 Lat = 52.4 和 lon = -1.9 的位置时,我实际上得到了 lat = 52 和 lon 1
这是我的代码; lat 和 lon 都是字符串:
ExifInterface exif = new ExifInterface(mainMenu.filename);
lat = exif.getAttribute(ExifInterface.TAG_GPS_LATITUDE);
lon = exif.getAttribute(ExifInterface.TAG_GPS_LONGITUDE);
我保存纬度和经度的数据库值是 double 值,我也尝试过 float 。
最佳答案
查看documentation for ExifInterface ,您不应该使用 getLatLong(float[] output)方法?
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.
}
关于android - Exif 仅以整数形式返回纬度和经度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5817333/