我有一个包含数百万个位置的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 -- 或维基百科页面 http://en.wikipedia.org/wiki/Pathfinding其中描述了众所周知的算法。然后,您可能想研究 A*(A 星)算法,或者(如果您要在同一组数据上解决许多路线)研究收缩层次结构:http://en.wikipedia.org/wiki/Contraction_hierarchies
关于php - 查找坐标数组中最接近的坐标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23591570/