通过ExifInterface可以将拍照时的一些属性信息写入图片文件里,其中包括经纬度信息。本文介绍一种将经纬度坐标写入JPEG图片文件的方法!
核心代码
/**
* 浮点型经纬度值转成度分秒格式
*
* @param coord
* @return
*/
public String decimalToDMS(double coord) {
String output, degrees, minutes, seconds;
// gets the modulus the coordinate divided by one (MOD1).
// in other words gets all the numbers after the decimal point.
// e.g. mod := -79.982195 % 1 == 0.982195
//
// next get the integer part of the coord. On other words the whole
// number part.
// e.g. intPart := -79
double mod = coord % 1;
int intPart = (int) coord;
// set degrees to the value of intPart
// e.g. degrees := "-79"
degrees = String.valueOf(intPart);
// next times the MOD1 of degrees by 60 so we can find the integer part
// for minutes.
// get the MOD1 of the new coord to find the numbers after the decimal