1234567891011121314151617 |
- module(..., package.seeall)
- PI = 3.14159265359
- ERadius = 6371.393
- function getDistance( lat1, lng1, lat2, lng2 )
- -- body
- local radLat1 = lat1 * (PI / 180)
- local radLat2 = lat2 * (PI / 180)
- local a = radLat1 - radLat2
- local b = (lng1 * (PI / 180)) - (lng2 * (PI / 180))
-
- local s = 2 * math.asin(math.sqrt(math.pow(math.sin(a/2),2) + math.cos(radLat1)*math.cos(radLat2)*math.pow(math.sin(b/2),2)))
- local s = s * ERadius
- local s = math.floor(s * 10000+0.5) / 10000
- return s
- end
|