Tweaks to json output / webmap handling of new fields (untested)

This commit is contained in:
Oliver Jowett 2018-03-08 17:34:34 +00:00
parent d8f568e0ce
commit 213d769bf9
4 changed files with 62 additions and 25 deletions

View file

@ -1304,10 +1304,10 @@ char *generateAircraftJson(const char *url_path, int *len) {
if (trackDataValid(&a->callsign_valid))
p = safe_snprintf(p, end, ",\"flight\":\"%s\"", jsonEscapeString(a->callsign));
if (trackDataValid(&a->airground_valid) && a->airground_valid.source >= SOURCE_MODE_S_CHECKED && a->airground == AG_GROUND)
p = safe_snprintf(p, end, ",\"altitude\":\"ground\"");
p = safe_snprintf(p, end, ",\"alt_baro\":\"ground\"");
else {
if (trackDataValid(&a->altitude_baro_valid))
p = safe_snprintf(p, end, ",\"altitude\":%d", a->altitude_baro);
p = safe_snprintf(p, end, ",\"alt_baro\":%d", a->altitude_baro);
if (trackDataValid(&a->altitude_geom_valid))
p = safe_snprintf(p, end, ",\"alt_geom\":%d", a->altitude_geom);
}

View file

@ -106,7 +106,7 @@
Groundspeed:
</div>
<div class="infoData infoRowFluid fourColumnSection4">
<span id="selected_speed">n/a</span>
<span id="selected_gs">n/a</span>
</div>
</div>
<div>
@ -211,15 +211,15 @@
<div class="infoBlockSection">
<div>
<div class="infoHeading infoRowFluid fourColumnSection1">AP alt:</div>
<div class="infoData infoRowFluid fourColumnSection2"><span id="selected_intent_alt"/></div>
<div class="infoHeading infoRowFluid fourColumnSection3">AP heading:</div>
<div class="infoData infoRowFluid fourColumnSection4"><span id="selected_intent_heading"/></div>
<div class="infoHeading infoRowFluid fourColumnSection1">Nav alt:</div>
<div class="infoData infoRowFluid fourColumnSection2"><span id="selected_nav_alt"/></div>
<div class="infoHeading infoRowFluid fourColumnSection3">Nav heading:</div>
<div class="infoData infoRowFluid fourColumnSection4"><span id="selected_nav_heading"/></div>
</div>
<div>
<div class="infoHeading infoRowFluid fourColumnSection1">AP modes:</div>
<div class="infoData infoRowFluid fourColumnSection2"><span id="selected_intent_modes"/></div>
<div class="infoHeading infoRowFluid fourColumnSection3">Alt setting:</div>
<div class="infoHeading infoRowFluid fourColumnSection1">Nav modes:</div>
<div class="infoData infoRowFluid fourColumnSection2"><span id="selected_nav_modes"/></div>
<div class="infoHeading infoRowFluid fourColumnSection3">Nav QNH:</div>
<div class="infoData infoRowFluid fourColumnSection4"><span id="selected_alt_setting"/></div>
</div>
</div>

View file

@ -11,22 +11,29 @@ function PlaneObject(icao) {
// Basic location information
this.altitude = null;
this.alt_baro = null;
this.alt_geom = null;
this.speed = null;
this.gs = null;
this.ias = null;
this.tas = null;
this.track = null;
this.track_rate = null;
this.mag_heading = null;
this.true_heading = null;
this.mach = null;
this.roll = null;
this.intent_alt = null;
this.intent_heading = null;
this.intent_modes = null;
this.alt_setting = null;
this.nav_alt = null;
this.nav_heading = null;
this.nav_modes = null;
this.nav_qnh = null;
this.baro_rate = null;
this.geom_rate = null;
this.vert_rate = null;
this.version = null;
this.prev_position = null;
@ -429,10 +436,10 @@ PlaneObject.prototype.updateData = function(receiver_timestamp, data) {
// simple fields
var fields = ["altitude", "alt_geom", "gs", "ias", "tas", "track",
var fields = ["alt_baro", "alt_geom", "gs", "ias", "tas", "track",
"track_rate", "mag_heading", "true_heading", "mach",
"roll", "intent_alt", "intent_heading", "intent_modes",
"alt_setting", "baro_rate", "geom_rate",
"roll", "nav_altitude", "nav_heading", "nav_modes",
"nav_qnh", "baro_rate", "geom_rate",
"squawk", "category", "version"];
for (var i = 0; i < fields.length; ++i) {
@ -473,6 +480,36 @@ PlaneObject.prototype.updateData = function(receiver_timestamp, data) {
}
}
}
// Pick an altitude
if ('alt_baro' in data) {
this.altitude = data.alt_baro;
} else if ('alt_geom' in data) {
this.altitude = data.alt_geom;
} else {
this.altitude = null;
}
// Pick vertical rate from either baro or geom rate
// geometric rate is generally more reliable (smoothed etc)
if ('geom_rate' in data) {
this.vert_rate = data.geom_rate;
} else if ('baro_rate' in data) {
this.vert_rate = data.baro_rate;
} else {
this.vert_rate = null;
}
// Pick a speed
if ('gs' in data) {
this.speed = data.gs;
} else if ('tas' in data) {
this.speed = data.tas;
} else if ('ias' in data) {
this.speed = data.ias;
} else {
this.speed = null;
}
};
PlaneObject.prototype.updateTick = function(receiver_timestamp, last_timestamp) {

View file

@ -872,7 +872,7 @@ function refreshSelected() {
// emerg.className = 'hidden';
// }
$("#selected_altitude").text(format_altitude_long(selected.altitude, selected.baro_rate, DisplayUnits));
$("#selected_altitude").text(format_altitude_long(selected.altitude, selected.vert_rate, DisplayUnits));
if (selected.squawk === null || selected.squawk === '0000') {
$('#selected_squawk').text('n/a');
@ -880,8 +880,8 @@ function refreshSelected() {
$('#selected_squawk').text(selected.squawk);
}
$('#selected_speed').text(format_speed_long(selected.gs, DisplayUnits));
$('#selected_vertical_rate').text(format_vert_rate_long(selected.baro_rate, DisplayUnits));
$('#selected_gs').text(format_speed_long(selected.gs, DisplayUnits));
$('#selected_vertical_rate').text(format_vert_rate_long(selected.vert_rate, DisplayUnits));
$('#selected_icao').text(selected.icao.toUpperCase());
$('#airframes_post_icao').attr('value',selected.icao);
$('#selected_track').text(format_track_long(selected.track));
@ -1010,9 +1010,9 @@ function refreshHighlighted() {
}
$('#highlighted_speed').text(format_speed_long(highlighted.gs, DisplayUnits));
$('#highlighted_speed').text(format_speed_long(highlighted.speed, DisplayUnits));
$("#highlighted_altitude").text(format_altitude_long(highlighted.altitude, highlighted.baro_rate, DisplayUnits));
$("#highlighted_altitude").text(format_altitude_long(highlighted.altitude, highlighted.vert_rate, DisplayUnits));
$('#highlighted_icao').text(highlighted.icao.toUpperCase());
@ -1081,9 +1081,9 @@ function refreshTableInfo() {
tableplane.tr.cells[3].textContent = (tableplane.registration !== null ? tableplane.registration : "");
tableplane.tr.cells[4].textContent = (tableplane.icaotype !== null ? tableplane.icaotype : "");
tableplane.tr.cells[5].textContent = (tableplane.squawk !== null ? tableplane.squawk : "");
tableplane.tr.cells[6].innerHTML = format_altitude_brief(tableplane.altitude, tableplane.baro_rate, DisplayUnits);
tableplane.tr.cells[6].innerHTML = format_altitude_brief(tableplane.altitude, tableplane.vert_rate, DisplayUnits);
tableplane.tr.cells[7].textContent = format_speed_brief(tableplane.gs, DisplayUnits);
tableplane.tr.cells[8].textContent = format_vert_rate_brief(tableplane.baro_rate, DisplayUnits);
tableplane.tr.cells[8].textContent = format_vert_rate_brief(tableplane.vert_rate, DisplayUnits);
tableplane.tr.cells[9].textContent = format_distance_brief(tableplane.sitedist, DisplayUnits);
tableplane.tr.cells[10].textContent = format_track_brief(tableplane.track);
tableplane.tr.cells[11].textContent = tableplane.messages;
@ -1134,7 +1134,7 @@ function sortByAircraftType() { sortBy('icaotype', compareAlpha, func
function sortBySquawk() { sortBy('squawk', compareAlpha, function(x) { return x.squawk; }); }
function sortByAltitude() { sortBy('altitude',compareNumeric, function(x) { return (x.altitude == "ground" ? -1e9 : x.altitude); }); }
function sortBySpeed() { sortBy('speed', compareNumeric, function(x) { return x.gs; }); }
function sortByVerticalRate() { sortBy('vert_rate', compareNumeric, function(x) { return x.baro_rate; }); }
function sortByVerticalRate() { sortBy('vert_rate', compareNumeric, function(x) { return x.vert_rate; }); }
function sortByDistance() { sortBy('sitedist',compareNumeric, function(x) { return x.sitedist; }); }
function sortByTrack() { sortBy('track', compareNumeric, function(x) { return x.track; }); }
function sortByMsgs() { sortBy('msgs', compareNumeric, function(x) { return x.messages; }); }