且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

两个GEO位置之间的距离

更新时间:2023-02-01 23:12:48

GPS坐标是WGS84球体上的地理坐标。在这个模型下,Vincenty的公式给出了亚毫米精度的结果。对于大多数应用来说,这可能是过度杀伤或实际欺骗,因为地球的表面没有被WGS84建模到那个等级。

GPS coordinates are geographical coordinates on the WGS84 spheroid. Under this model, Vincenty's formulae gives results of sub-millimeter accuracy. For most applications, that's either overkill or actually deceptive, as the earth's surface is not modelled by WGS84 to that scale.

你可以比较各种距离计算方法的准确性 此页 断开的链接;请查看源代码而不是)。正如您所看到的,球形和差分近似(后者使用具有正确局部度量的毕达哥拉斯定理)在很多情况下都是不准确的。

You can compare the accurracy of various methods of distance computation on this page (broken link; check the source code instead). As you can see, the spherical and the differential approximations (the latter uses the Pythagorean theorem with the correct local metric) are inaccurate for a lot of cases.

其余的方法,第一个使用球体的平均半径从地理纬度转换为地心纬度,而第二个使用余弦规则在小距离的情况下获得更准确的结果(其中'小'的定义主要取决于(纬度差异)。

Of the remaining methods, the first one uses the spheroid's mean radius to convert from geographical to geocentrical latitude, whereas the second one uses the cosine rule to get more accurate results in case of 'small' distances (where the definition of 'small' mainly depends on the difference in latitude).

仅包含这两种方法的单独脚本可以在这里找到,它提供了一个名为 distance()的函数,并期望有四个参数:两个纬度,经度差(全部以弧度表示)和一个布尔标志,表示距离是否为小。

A seperate script containing only these two methods can be found here, which provides a function called distance() and expecting four arguments: the two latitudes, the difference in longitude (all in radians) and a boolean flag indicating whether the distance is 'small'.