1const R = 6371e3; // metres
2const φ1 = lat1 * Math.PI/180; // φ, λ in radians
3const φ2 = lat2 * Math.PI/180;
4const Δφ = (lat2-lat1) * Math.PI/180;
5const Δλ = (lon2-lon1) * Math.PI/180;
6
7const a = Math.sin(Δφ/2) * Math.sin(Δφ/2) +
8 Math.cos(φ1) * Math.cos(φ2) *
9 Math.sin(Δλ/2) * Math.sin(Δλ/2);
10const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
11
12const d = R * c; // in metres
1from math import cos, sqrt
2def qick_distance(Lat1, Long1, Lat2, Long2):
3 x = Lat2 - Lat1
4 y = (Long2 - Long1) * cos((Lat2 + Lat1)*0.00872664626)
5 return 111.319 * sqrt(x*x + y*y)
6