[hamradio-commits] [dump1090] 232/389: Added distance to plane from site Just for fun. Distance is only shown if SiteShow is true in config.js-file.
Matthew Ernisse
mernisse-guest at moszumanska.debian.org
Wed Nov 5 00:19:58 UTC 2014
This is an automated email from the git hooks/post-receive script.
mernisse-guest pushed a commit to branch master
in repository dump1090.
commit ca314fcf2c8e5ef8a245f95887bad73c66070d4b
Author: terribl <terri at rannalla.net>
Date: Mon May 27 11:36:23 2013 +0300
Added distance to plane from site
Just for fun. Distance is only shown if SiteShow is true in config.js-file.
modified: public_html/script.js
---
public_html/script.js | 43 +++++++++++++++++++++++++++++++++++++++----
1 file changed, 39 insertions(+), 4 deletions(-)
diff --git a/public_html/script.js b/public_html/script.js
index 48288c8..d6048ba 100644
--- a/public_html/script.js
+++ b/public_html/script.js
@@ -267,12 +267,45 @@ function refreshSelected() {
html += '<tr><td colspan="' + columns + '" align="center">Lat/Long: ';
if (selected && selected.vPosition) {
- html += selected.latitude + ', ' + selected.longitude;
+ html += selected.latitude + ', ' + selected.longitude + '</td></tr>';
+
+ // Let's show some extra data if we have site coordinates
+ if (SiteShow) {
+ // Converts numeric degrees to radians
+ if (typeof Number.prototype.toRad == 'undefined') {
+ Number.prototype.toRad = function() {
+ return this * Math.PI / 180;
+ }
+ }
+
+ // Converts radians to numeric (signed) degrees
+ if (typeof Number.prototype.toDeg == 'undefined') {
+ Number.prototype.toDeg = function() {
+ return this * 180 / Math.PI;
+ }
+ }
+
+ // Calculate distance
+ var R = 6371; // km
+ var dLat = (selected.latitude-SiteLat).toRad();
+ var dLon = (selected.longitude-SiteLon).toRad();
+ var a = Math.sin(dLat/2) * Math.sin(dLat/2) +
+ Math.cos(SiteLat.toRad()) * Math.cos(selected.latitude.toRad()) *
+ Math.sin(dLon/2) * Math.sin(dLon/2);
+ var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
+ var dist = (R * c) / 1.852;
+ dist = (Math.round(dist*10)/10).toFixed(1);
+
+ html += '<tr><td colspan="' + columns + '">Distance from Site: ' + dist + ' NM</td></tr>';
+ } // End of SiteShow
} else {
- html += 'n/a';
+ if (SiteShow) {
+ html += '<tr><td colspan="' + columns + '">Distance from Site: n/a NM</td></tr>';
+ } else {
+ html += 'n/a</td></tr>';
+ }
}
- html += '</td></tr>';
-
+
html += '</table>';
document.getElementById('plane_detail').innerHTML = html;
@@ -489,4 +522,6 @@ function selectPlaneByHex(hex) {
} else {
SelectedPlane = null;
}
+ refreshSelected();
+ refreshTableInfo();
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-hamradio/dump1090.git
More information about the pkg-hamradio-commits
mailing list