android - 如何在 Android 上的 exif 数据中保存 GPS 坐标?

标签 android gps exif geotagging

我正在将 GPS 坐标写入我的 JPEG 图像,并且坐标是正确的(如我的 logcat 输出所示),但它似乎以某种方式被损坏了。读取 exif 数据会产生空值,或者在我的 GPS 的情况下:512.976698 度,512.976698 度。谁能解释一下这个问题?

写下来:

        try {
            ExifInterface exif = new ExifInterface(filename);
            exif.setAttribute(ExifInterface.TAG_GPS_LATITUDE, latitude);
            exif.setAttribute(ExifInterface.TAG_GPS_LONGITUDE, longitude);
            exif.saveAttributes();
            Log.e("LATITUDE: ", latitude);
            Log.e("LONGITUDE: ", longitude);


        } catch (IOException e) {
            e.printStackTrace();
        }

并阅读它:

        try {
            ExifInterface exif = new ExifInterface("/sdcard/globetrotter/mytags/"+ TAGS[position]);
            Log.e("LATITUDE EXTRACTED", exif.getAttribute(ExifInterface.TAG_GPS_LATITUDE));
            Log.e("LONGITUDE EXTRACTED", exif.getAttribute(ExifInterface.TAG_GPS_LONGITUDE));
        } catch (IOException e) {
            e.printStackTrace();
        }

它进入(例如)37.715183-117.260489和出来33619970/65540、14811136/336855033619970/65540、14811136/3368550。我做错了吗?

编辑:

所以,问题是我没有以正确定义的格式对其进行编码,就像您在此处看到的那样:

enter image description here

谁能解释一下这种格式是什么?显然第一个数字是 22/1 = 22 度,但我不知道如何计算那里的小数。

最佳答案

GPSLatitude

Indicates the latitude. The latitude is expressed as three RATIONAL values giving the degrees, minutes, and seconds, respectively. If latitude is expressed as degrees, minutes and seconds, a typical format would be dd/1,mm/1,ss/1. When degrees and minutes are used and, for example, fractions of minutes are given up to two decimal places, the format would be dd/1,mmmm/100,0/1.

https://docs.google.com/viewer?url=http%3A%2F%2Fwww.exif.org%2FExif2-2.PDF

Android 文档对此没有任何解释:http://developer.android.com/reference/android/media/ExifInterface.html#TAG_GPS_LATITUDE

Exif 数据是标准化的,GPS 数据必须使用上述地理坐标(分、秒等)而不是分数进行编码。除非它在 ​​exif 标签中以这种格式编码,否则它不会粘住。

如何编码:http://en.wikipedia.org/wiki/Geographic_coordinate_conversion

如何解码:http://android-er.blogspot.com/2010/01/convert-exif-gps-info-to-degree-format.html

关于android - 如何在 Android 上的 exif 数据中保存 GPS 坐标?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5280479/

相关文章:

java - 将 google play services 版本添加到应用程序的 list 中会出错

android - 获取到一个点的最短距离

objective-c - iOS-向图像添加kCGImagePropertyExifUserComment的问题

android - 图像字节流操作

java - 调用 View.draw(Canvas) 方法时出现 ArrayIndexOutOfBoundException

android - 获取从相机传感器到当前设备方向的相对旋转

php - 检索与特定 GPS 坐标 + 距离匹配的项目

iphone - 如何使用 iPhone 中已安装的 GPS 系统

c# - 如何在 Windows Phone 8 中获取捕获图像或存储图像的地理标记详细信息

testing - 需要非压缩 TIFF 格式的带有 exif 缩略图的 JPEG 测试图像