如何将 Exif 长/纬度转换为实际值?

发布于 2024-10-21 13:05:24 字数 171 浏览 4 评论 0原文

我正在尝试从我的一些图片中获取 Exif 数据,这些是我收到的纬度和经度值。有人可以帮助我并告诉我这些数字的含义吗?

DEBUG/lat = 30/1,12/1,34/1 (7588):纬度

DEBUG/long = 81/1,22/1,41/1 (7588):经度

提前致谢。

I am trying to get the Exif data from some of my pictures and these are the latitude and longitude values that I am receiving. Can someone help me out and tell me what these numbers mean?

DEBUG/lat = 30/1,12/1,34/1 (7588) : lattitude

DEBUG/long = 81/1,22/1,41/1 (7588) : longitude

thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梨涡 2024-10-28 13:05:24

我本来打算为此编写一个转换器,但结果是答案 已经在此博客中

以防万一链接失效:

public class geoDegree {
private boolean valid = false;
Double Latitude, Longitude; 
geoDegree(ExifInterface exif) {
 String attrLATITUDE = exif.getAttribute(ExifInterface.TAG_GPS_LATITUDE);
 String attrLATITUDE_REF = exif.getAttribute(ExifInterface.TAG_GPS_LATITUDE_REF);
 String attrLONGITUDE = exif.getAttribute(ExifInterface.TAG_GPS_LONGITUDE);
 String attrLONGITUDE_REF = exif.getAttribute(ExifInterface.TAG_GPS_LONGITUDE_REF);

 if((attrLATITUDE !=null)
   && (attrLATITUDE_REF !=null)
   && (attrLONGITUDE != null)
   && (attrLONGITUDE_REF !=null))
 {
  valid = true;

  if(attrLATITUDE_REF.equals("N")){
   Latitude = convertToDegree(attrLATITUDE);
  }
  else{
   Latitude = 0 - convertToDegree(attrLATITUDE);
  }

  if(attrLONGITUDE_REF.equals("E")){
   Longitude = convertToDegree(attrLONGITUDE);
  }
  else{
   Longitude = 0 - convertToDegree(attrLONGITUDE);
  }

 }
};

private Float convertToDegree(String stringDMS){
 Float result = null;
 String[] DMS = stringDMS.split(",", 3);

 String[] stringD = DMS[0].split("/", 2);
    Double D0 = new Double(stringD[0]);
    Double D1 = new Double(stringD[1]);
    Double FloatD = D0/D1;

 String[] stringM = DMS[1].split("/", 2);
 Double M0 = new Double(stringM[0]);
 Double M1 = new Double(stringM[1]);
 Double FloatM = M0/M1;

 String[] stringS = DMS[2].split("/", 2);
 Double S0 = new Double(stringS[0]);
 Double S1 = new Double(stringS[1]);
 Double FloatS = S0/S1;

    result = new Float(FloatD + (FloatM/60) + (FloatS/3600));

 return result;


};

public boolean isValid()
{
 return valid;
}

@Override
public String toString() {
 // TODO Auto-generated method stub
 return (String.valueOf(Latitude)
   + ", "
   + String.valueOf(Longitude));
}

public int getLatitudeE6(){
 return (int)(Latitude*1000000);
}

public int getLongitudeE6(){
 return (int)(Longitude*1000000);
}

}

I was going to write a converter for this and stuff, but it turns out the answer is already in this blog

Just in case if the link goes dead:

public class geoDegree {
private boolean valid = false;
Double Latitude, Longitude; 
geoDegree(ExifInterface exif) {
 String attrLATITUDE = exif.getAttribute(ExifInterface.TAG_GPS_LATITUDE);
 String attrLATITUDE_REF = exif.getAttribute(ExifInterface.TAG_GPS_LATITUDE_REF);
 String attrLONGITUDE = exif.getAttribute(ExifInterface.TAG_GPS_LONGITUDE);
 String attrLONGITUDE_REF = exif.getAttribute(ExifInterface.TAG_GPS_LONGITUDE_REF);

 if((attrLATITUDE !=null)
   && (attrLATITUDE_REF !=null)
   && (attrLONGITUDE != null)
   && (attrLONGITUDE_REF !=null))
 {
  valid = true;

  if(attrLATITUDE_REF.equals("N")){
   Latitude = convertToDegree(attrLATITUDE);
  }
  else{
   Latitude = 0 - convertToDegree(attrLATITUDE);
  }

  if(attrLONGITUDE_REF.equals("E")){
   Longitude = convertToDegree(attrLONGITUDE);
  }
  else{
   Longitude = 0 - convertToDegree(attrLONGITUDE);
  }

 }
};

private Float convertToDegree(String stringDMS){
 Float result = null;
 String[] DMS = stringDMS.split(",", 3);

 String[] stringD = DMS[0].split("/", 2);
    Double D0 = new Double(stringD[0]);
    Double D1 = new Double(stringD[1]);
    Double FloatD = D0/D1;

 String[] stringM = DMS[1].split("/", 2);
 Double M0 = new Double(stringM[0]);
 Double M1 = new Double(stringM[1]);
 Double FloatM = M0/M1;

 String[] stringS = DMS[2].split("/", 2);
 Double S0 = new Double(stringS[0]);
 Double S1 = new Double(stringS[1]);
 Double FloatS = S0/S1;

    result = new Float(FloatD + (FloatM/60) + (FloatS/3600));

 return result;


};

public boolean isValid()
{
 return valid;
}

@Override
public String toString() {
 // TODO Auto-generated method stub
 return (String.valueOf(Latitude)
   + ", "
   + String.valueOf(Longitude));
}

public int getLatitudeE6(){
 return (int)(Latitude*1000000);
}

public int getLongitudeE6(){
 return (int)(Longitude*1000000);
}

}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文