Quicker way to calculate geographic distance between two points

后端 未结 4 1542
醉酒成梦
醉酒成梦 2020-12-05 08:37

I borrowed the following method from somewhere on the internet (Can\'t remember where). But its doing a straight forward process, finding the distance between two gps points

4条回答
  •  天命终不由人
    2020-12-05 09:08

    That's the haversine algorithm, will provide you with a decent level of accuracy.

    If it really is "millions" of points, perhaps implement a cache of calculations that you've made... if you come across a pair of coordinates, both of which are sufficiently close to a pair whose distance you've already calculated, then use the cached value?

    Or try to cache some of the intermediate steps, e.g. degree to radians conversions.

提交回复
热议问题