Clean up js-side data capture, fix naming on ground track / speed.

This commit is contained in:
Oliver Jowett 2017-06-16 10:39:57 +01:00
parent 382554a250
commit 8a52108d77
2 changed files with 22 additions and 45 deletions

View file

@ -103,7 +103,7 @@
<span id="selected_squawk"></span> <span id="selected_squawk"></span>
</div> </div>
<div class="infoHeading infoRowFluid fourColumnSection3"> <div class="infoHeading infoRowFluid fourColumnSection3">
Speed: Groundspeed:
</div> </div>
<div class="infoData infoRowFluid fourColumnSection4"> <div class="infoData infoRowFluid fourColumnSection4">
<span id="selected_speed">n/a</span> <span id="selected_speed">n/a</span>
@ -127,7 +127,7 @@
<div class="infoBlockSection lightGreyBackground"> <div class="infoBlockSection lightGreyBackground">
<div> <div>
<div class="infoHeading infoRowFluid fourColumnSection1"> <div class="infoHeading infoRowFluid fourColumnSection1">
Heading: Ground track:
</div> </div>
<div class="infoData infoRowFluid fourColumnSection2"> <div class="infoData infoRowFluid fourColumnSection2">
<span id="selected_track">n/a</span> <span id="selected_track">n/a</span>

View file

@ -426,53 +426,30 @@ PlaneObject.prototype.updateData = function(receiver_timestamp, data) {
this.rssi = data.rssi; this.rssi = data.rssi;
this.last_message_time = receiver_timestamp - data.seen; this.last_message_time = receiver_timestamp - data.seen;
if (typeof data.type !== "undefined") // simple fields
var fields = ["altitude", "alt_geom", "gs", "ias", "tas", "track",
"track_rate", "mag_heading", "true_heading", "mach",
"roll", "intent_alt", "intent_heading",
"alt_setting", "baro_rate", "geom_rate", "flight",
"squawk", "category", "version"];
for (var i = 0; i < fields.length; ++i) {
if (fields[i] in data) {
this[fields[i]] = data[fields[i]];
} else {
this[fields[i]] = null;
}
}
// fields with more complex behaviour
if ('type' in data)
this.addrtype = data.type; this.addrtype = data.type;
else else
this.addrtype = 'adsb_icao'; this.addrtype = 'adsb_icao';
if (typeof data.altitude !== "undefined") if ('lat' in data && 'lon' in data) {
this.altitude = data.altitude;
if (typeof data.alt_geom !== "undefined")
this.alt_geom = data.alt_geom;
if (typeof data.gs !== "undefined")
this.gs = data.gs;
if (typeof data.ias !== "undefined")
this.ias = data.ias;
if (typeof data.tas !== "undefined")
this.tas = data.tas;
if (typeof data.track !== "undefined")
this.track = data.track;
if (typeof data.track_rate !== "undefined")
this.track_rate = data.track_rate;
if (typeof data.mag_heading !== "undefined")
this.mag_heading = data.mag_heading;
if (typeof data.true_heading !== "undefined")
this.true_heading = data.true_heading;
if (typeof data.mach !== "undefined")
this.mach = data.mach;
if (typeof data.roll !== "undefined")
this.roll = data.roll;
if (typeof data.intent_alt !== "undefined")
this.intent_alt = data.intent_alt;
if (typeof data.intent_heading !== "undefined")
this.intent_heading = data.intent_heading;
if (typeof data.alt_setting !== "undefined")
this.alt_setting = data.alt_setting;
if (typeof data.baro_rate !== "undefined")
this.baro_rate = data.baro_rate;
if (typeof data.geom_rate !== "undefined")
this.geom_rate = data.geom_rate;
if (typeof data.flight !== "undefined")
this.flight = data.flight;
if (typeof data.squawk !== "undefined")
this.squawk = data.squawk;
if (typeof data.category !== "undefined")
this.category = data.category;
if (typeof data.version !== "undefined")
this.version = data.version;
if (typeof data.lat !== "undefined") {
this.position = [data.lon, data.lat]; this.position = [data.lon, data.lat];
this.last_position_time = receiver_timestamp - data.seen_pos; this.last_position_time = receiver_timestamp - data.seen_pos;