是否可以输入六十进制的纬度和经度
我想弄清楚你是否可以给出一个六十进制输入作为一个位置,就像你可以在android中给出一个十进制输入一样:
// Decimal input
double src_lat = 46.550952;
double src_long = 15.651366;
GeoPoint srcGeoPoint = new GeoPoint((int) (src_lat * 1E6),
(int) (src_long * 1E6));
所以我的问题如下 - 有没有办法输入六十进制 数字而不是十进制? 我的数据库中有六十进制数字,格式为“46.550952、15.651366 等”。 但是当我以小数形式输入它们时,它显然给了我在 Google 地图上的错误位置,这是一个问题。
如果有任何答案或发现,我将非常感激。
--- 编辑 ---
我刚刚放弃并创建了一个将六十进制转换为十进制的函数 =) 由于我得到的所有字符串(数字)都是 10 个字符长,我可以简单地对分钟进行子串并秒。
代码如下:
private double turnSexagesimalToDecimal(String number) {
double sumDivMinutes = 0;
String degree = number;
String degrees = degree.substring(0, 2);
String minutes = degree.substring(3, 5);
String second1 = degree.substring(5, 7);
String second2 = degree.substring(7);
String seconds = second1 + "." + second2;
double divideSeconds = Double.parseDouble(seconds) / 60;
sumDivMinutes = (Double.parseDouble(minutes) + divideSeconds) / 60;
sumDivMinutes = (double)Math.round(sumDivMinutes * 1000000) / 1000000;
sumDivMinutes = sumDivMinutes + Double.parseDouble(degrees);
return sumDivMinutes;
}
i am trying to figure out if you can give a sexagesimal input as a location , just like you can give a decimal input in android like this:
// Decimal input
double src_lat = 46.550952;
double src_long = 15.651366;
GeoPoint srcGeoPoint = new GeoPoint((int) (src_lat * 1E6),
(int) (src_long * 1E6));
so my question is as follows - is there a way to enter sexagesimal numbers and not decimal?
I have sexagesimal numbers in my database, in the form of "46.550952, 15.651366, etc."
but when i enter them as decimals it obviously gives me the wrong location on Google Maps , which is a problem.
I would be really gratefull for any answers or findings.
--- EDIT ---
I just gave up and made a function that turns sexagesimal into decimal =) Since all of the strings (numbers) i get are 10 chars long i can simply substring the minutes and seconds.
the code is below:
private double turnSexagesimalToDecimal(String number) {
double sumDivMinutes = 0;
String degree = number;
String degrees = degree.substring(0, 2);
String minutes = degree.substring(3, 5);
String second1 = degree.substring(5, 7);
String second2 = degree.substring(7);
String seconds = second1 + "." + second2;
double divideSeconds = Double.parseDouble(seconds) / 60;
sumDivMinutes = (Double.parseDouble(minutes) + divideSeconds) / 60;
sumDivMinutes = (double)Math.round(sumDivMinutes * 1000000) / 1000000;
sumDivMinutes = sumDivMinutes + Double.parseDouble(degrees);
return sumDivMinutes;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为什么不写一个函数来在两者之间进行转换呢?
why not just write a function to convert between the two?