From d5e43b643f937f275862e9fad5f38fdebffd882f Mon Sep 17 00:00:00 2001 From: Matthias Wirth Date: Mon, 5 Aug 2019 12:32:28 +0200 Subject: [PATCH] don't delete old positions, it just creates a mess --- html/planeObject.js | 36 +++++++++++++++++++----------------- html/script.js | 6 +++++- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/html/planeObject.js b/html/planeObject.js index 67d0a85..d7d89b0 100644 --- a/html/planeObject.js +++ b/html/planeObject.js @@ -674,9 +674,7 @@ PlaneObject.prototype.updateTick = function(receiver_timestamp, last_timestamp, // If no packet in over 58 seconds, clear the plane. // Only clear the plane if it's not selected individually - if (this.seen_pos > 100 && (!this.selected || SelectedAllPlanes) ) - this.position = null; - if ((this.seen > 58 || this.position == null) + if ((this.seen > 58 || this.position == null || this.seen_pos > 100) && (!this.selected || SelectedAllPlanes)) { if (this.visible) { //console.log("hiding " + this.icao); @@ -789,6 +787,24 @@ PlaneObject.prototype.updateLines = function() { }) }); + // create any missing fixed line features + for (var i = 0; i < this.track_linesegs.length; ++i) { + var seg = this.track_linesegs[i]; + if (!seg.feature) { + seg.feature = new ol.Feature(seg.fixed); + if (seg.estimated) { + seg.feature.setStyle(estimateStyle); + } else { + seg.feature.setStyle(this.altitudeLines(seg.altitude)); + } + + PlaneTrailFeatures.push(seg.feature); + } + } + + if (!this.position) + return; + // find the old elastic band so we can replace it in place // (which should be faster than remove-and-add when PlaneTrailFeatures is large) var oldElastic = -1; @@ -813,20 +829,6 @@ PlaneObject.prototype.updateLines = function() { PlaneTrailFeatures.setAt(oldElastic, this.elastic_feature); } - // create any missing fixed line features - for (var i = 0; i < this.track_linesegs.length; ++i) { - var seg = this.track_linesegs[i]; - if (!seg.feature) { - seg.feature = new ol.Feature(seg.fixed); - if (seg.estimated) { - seg.feature.setStyle(estimateStyle); - } else { - seg.feature.setStyle(this.altitudeLines(seg.altitude)); - } - - PlaneTrailFeatures.push(seg.feature); - } - } }; PlaneObject.prototype.destroy = function() { diff --git a/html/script.js b/html/script.js index 3d8918d..b4cfaf6 100644 --- a/html/script.js +++ b/html/script.js @@ -569,8 +569,12 @@ function parse_history() { // Final pass to update all planes to their latest state console.log("Final history cleanup pass"); - for (var i = 0; i < PlanesOrdered.length; ++i) { + for (var i in PlanesOrdered) { var plane = PlanesOrdered[i]; + + if (plane.position && SitePosition) + plane.sitedist = ol.sphere.getDistance(SitePosition, plane.position); + if (plane.dataSource == "uat") plane.updateTick(uat_now, uat_last, true); else