假设我有两点:
var lat1 = 37.7833
var lon1 = -122.4167
var lat2 = 39.4811
var lon2 = -118.9558
如何计算它们之间的距离,最简单的方法? (考虑到地球的曲率)
我查看了this回答,但CCLocation
在Swift 2.0中没有初始化程序
答案 0 :(得分:5)
let coord1 = CLLocation(latitude: 37.7833, longitude: -122.4167)
let coord2 = CLLocation(latitude: 39.4811, longitude: -118.9558)
let distance = coord1.distance(from: coord2)
print("the distance between the two points is: \(distance) meters")
答案 1 :(得分:2)
我一直在使用它,对我来说非常适合: -
data TAL :: (k -> k -> *) -> k -> k -> * where
Nil :: TAL c x x
(:::) :: c x y -> TAL c y z -> TAL c x z