kiliankoe / Haversine

🗺 Calculate the Haversine distance between two coordinate pairs.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

License:MIT License


Languages

Language:Swift 100.0%