我有一个具有数百万个位置的MYSQL表,其结构如下:

id  latitude    longitude
1240451 6.893   79.85412
1240450 6.932   79.85005
1240448 7.082   79.89186
1240449 6.932   79.86133


我还有另一个表记录了旅程的起点和终点,其结构如下:

id  jrny_startlat   jrny_startllong jrny_endlat jrny_endlong
17  6.81462565  79.88666117 6.80900081  79.91052210


基本上,我必须通过与位置表进行比较来使用行程起点纬度和行程终点纬度来找到可能的路径。

最佳答案

在此处-How does Google Maps and Nokia Maps generate routes from point to point-或在Wikipedia页面http://en.wikipedia.org/wiki/Pathfinding上描述了众所周知的算法。然后,您可能想研究A *(A星)算法,或者(如果您要在同一组数据上求解许多路径)研究收缩层次结构:http://en.wikipedia.org/wiki/Contraction_hierarchies

关于php - 在坐标数组中找到最接近的坐标,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/23591570/

10-11 15:00