コード例 #1
0
 def distance(lat1, lon1, lat2, lon2, R=3959):
     # http://andrew.hedges.name/experiments/haversine/
     dlon = radians(lon2 - lon1)
     dlat = radians(lat2 - lat1)
     a = sin(dlat / 2.0) ** 2 + cos(lat1) * cos(lat2) * sin(dlon / 2.0) ** 2
     return R * 2 * atan2(sqrt(a), sqrt(1 - a))
コード例 #2
0
 def distance(lat1, lon1, lat2, lon2, R=3959):
     # http://andrew.hedges.name/experiments/haversine/
     dlon = radians(lon2 - lon1)
     dlat = radians(lat2 - lat1)
     a = sin(dlat / 2.0) ** 2 + cos(lat1) * cos(lat2) * sin(dlon / 2.0) ** 2
     return R * 2 * atan2(sqrt(a), sqrt(1 - a))