Closed dchecheb closed 2 years ago
CREATE OR REPLACE FUNCTION GET_DISTANCE(
centralLatitude IN numeric,
centralLongitude IN numeric,
itemLatitude IN numeric,
itemLongitude IN numeric
)
RETURNS numeric AS
$$
BEGIN
RETURN (6371 * acos(cos(radians(centralLatitude))
* cos(radians(itemLatitude)) * cos(radians(itemLongitude) - radians(centralLongitude))
+ sin(radians(centralLatitude)) * sin(radians(itemLatitude))));
END; $$
LANGUAGE PLPGSQL;