How to show GPS coordinates in a specific format?
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.
精彩评论