From 02284958a1189ffcb10b34a4c3a02417f8136a4d Mon Sep 17 00:00:00 2001 From: Anson Bridges Date: Mon, 11 Aug 2025 22:24:05 -0700 Subject: Initialize git repo from local project files --- static/js/utils.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 static/js/utils.js (limited to 'static/js/utils.js') diff --git a/static/js/utils.js b/static/js/utils.js new file mode 100644 index 0000000..83e6397 --- /dev/null +++ b/static/js/utils.js @@ -0,0 +1,18 @@ +function deg2rad(deg) { + return deg * (Math.PI/180) +} +function getDistanceFromLatLon(item1, item2) { + lat1 = item1['latitude']; lon1 = item1['longitude']; + lat2 = item2['latitude']; lon2 = item2['longitude']; + var R = 3958.8; // Radius of the earth + var dLat = deg2rad(lat2-lat1); + var dLon = deg2rad(lon2-lon1); + var a = + Math.sin(dLat/2) * Math.sin(dLat/2) + + Math.cos(deg2rad(lat1)) * Math.cos(deg2rad(lat2)) * + Math.sin(dLon/2) * Math.sin(dLon/2) + ; + var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); + var d = R * c; // Distance in mi + return d; +} \ No newline at end of file -- cgit v1.2.3