开发者

Calculating route length using lat/lon from mysql

开发者 https://www.devze.com 2023-02-13 21:23 出处:网络
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 ta

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

精彩评论

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