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 function distance(lat1 real, lng1 real, lat2 real, lng2 real) returns real no sql | |
| return ATAN2(SQRT(POW(COS(RADIANS(lat2)) * SIN(RADIANS(lng1 - lng2)), 2) + | |
| POW(COS(RADIANS(lat1)) * SIN(RADIANS(lat2)) - SIN(RADIANS(lat1)) * | |
| COS(RADIANS(lat2)) * COS(RADIANS(lng1 - lng2)), 2)), | |
| (SIN(RADIANS(lat1)) * SIN(RADIANS(lat2)) + COS(RADIANS(lat1)) * | |
| COS(RADIANS(lat2)) * COS(RADIANS(lng1 - lng2)))) * 6372.795; |