[SOLVED] Calculate distance between 2 latitude


i have 2 latitude obtain on this format:

let lat1 = 37.33756323
let lat2 = 37.33683958

now I need to calculate the distance between this 2 point.

converting this to hours, min and second I’m able to calculate the distance .. which result in around 0.08km considering that for 1 deg of lat = 60 NM

But how can I do it with swift.. is there any way to first convert this lat in hours, min and second? I can’t find the right way to "subtract" correctly this 2 angles.

any suggestion?

thanks a lot


from the code at: Calculate distance between 2 point on maps for iOS

import CoreLocation 

let lat1 = 37.33756323
let lat2 = 37.33683958

let coord0 = CLLocation(latitude: lat1, longitude: 0.0)
let coord1 = CLLocation(latitude: lat2, longitude: 0.0)
let d = coord0.distance(from: coord1)

print("\n----> d = \(d) (m) ")  // 80.31355191695503 meters
print("----> d = \(d/1000.0) (km) \n") // 0.08031355191695504 kilometers

Answered By – workingdog support Ukraine

Answer Checked By – Marilyn (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *