Merge branch 'altimeter-correction' of https://github.com/justin4046/tar1090

This commit is contained in:
Matthias Wirth
2024-05-04 15:22:25 +02:00
4 changed files with 55 additions and 4 deletions

View File

@@ -331,6 +331,7 @@ HideCols = [
// labelsGeom = false; // labels: uses geometric altitude (WGS84 ellipsoid unless geomUseEGM is enabled
// geomUseEGM = false; // use EGM96 for displaying geometric altitudes (extra load time!)
// baroUseQNH = false;
// windLabelsSlim = false;
// showLabelUnits = true;

View File

@@ -344,6 +344,7 @@ let showSil = false;
let labelsGeom = false; // labels: uses geometric altitude (WGS84 ellipsoid unless geomUseEGM is enabled
let geomUseEGM = false; // use EGM96 for displaying geometric altitudes (extra load time!)
let baroUseQNH = false;
let windLabelsSlim = false;
let showLabelUnits = true;

View File

@@ -297,7 +297,7 @@
</tr>
<tr>
<td>
<span class="infoHeading" title="The uncorrected pressure-derived height of the aircraft above mean sea level (based on barometric pressure)">Baro. Altitude</span>:
<span class="infoHeading" id="selected_altitude1_title" title="The uncorrected pressure-derived height of the aircraft above mean sea level (based on barometric pressure)">Baro. Altitude</span>:
<span class="infoData" id="selected_altitude1"></span>
</td>
</tr>
@@ -519,7 +519,7 @@
<div class="infoBlockSection">
<div>
<div class="infoHeading">
<span title="The uncorrected pressure-derived height of the aircraft above mean sea level (based on barometric pressure)">Barometric</span>:
<span id="selected_altitude2_title" title="The uncorrected pressure-derived height of the aircraft above mean sea level (based on barometric pressure)">Barometric</span>:
</div>
<div class="infoData">
<span id="selected_altitude2"></span>
@@ -901,6 +901,11 @@
<td id="dump1090_total_history_td"><span class="infoBlockTitleText">History:</span> <span id="dump1090_total_history">n/a</span> positions</td>
</tr>
</table>
<table style="width: 100%" id="infoblock_altimeter" class="hidden">
<tr>
<td><span class="infoBlockTitleText">Altimeter:<span> <span><input id="settings_altimeter" type="number" step="0.01" value="29.92">
</tr>
</table>
</td>
</tr>
</table>

View File

@@ -1247,6 +1247,28 @@ jQuery('#selected_altitude_geom1')
}
});
new Toggle({
key: "baroUseQNH",
display: "Baro. alt.: Standard pressure -> Pressure corrected",
container: "#settingsLeft",
init: baroUseQNH,
setState: function(state) {
baroUseQNH = state;
if (baroUseQNH) {
jQuery('#selected_altitude1_title').updateText('Baro. altitude');
jQuery('#selected_altitude2_title').updateText('Adjusted Barometric');
jQuery('#infoblock_altimeter').removeClass('hidden');
} else {
jQuery('#selected_altitude1_title').updateText('Baro. altitude');
jQuery('#selected_altitude2_title').updateText('Adjusted Barometric');
jQuery('#infoblock_altimeter').addClass('hidden');
}
if (loadFinished) {
remakeTrails();
refreshSelected();
}
}
});
if (usp.has('labelsGeom')) {
toggles['labelsGeom'].toggle(true, 'init');
@@ -3127,8 +3149,8 @@ function refreshSelected() {
}
jQuery("#selected_altitude1").updateText(format_altitude_long(selected.altitude, selected.vert_rate, DisplayUnits));
jQuery("#selected_altitude2").updateText(format_altitude_long(selected.altitude, selected.vert_rate, DisplayUnits));
jQuery("#selected_altitude1").updateText(format_altitude_long(adjust_baro_alt(selected.altitude), selected.vert_rate, DisplayUnits));
jQuery("#selected_altitude2").updateText(format_altitude_long(adjust_baro_alt(selected.altitude), selected.vert_rate, DisplayUnits));
jQuery('#selected_onground').updateText(format_onground(selected.altitude));
@@ -8434,6 +8456,28 @@ function getn(n) {
limitUpdates=n; RefreshInterval=0; fetchCalls=0;
}
function adjust_baro_alt(alt) {
if (baroUseQNH && alt != null) {
let altimeter = document.getElementById("settings_altimeter").value
if (altimeter < 100) {
return corrected_alt(alt, inhg_to_hpa(altimeter));
} else {
return corrected_alt(alt, altimeter);
}
} else {
return alt;
}
}
function corrected_alt(alt, qnh) {
let station_pressure = 29.92 * Math.pow( ( (288-0.0065*(0.3048 * alt)) / 288), 5.2561);
return ( 1 - Math.pow( (inhg_to_hpa(station_pressure) / qnh ), 0.190284) ) * 145366.45;
}
function inhg_to_hpa(inhg) {
return 33.8639 * inhg
}
function globeRateUpdate() {
if (adsbexchange) {
dynGlobeRate = true;