Skip to content

Instantly share code, notes, and snippets.

@maximecolin
Created July 6, 2015 15:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maximecolin/4bcd5b7b755d727694c5 to your computer and use it in GitHub Desktop.
Save maximecolin/4bcd5b7b755d727694c5 to your computer and use it in GitHub Desktop.
CREATE OR REPLACE FUNCTION orthodromic_distance(point, point) RETURNS float AS $_$
SELECT acos(sin(radians($1[0])) * sin(radians($2[0])) + cos(radians($1[0])) * cos(radians($2[0])) * cos(radians($2[1]) - radians($1[1]))) * 6371.0;
$_$ LANGUAGE sql IMMUTABLE;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment