我正在尝试将以度为单位的纬度和经度值转换为双倍。
价值观是这样的
"latitude":"25°21 N",
"longitude":"55°23 E"
When i try to log this in android it is coming like this.
![enter image description here](https://i.stack.imgur.com/SLAkP.png)
这是什么"A^"
那里有特殊的字符。怎么来的。另外当我尝试保存日志时
它就像25°21 N
如何将纬度和经度的度数转换为双精度值?
Thanks
对于您当前的示例,您必须解析您的输入,一次解析后将其分配给该公式。
解析输入
Map<String,String> yourMap; //imagine is your input
//"latitude":"25°21 N",
//"longitude":"55°23 E"
String latitude = yourMap.get("latitude");
String hour = latitude.split("º")[0];
String minute = latitude.split("º")[1].split(" ")[0];
// This is a very ugly way to parse it, better do with regular expressions,
// but I'm not an expert on them and cannot figure them.
//Parse result
String hour = "25";
String minute = "21";
String second = "0";
//Formula
double result = Integer.intValue(hour) +
Integer.intValue(minute) / 60 +
Integer.intValue(second) / 3600;
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)