我试图找到两个lat长对之间的时差ad距离。
我收到一些记录的时间值不正确
SELECT A.ID, A.latitude, A.longitude, A.drive_time, (B.drive_time - A.drive_time) AS time_difference, 6367 * acos( cos(
radians(A.latitude) )
* cos( radians(B.latitude) )
* cos( radians(B.longitude) - radians(A.longitude)) + sin(radians(A.latitude))
* sin( radians(B.latitude) ) as distance
FROM mapper A INNER JOIN mapper B ON B.ID = (A.ID + 1);
答案 0 :(得分:0)
别介意我找到了解决办法。
SELECT A.ID, A.latitude, A.longitude, B.drive_time, 6371000 * 2 * ASIN(SQRT(
POWER(SIN((A.latitude - abs(B.latitude)) * pi()/180 / 2),
2) + COS(A.latitude * pi()/180 ) * COS(abs(B.latitude) *
pi()/180) * POWER(SIN((A.longitude - B.longitude) *
pi()/180 / 2), 2) )) as distance ,time_to_sec(TIMEDIFF(B.drive_time,A.drive_time)) AS time_difference
FROM mapper A left JOIN mapper B ON B.ID = A.ID + 1