android应用如何将位置信息写入JPEG文件中

  介绍

这篇文章给大家介绍android应用如何将位置信息写入JPEG文件中,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。

<强>核心代码

/* *   *,浮点型经纬度值转成度分秒格式   *,   *,@param  coord   *,@return   */public  String  decimalToDMS (double  coord), {   String 输出,一定程度上,分,秒,//,gets 从而,modulus 从而coordinate  divided  by  one  (MOD1)。//,拷贝other  words  gets  all 从而numbers  after 从而decimal 点。//,如只mod :=, -79.982195, %, 1,==0.982195////,next  get 从而integer  part  of 从而coord只提醒other  words 从而整体//number 部分。//,如只intPart :=-79      double  mod =, coord  %, 1;   int  intPart =, (int), coord;//,set  degrees 用,value  of  intPart//,如只degrees :=,“-79”;      时间=degrees  String.valueOf (intPart);//,next  times 从而MOD1  of  degrees  by  60, so 还要find 我方表示歉意,integer 部分//for 分钟。//,get 从而,MOD1  of 从而new  coord 用find 从而numbers  after 从而小数//点。//,如只coord :=, 0.982195, *, 60,==58.9317//,mod :=, 58.9317, %, 1,==0.9317////,next  get 从而value  of 从而integer  part  of 从而coord。//,如只intPart :=58      *=coord  mod  60;   时间=mod  coord  %, 1;   intPart =, (int), coord;   if  (intPart  & lt;, 0), {//,Convert  number 用positive  if 这# 39;s 消极的。   *=intPart  1;   }//,set  minutes 用,value  of  intPart。//,如只minutes =,“58“;   时间=minutes  String.valueOf (intPart);//,do 从而,same  again  for 分钟//,如只coord :=, 0.9317, *, 60,==55.902//,如只intPart :=55   *=coord  mod  60;   intPart =, (int), coord;   if  (intPart  & lt;, 0), {//,Convert  number 用positive  if 这# 39;s 消极的。   *=intPart  1;   }//,set  seconds 用,value  of  intPart。//,如只seconds =,“55”;   时间=seconds  String.valueOf (intPart);//,小姐:used 却;能够format  for  android  but 你还要change 它的代价//,用return 拷贝whatever  format 你喜欢//,如只output =,, -79/1, 58/1, 56/1"   +=output  degrees “/1“, +, minutes  +,“/1“, +, seconds  +,“/1“;;//,Standard  output  of  D°M′S”=//,output  degrees  +,“°“, +, minutes  +,“& # 39;“, +, seconds  +,“\”;“      return 产量;   }/* *   *,将经纬度信息写入JPEG图片文件里   *,   *,@param  picPath   *,,,,,,JPEG图片文件路径   *,@param  dLat   *,,,,,,纬度   *,@param  dLon   *,,,,,,经度   */public  void  writeLatLonIntoJpeg (String  picPath, double  dLat,, double  dLon), {   File  File =, new 文件(picPath);   if  (file.exists ()), {   try  {   ExifInterface  exif =, new  ExifInterface (picPath);   String  tagLat =exif   .getAttribute (ExifInterface.TAG_GPS_LATITUDE);   String  tagLon =exif   .getAttribute (ExifInterface.TAG_GPS_LONGITUDE);   if  (tagLat ==, null ,,, tagLon ==, null),//,无经纬度信息   {   exif.setAttribute (ExifInterface.TAG_GPS_LATITUDE   decimalToDMS (dLat));   exif.setAttribute (ExifInterface.TAG_GPS_LATITUDE_REF   dLat 祝辞,0,?,“N",:,“S");,//,区分南北半球   exif.setAttribute (ExifInterface.TAG_GPS_LONGITUDE   decimalToDMS (dLon));   exif.setAttribute (ExifInterface.TAG_GPS_LONGITUDE_REF   dLon 祝辞,0,?,“E",:,“W");,//,区分东经西经      exif.saveAttributes ();   }   },catch  (Exception  e), {      }   }   }

<>强测试代码

String  strImgPath =, getImageCachePath (), +, File.separator  +,“1. jpg";      ExifInterface  eif =, new  ExifInterface (strImgPath);   String  lat =, eif.getAttribute (ExifInterface.TAG_GPS_LATITUDE);   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null

android应用如何将位置信息写入JPEG文件中