Skip to content

🗺 Calculate the Haversine distance between two coordinate pairs.

License

Notifications You must be signed in to change notification settings

kiliankoe/Haversine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Haversine

Calculate the Haversine distance between two coordinate pairs. This does not take into account the fact that the Earth is not a perfect sphere, but it's close enough for some applications. Use CoreLocation's distance API for better results.

let dresden = Coordinate(latitude: 51.0767496, longitude: 13.6321621)
let valencia = Coordinate(latitude: 39.4077641, longitude: -0.4317223)

let distance = dresden.distance(from: valencia)
// This is off by ~450m according to CoreLocation, which is roughly 0.03%.

About

🗺 Calculate the Haversine distance between two coordinate pairs.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages