1GIS::Distance::VincentyU(s3eprm)Contributed Perl DocumenGtIaSt:i:oDnistance::Vincenty(3pm)
2
3
4
6 GIS::Distance::Vincenty - Thaddeus Vincenty distance calculations.
7
9 For the benefit of the terminally obsessive (as well as the genuinely
10 needy), Thaddeus Vincenty devised formulae for calculating geodesic
11 distances between a pair of latitude/longitude points on the earth's
12 surface, using an accurate ellipsoidal model of the earth.
13
14 Vincenty's formula is accurate to within 0.5mm, or 0.000015", on the
15 ellipsoid being used. Calculations based on a spherical model, such as
16 the (much simpler) Haversine, are accurate to around 0.3% (which is
17 still good enough for most purposes).
18
19 The accuracy quoted by Vincenty applies to the theoretical ellipsoid
20 being used, which will differ (to varying degree) from the real earth
21 geoid. If you happen to be located in Colorado, 2km above msl,
22 distances will be 0.03% greater. In the UK, if you measure the distance
23 from Land's End to John O' Groats using WGS-84, it will be 28m - 0.003%
24 - greater than using the Airy ellipsoid, which provides a better fit
25 for the UK.
26
27 Take a look at the GIS::Distance::ALT formula for a much quicker
28 alternative with nearly the same accuracy.
29
30 A faster (XS) version of this formula is available as
31 GIS::Distance::Fast::Vincenty.
32
33 Normally this module is not used directly. Instead GIS::Distance is
34 used which in turn interfaces with the various formula classes.
35
37 a, b = major & minor semiaxes of the ellipsoid
38 f = flattening (a-b)/a
39 L = lon2 - lon1
40 u1 = atan((1-f) * tan(lat1))
41 u2 = atan((1-f) * tan(lat2))
42 sin_u1 = sin(u1)
43 cos_u1 = cos(u1)
44 sin_u2 = sin(u2)
45 cos_u2 = cos(u2)
46 lambda = L
47 lambda_pi = 2PI
48 while abs(lambda-lambda_pi) > 1e-12
49 sin_lambda = sin(lambda)
50 cos_lambda = cos(lambda)
51 sin_sigma = sqrt((cos_u2 * sin_lambda) * (cos_u2*sin_lambda) +
52 (cos_u1*sin_u2-sin_u1*cos_u2*cos_lambda) * (cos_u1*sin_u2-sin_u1*cos_u2*cos_lambda))
53 cos_sigma = sin_u1*sin_u2 + cos_u1*cos_u2*cos_lambda
54 sigma = atan2(sin_sigma, cos_sigma)
55 alpha = asin(cos_u1 * cos_u2 * sin_lambda / sin_sigma)
56 cos_sq_alpha = cos(alpha) * cos(alpha)
57 cos2sigma_m = cos_sigma - 2*sin_u1*sin_u2/cos_sq_alpha
58 cc = f/16*cos_sq_alpha*(4+f*(4-3*cos_sq_alpha))
59 lambda_pi = lambda
60 lambda = L + (1-cc) * f * sin(alpha) *
61 (sigma + cc*sin_sigma*(cos2sigma_m+cc*cos_sigma*(-1+2*cos2sigma_m*cos2sigma_m)))
62 }
63 usq = cos_sq_alpha*(a*a-b*b)/(b*b);
64 aa = 1 + usq/16384*(4096+usq*(-768+usq*(320-175*usq)))
65 bb = usq/1024 * (256+usq*(-128+usq*(74-47*usq)))
66 delta_sigma = bb*sin_sigma*(cos2sigma_m+bb/4*(cos_sigma*(-1+2*cos2sigma_m*cos2sigma_m)-
67 bb/6*cos2sigma_m*(-3+4*sin_sigma*sin_sigma)*(-3+4*cos2sigma_m*cos2sigma_m)))
68 c = b*aa*(sigma-delta_sigma)
69
71 • <http://www.ngs.noaa.gov/PUBS_LIB/inverse.pdf>
72
73 • <http://www.movable-type.co.uk/scripts/LatLongVincenty.html>
74
76 See "SUPPORT" in GIS::Distance.
77
79 See "AUTHORS" in GIS::Distance.
80
82 See "LICENSE" in GIS::Distance.
83
84
85
86perl v5.38.0 2023-07-20 GIS::Distance::Vincenty(3pm)