Haversine vs等矩形近似 [英] Haversine vs Equirectangular approximation

查看:32
本文介绍了Haversine vs等矩形近似的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我需要计算两个点(经纬度对)之间的距离.我已经在可移动类型脚本中了解了Haversine公式和等距近似.

So, I need to calculate distances betweeen two points (lat-lon pairs). I've read about Haversine formula and Equirectangular approximation in Movable Type Scripts.

由于我只想计算短距离(小于4公里),所以等距矩形公式是一个很好的近似值吗?

Since I only want to calculate short distances (less than 4 KM), is the Equirectangular formula a good approximation?

此外,我已经在Google中了解了MySQL数据库中的lat-lon存储开发人员文档,他们实现了Haversine公式,如下所示:

Also, I've read about lat-lon storage in MySQL databases in Google Developers documentation and they implement the Haversine formula like this:

SELECT id, ( 3959 * acos( cos( radians(37) ) * cos( radians( lat ) ) * cos( radians( lng ) - radians(-122) ) + sin( radians(37) ) * sin( radians( lat ) ) ) ) AS distance FROM markers HAVING distance < 25 ORDER BY distance LIMIT 0 , 20;

我的最后一个问题是,在过滤sql查询中的点(如示例中)和通过代码过滤点之间,在性能上有什么大差异吗?

My last question is, is there any big performance differences between filtering the points in the sql query (as in the example) and filtering them by code?.

推荐答案

当我在更大的距离(英国境内1000公里)上测试Haversine v equirectangular时,差异约为0.1%.因此,对于4km或更短的距离,除非需要最大的精度,否则最好使用等角矩形作为速度.

When I tested haversine v equirectangular over much larger distances (1000km, within the UK), the difference was on the order of 0.1%. So for distances of 4km or less you might as well use equirectangular for speed unless you have a need for maximum accuracy.

这篇关于Haversine vs等矩形近似的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆