Last active
December 14, 2015 19:49
-
-
Save AustinW/5139274 to your computer and use it in GitHub Desktop.
Geo searching
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
CREATE DEFINER=`root`@`localhost` FUNCTION `geo_distance_miles`(in_lat decimal(10,6), in_lon decimal(10,6), latitude decimal(10,6), longitude decimal(10,6)) RETURNS decimal(10,3) | |
DETERMINISTIC | |
RETURN | |
( | |
( | |
ACOS( | |
SIN(in_lat * PI() / 180) * SIN(latitude * PI() / 180) + COS(in_lat * PI() / 180) * COS(latitude * PI() / 180) * COS((in_lon - longitude) * PI() / 180) | |
) * 180 / PI() | |
) * 60 * 1.1515 | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment