summaryrefslogtreecommitdiff
path: root/dashboard_website/static/js/utils.js
diff options
context:
space:
mode:
authorAnson Bridges <bridges.anson@gmail.com>2023-11-07 03:38:00 -0500
committerAnson Bridges <bridges.anson@gmail.com>2023-11-07 03:38:00 -0500
commit2cae9c97591b626d4af31739ae0036f0a015122d (patch)
tree995833077273487854960b5078bf7dcb9ecd48d3 /dashboard_website/static/js/utils.js
parent9093ffdb4f8fcb16e593c9c0ba3ca9f0e68631b7 (diff)
bike display, animation, add clue UX
Diffstat (limited to 'dashboard_website/static/js/utils.js')
-rw-r--r--dashboard_website/static/js/utils.js18
1 files changed, 18 insertions, 0 deletions
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