Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Distance between two geospatial points in MySql
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
You can’t perform that action at this time.