Created
May 26, 2019 08:09
-
-
Save Kuzyashin/6346808619acbdfb26a17c2e2959b81a to your computer and use it in GitHub Desktop.
find_remoteness_btw_cords.sql
This file contains 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 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