开发者

How to show GPS coordinates in a specific format?

开发者 https://www.devze.com 2023-02-28 18:57 出处:网络
I am trying to show the location coordinates in specific format like 42° 51’36.712032\" N, 112° 25’开发者_Python百科 45.069804\" W (example of geographical coordinates). How can i implement this.

I am trying to show the location coordinates in specific format like 42° 51’36.712032" N, 112° 25’开发者_Python百科 45.069804" W (example of geographical coordinates). How can i implement this.

Thanks in advance.


From Wikipedia:

Each degree of longitude is sub-divided into 60 minutes, each of which is divided into 60 seconds. A longitude is thus specified in sexagesimal notation as 23° 27′ 30" E. For higher precision, the seconds are specified with a decimal fraction.

Thus, take the fractional part of your coordinate and multiply it by 3600 (60×60) to get the total number of seconds; to convert that to the minutes/seconds that you want, take the total seconds mod 60 to get the actual seconds, subtract that number from the fractional part you got earlier, and then divide the result by 60 to get the number of minutes.

0

精彩评论

暂无评论...
验证码 换一张
取 消