Last active
July 12, 2020 02:45
-
-
Save rodrigopolo/4bef2a0f3940e675006876373f1e0cb3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Meters: 6371000, Miles: 3959000 | |
DELIMITER $$ | |
DROP FUNCTION IF EXISTS `DISTANCE_BETWEEN` $$ | |
CREATE FUNCTION DISTANCE_BETWEEN ( | |
lat1 float(10,6), lon1 float(10,6), | |
lat2 float(10,6), lon2 float(10,6) | |
) RETURNS DOUBLE DETERMINISTIC | |
BEGIN | |
return ACOS(SIN(lat1*PI()/180)*SIN(lat2*PI()/180) | |
+ COS(lat1*PI()/180)*COS(lat2*PI()/180) | |
* COS(lon2*PI()/180-lon1*PI()/180)) | |
* 6371000; | |
END $$ | |
DELIMITER ; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment