diff --git a/webassets/css/style.css b/webassets/css/style.css index 89d5f00..cebe765 100644 --- a/webassets/css/style.css +++ b/webassets/css/style.css @@ -102,7 +102,7 @@ span.freq-hz { font-size: 0.8em; } -span.mode-q { +span.mode-q, span.bearing-q { padding-left: 0.5em; font-size: 0.7em; color: lightgray; diff --git a/webassets/js/common.js b/webassets/js/common.js index 8c0312d..79484fb 100644 --- a/webassets/js/common.js +++ b/webassets/js/common.js @@ -109,6 +109,21 @@ function columnsUpdated() { saveSettings(); } +// Calculate great circle bearing between two lat/lon points. +function calcBearing(lat1, lon1, lat2, lon2) { + lat1 *= Math.PI / 180; + lon1 *= Math.PI / 180; + lat2 *= Math.PI / 180; + lon2 *= Math.PI / 180; + var lonDelta = lon2 - lon1; + var y = Math.sin(lonDelta) * Math.cos(lat2); + var x = Math.cos(lat1) * Math.sin(lat2) - Math.sin(lat1) * Math.cos(lat2) * Math.cos(lonDelta); + var bearing = Math.atan2(y, x); + bearing = bearing * (180 / Math.PI); + if ( bearing < 0 ) { bearing += 360; } + return bearing; +} + // Convert a Maidenhead grid reference of arbitrary precision to the lat/long of the centre point of the square. // Returns null if the grid format is invalid. function latLonForGridCentre(grid) { diff --git a/webassets/js/spots.js b/webassets/js/spots.js index 22e8bf5..bff15f0 100644 --- a/webassets/js/spots.js +++ b/webassets/js/spots.js @@ -65,6 +65,9 @@ function updateTable() { if (showComment) { table.find('thead tr').append(`