android - Exif 仅以整数形式返回纬度和经度

标签 android exif

通过我的应用程序,我将图像上传到数据库。对于图像,我想使用 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/

相关文章:

iphone - 设置图像的 exif 数据时出现问题

javascript - 使用 Javascript 从 JPEG 中提取 IPTC 信息

c# - 从 JPEG 中提取 EXIF

python - 为什么我在图片上添加评论后图片的尺寸会变小?

android - 在android中播放音轨中的音频

android - 无法在 Android Studio 中将文件推送到 SD 卡

java - 如何通过gcm发送自定义消息并得到其响应?

c# - 使用 WriteImageToSavedPhotosAlbum 时未保存 Gps exif 数据

android - ImageView selectableItemBackgroundBorderless 不会在 View 边界之外呈现

java - 带 ARM 的 Box2d 旋转关节车辆