-
-
Save manidip/add22b6a7fcd6e881924b8a0cc1b2ac9 to your computer and use it in GitHub Desktop.
This is a MySQL function that will calculate the distance between two latitude and longitude points
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
| DELIMITER ;; | |
| /*!50003 CREATE*/ /*!50020 DEFINER=`foobar`@`localhost`*/ /*!50003 FUNCTION `distance`( lat1 DOUBLE, lon1 DOUBLE, lat2 DOUBLE, lon2 DOUBLE ) RETURNS DOUBLE | |
| DETERMINISTIC | |
| BEGIN | |
| RETURN 3956 * 2 * ASIN(SQRT(POWER(SIN((lat1 - lat2) * pi()/180 / 2), 2) + COS(lat1 * pi()/180) * COS(lat2 * pi()/180) * POWER(SIN((lon1 - lon2) * pi()/180 / 2), 2))); | |
| END */;; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment