英文:
Convert full location degree to java degree
问题
我可以获取一些位置度数,格式如下:
北 7°7'23.2716"
东 6°19'16.72428"
但是我不确定如何将其转换为在Java中表示度数的双精度值,除了我应该从字符串中提取度数、分钟和秒,并对它们进行处理。
英文:
I'm able to get some location degrees in a format like these:
N 7°7'23,2716"
E 6°19'16,72428"
But I'm not sure how I should convert it to the double value that represents a degree in java, apart from the fact that I should take the degree, the minutes and the seconds from my string and do something with them.
答案1
得分: 2
如@Berto99所说,将所有内容转换为秒。但您还需要添加度数。所以你有:
> 十进制度数 = 度数 + (分钟/60) + (秒/3600)
所以在你的示例中,N 7°7'23.2716",E 6°19'16.72428":
> N 7°7'23.2716" = 7度 + (7/60) + (23.2716/3600) = +7.123131
> E 6°19'16.72428" = 6度 + (19/60) + (16.72428/3600) = +6.3213123
注意减号 如果N变为S,或者E变为W,那么在小数前面加上减号。
英文:
As @Berto99 said, convert everything into seconds. But you also need to add the degrees. So you have:
> Decimal Degrees = degrees + (minutes/60) + (seconds/3600)
So in your examples, N 7°7'23,2716", E 6°19'16,72428"
> N 7°7'23,2716" = 7 degrees + (7/60) + (23.2716/3600) = +7.123131
> E 6°19'16,72428" = 6 degrees + (19/60) + (16.72428/3600) = +6.3213123
Beware of the minus sign If the N changes to an S, or the E changes to a W, then stick a minus sign in front of the decimal number.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论