1

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

Brad Mace
  • 27,194
  • 17
  • 102
  • 148

1 Answers1

0

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.

Community
  • 1
  • 1
TuteC
  • 4,342
  • 30
  • 40