SQL/개념
[TIL] MySQL에서 위도-경도 거리 계산하기
소금깨
2022. 6. 9. 01:10
1. 하버사인 공식
SELECT 컬럼,
( 2 * 6371 * asin(sqrt(pow(sin((radians(lat) - radians(source_lat)) / 2 ), 2) +
cos (radians (lat)) * cos(radians(source_lat)) *
pow(sin((radians(lng) - radians(source_lat)) / 2), 2))) AS distance
FROM location
2. 구면 코사인 공식
SELECT 컬럼,
(
6371 * acos (
cos ( radians(source_lat) )
* cos( radians( lat ) )
* cos( radians( lng ) - radians(source_lon) )
+ sin ( radians(source_lat) )
* sin( radians( lat ) )
)
) AS distance
FROM locations;
MySQL에서 위도,경도 활용하여 거리 계산하기
순서 거리 계산 하기 하버사인 공식 MySQL 하버사인 공식 적용 (내용이 궁금하지 않으면, 바로 3번으로!) 1. 거리 계산하기 사실 이 내용에 대해서는 상당히 많은 부분의 설명이 필요하다. 위도와
itseminar.tistory.com