2011-04-28 29 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