转换纬度和经度值(度)双。 Java的 [英] Convert Latitude and Longitude Values (Degrees) to Double . Java
本文介绍了转换纬度和经度值(度)双。 Java的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想转换这是在度翻一番纬度和经度值。
值是这样
I am trying to convert latitude and longitude values which are in degrees to double. the values are like this
"latitude":"25°21 N",
"longitude":"55°23 E"
当我尝试在Android中它是未来类似这样的记录本。
When i try to log this in android it is coming like this.
这是什么A ^
特殊字符那里。它是怎么来。此外,当我尝试保存日志
它像 25°21 N
What is this "A^"
special char there . How it came. Also when i try to save the log
it was like 25°21 N
如何度值转换为加倍纬度和经度?
How to convert the degree values to double for latitude and longitude ?
感谢
推荐答案
您当前例如,你要分析你的输入,一时间它被解析分配到该公式。
for your current example, you have to parse your input, one time it is parsed assign to that formula.
解析输入
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;
这篇关于转换纬度和经度值(度)双。 Java的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文