From e5053ac5c991385e2782ff844b585ddc02e50f38 Mon Sep 17 00:00:00 2001 From: Oliver Jowett Date: Mon, 29 Jun 2015 15:51:42 +0100 Subject: [PATCH] Only set/reset position_from_mlat when we actually see position data. Otherwise, if the position data times out on the dump1090 side, we'd keep the last seen position on the webpage side but lose the mlat status. --- public_html/planeObject.js | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/public_html/planeObject.js b/public_html/planeObject.js index df5b296..797c5af 100644 --- a/public_html/planeObject.js +++ b/public_html/planeObject.js @@ -13,6 +13,7 @@ function PlaneObject(icao) { this.speed = null; this.track = null; this.position = null; + this.position_from_mlat = false this.sitedist = null; // Data packet numbers @@ -290,6 +291,16 @@ PlaneObject.prototype.updateData = function(receiver_timestamp, data) { if (SitePosition !== null) { this.sitedist = google.maps.geometry.spherical.computeDistanceBetween (SitePosition, this.position); } + + this.position_from_mlat = false; + if (typeof data.mlat !== "undefined") { + for (var i = 0; i < data.mlat.length; ++i) { + if (data.mlat[i] === "lat" || data.mlat[i] == "lon") { + this.position_from_mlat = true; + break; + } + } + } } if (typeof data.flight !== "undefined") this.flight = data.flight; @@ -297,16 +308,6 @@ PlaneObject.prototype.updateData = function(receiver_timestamp, data) { this.squawk = data.squawk; if (typeof data.category !== "undefined") this.category = data.category; - - this.position_from_mlat = false - if (typeof data.mlat !== "undefined") { - for (var i = 0; i < data.mlat.length; ++i) { - if (data.mlat[i] === "lat" || data.mlat[i] == "lon") { - this.position_from_mlat = true; - break; - } - } - } }; PlaneObject.prototype.updateTick = function(receiver_timestamp, last_timestamp) {