android 获取图片上某一个文字位置_Android 得到照片位置信息

目前Android SDK定义的Tag有:

TAG_DATETIME    时间日期

TAG_FLASH   闪光灯

TAG_GPS_LATITUDE   纬度

TAG_GPS_LATITUDE_REF  纬度参考

TAG_GPS_LONGITUDE   经度

TAG_GPS_LONGITUDE_REF  经度参考

TAG_IMAGE_LENGTH   图片长

TAG_IMAGE_WIDTH   图片宽

TAG_MAKE   设备制造商

TAG_MODEL   设备型号

TAG_ORIENTATION   方向

TAG_WHITE_BALANCE   白平衡

String sFileName="/sdcard/DCIM/Camera/1.JPG";try{

ExifInterface exif= newExifInterface(sFileName);

String sModel=exif.getAttribute(ExifInterface.TAG_MODEL);

Toast.makeText(PhotoCatActivity.this,"1.JPG Exif:"+sModel, Toast.LENGTH_SHORT).show();

}catch(Exception ee){

}

经纬度得到的数据格式是 "num1/denom1,num2/denom2,num3/denom3",如何得到真正的经纬度呢?

publicLocation exif2Loc(String flNm) {

String sLat= "", sLatR = "", sLon = "", sLonR = "";try{

ExifInterface ef= newExifInterface(flNm);

sLat=ef.getAttribute(ExifInterface.TAG_GPS_LATITUDE);

sLon=ef.getAttribute(ExifInterface.TAG_GPS_LONGITUDE);

sLatR=ef.getAttribute(ExifInterface.TAG_GPS_LATITUDE_REF);

sLonR=ef.getAttribute(ExifInterface.TAG_GPS_LONGITUDE_REF);

}catch (IOException e) {return null;}double lat =dms2Dbl(sLat);if (lat > 180.0) return null;double lon =dms2Dbl(sLon);if (lon > 180.0) return null;

lat= sLatR.contains("S") ? -lat : lat;

lon= sLonR.contains("W") ? -lon : lon;

Location loc= new Location("exif");

loc.setLatitude(lat);

loc.setLongitude(lon);returnloc;

}//-------------------------------------------------------------------------

doubledms2Dbl(String sDMS){double dRV = 999.0;try{

String[] DMSs= sDMS.split(",", 3);

String s[]= DMSs[0].split("/", 2);

dRV= (new Double(s[0])/new Double(s[1]));

s= DMSs[1].split("/", 2);

dRV+= ((new Double(s[0])/new Double(s[1]))/60);

s= DMSs[2].split("/", 2);

dRV+= ((new Double(s[0])/new Double(s[1]))/3600);

}catch(Exception e) {}returndRV;

}

如何根据经纬度得到具体的地址?

public final String getAddress(double latitude, doublelongitude) {

Geocoder gc= new Geocoder(this, Locale.getDefault());

StringBuilder sb= newStringBuilder();try{

List

add= gc.getFromLocation(latitude, longitude, 1);if (add.size() > 0) {

Address ad= add.get(0);

sb.append(ad.getAddressLine(0));

sb.append(ad.getAddressLine(1));

sb.append(ad.getAddressLine(2));

}

}catch(Exception e) {

}returnsb.toString();

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值