开发者

Calculating route length using lat/lon from mysql

I have a table which has complete route co-ordinates (lat/lon). The data is of every 0.5 meters. I want to calculate distance between every two points and put the result in distance column of mysql table:

Lat            lon             Distance 
12.9994     77.66645    0
12.9874     77.76888    0.5
12.8977     77.88404    1.0
12.7899     11.87999    1.5

I have written a function in php to calculate like GetDist($lat1,$lon1,$lat2,$lon2), but the issue is every time $lat1,开发者_开发知识库$lon1,$lat2,$lon2 has to be fetched from mysql and after coming out of the function $lat1 should be updated with $lat2 and $lon1 should be updated with $lon2 and $lat2/$lon2 should acquire new data from Mysql.

Can anyone help me on how to I do this?

Thanks


For calculating the distance of your dataset given one point, you can look at Fastest Way to Find Distance Between Two Lat/Long Points.

Then you can calculate the distance "between every two points" in a loop, taking each row's lat and lng parameter as query.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜