Skip to content

Instantly share code, notes, and snippets.

@Kuzyashin
Created May 26, 2019 08:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kuzyashin/6346808619acbdfb26a17c2e2959b81a to your computer and use it in GitHub Desktop.
Save Kuzyashin/6346808619acbdfb26a17c2e2959b81a to your computer and use it in GitHub Desktop.
find_remoteness_btw_cords.sql
CREATE or REPLACE FUNCTION find_remoteness_btw_cords(lat1 double precision, lng1 double precision, lat2 double precision, lng2 double precision)
RETURNS double precision
LANGUAGE plpgsql AS $$
BEGIN
RETURN ACOS(SIN(PI()*lat1/180.0)*SIN(PI()*lat2/180.0)+COS(PI()*lat1/180.0)*COS(PI()*lat2/180.0)*COS(PI()*lng2/180.0-PI()*lng1/180.0))*6367000;
END;
$$;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment