Finding the Distance Between Two Points Using Latitude and Longitude in Degree Minutes Seconds Format

I am working on a tool to find the distance between two points whose latitude and longitude are given. Its good when latitude and longitude are set in Signed Degree Format . But I could not find a way to calculate the distance when the latitude and longitude are indicated in the format Degree of second seconds (for example: N 11 ° 14 '52'). Can anyone suggest me a way to find the distance?

+4
source share
1 answer

So, first convert the DMS coordinates to your degree format.

eg. 11°14'52" = 11 + 14/60 + 52/3600 = 11.24777778 degrees

and then continue, as you did, with your calculation, which, as you say, is already working.


Edit: Note that latitudes in the southern hemisphere and longitudes in the western hemisphere are negative. Therefore, the above formula should really be:

sign(degrees) * (abs(degrees) + minutes/60 + seconds/3600)

+1
source

Source: https://habr.com/ru/post/1469176/


All Articles