项目作者: kiliankoe

项目描述 :
🗺 Calculate the Haversine distance between two coordinate pairs.
高级语言: Swift
项目地址: git://github.com/kiliankoe/Haversine.git
创建时间: 2019-09-06T16:27:25Z
项目社区:https://github.com/kiliankoe/Haversine

开源协议:MIT License

下载


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.

  1. let dresden = Coordinate(latitude: 51.0767496, longitude: 13.6321621)
  2. let valencia = Coordinate(latitude: 39.4077641, longitude: -0.4317223)
  3. let distance = dresden.distance(from: valencia)
  4. // This is off by ~450m according to CoreLocation, which is roughly 0.03%.