2011-04-28 84 views
2

通过我的应用程序,我将图像上传到数据库。我想通过使用exif数据来捕获图像的位置。当我在手机上进行测试时,经纬度和上限确实上传,但仅限于四舍五入的正数。Exif只以整数回到经纬度

当我期待的纬度位置= 52.4和LON = -1.9 IM实际上得到LAT = 52和LON 1

这里是我的代码;纬度和经度都是字符串:

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

举行的纬度和经度双打我数据库中的值,我也试着浮动。

回答

4

看着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. 
} 
+0

我将如何分配说拉特我的字符串经纬度? – James 2011-04-28 10:54:22

+0

我在某个地方误解了你;你的数据库值是不是加倍或浮动?你为什么需要字符串?无论如何,我真的不太了解java,但是不能只使用Float.toString(latLong [0])'? – 2011-04-28 11:01:54

+0

非常感谢您的帮助,现在的工作:) – James 2011-04-28 11:08:11