From 213d769bf92041149c1539f25d9063a066f7bf6e Mon Sep 17 00:00:00 2001 From: Oliver Jowett Date: Thu, 8 Mar 2018 17:34:34 +0000 Subject: [PATCH] Tweaks to json output / webmap handling of new fields (untested) --- net_io.c | 4 +-- public_html/index.html | 16 ++++++------ public_html/planeObject.js | 51 ++++++++++++++++++++++++++++++++------ public_html/script.js | 16 ++++++------ 4 files changed, 62 insertions(+), 25 deletions(-) diff --git a/net_io.c b/net_io.c index f4a68fd..75e5db7 100644 --- a/net_io.c +++ b/net_io.c @@ -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); } diff --git a/public_html/index.html b/public_html/index.html index 2c60ce1..b8f656d 100644 --- a/public_html/index.html +++ b/public_html/index.html @@ -106,7 +106,7 @@ Groundspeed:
- n/a + n/a
@@ -211,15 +211,15 @@
-
AP alt:
-
-
AP heading:
-
+
Nav alt:
+
+
Nav heading:
+
-
AP modes:
-
-
Alt setting:
+
Nav modes:
+
+
Nav QNH:
diff --git a/public_html/planeObject.js b/public_html/planeObject.js index b24e9b3..c211f89 100644 --- a/public_html/planeObject.js +++ b/public_html/planeObject.js @@ -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) { diff --git a/public_html/script.js b/public_html/script.js index 2dea753..c7fb70e 100644 --- a/public_html/script.js +++ b/public_html/script.js @@ -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; }); }