Created
August 9, 2013 20:12
-
-
Save nicolasiensen/6196787 to your computer and use it in GitHub Desktop.
Distance between two geospatial points in MySql
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
SET @orig_lat = "50"; | |
SET @orig_lng = "5"; | |
SET @dest_lat = "45"; | |
SET @dest_lng = "30"; | |
SELECT 3956 * 2 * ASIN(SQRT( POWER(SIN((@orig_lat - @dest_lat) * pi()/180 / 2), 2) + COS(@orig_lat * pi()/180) * COS(@dest_lat * pi()/180) * POWER(SIN((@orig_lng - @dest_lng) * pi()/180 / 2), 2) )); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment