Skip to content

Instantly share code, notes, and snippets.

@rockoil
Created October 24, 2018 01:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rockoil/cbf5eba9491daf66c0c3f4d83ccd83c1 to your computer and use it in GitHub Desktop.
Save rockoil/cbf5eba9491daf66c0c3f4d83ccd83c1 to your computer and use it in GitHub Desktop.
WGS84 두 좌표간의 거리 계산
# 두 좌표사의 거리를 반환하는 tibero(oracle) 함수
# 삼각함수를 이용하여 반환
# 반환단위는 km(킬로미터)
CREATE OR REPLACE FUNCTION RADIANS(V_DEGREES IN NUMBER)
RETURN NUMBER DETERMINISTIC
IS
BEGIN
/*
-- radians = degrees / (180 / pi)
-- RETURN nDegrees / (180 / ACOS(-1)); but 180/pi is a constant, so...
*/
RETURN V_DEGREES / 57.29577951308232087679815481410517033235;
END;
CREATE OR REPLACE FUNCTION DISTANCE_WGS84(H_LAT IN NUMBER, H_LOT IN NUMBER, T_LAT IN NUMBER, T_LOT IN NUMBER)
RETURN NUMBER DETERMINISTIC
IS
BEGIN
RETURN ( 6371.0 * ACOS(
LEAST(1,
COS( RADIANS(H_LAT) ) * COS( RADIANS(T_LAT) )
* COS(RADIANS(T_LOT) - RADIANS(H_LOT) )
+ SIN( RADIANS (H_LAT) ) * SIN(RADIANS( T_LAT) )
)
));
END;
참고 자료 https://tonyne.jeju.onl/2016/04/14/oracle-lat-lng-distnace-query/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment