From 2cae9c97591b626d4af31739ae0036f0a015122d Mon Sep 17 00:00:00 2001 From: Anson Bridges Date: Tue, 7 Nov 2023 03:38:00 -0500 Subject: bike display, animation, add clue UX --- dashboard_website/static/js/utils.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 dashboard_website/static/js/utils.js (limited to 'dashboard_website/static/js/utils.js') diff --git a/dashboard_website/static/js/utils.js b/dashboard_website/static/js/utils.js new file mode 100644 index 0000000..83e6397 --- /dev/null +++ b/dashboard_website/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