From 7742c0ceaf2bdb7fe7b248d239d1da7f6f3498b2 Mon Sep 17 00:00:00 2001 From: Matthias Wirth Date: Tue, 2 Aug 2022 12:52:56 +0200 Subject: [PATCH] max dist for ptracks --- html/planeObject.js | 5 +++-- html/script.js | 10 ++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/html/planeObject.js b/html/planeObject.js index e97f438..4f48def 100644 --- a/html/planeObject.js +++ b/html/planeObject.js @@ -1319,10 +1319,11 @@ PlaneObject.prototype.processTrace = function() { PlaneObject.prototype.updatePositionData = function(now, last, data, init) { if (this.position && SitePosition) { - if (pTracks && this.sitedist) + if (pTracks && this.sitedist) { this.sitedist = Math.max(ol.sphere.getDistance(SitePosition, this.position), this.sitedist); - else + } else { this.sitedist = ol.sphere.getDistance(SitePosition, this.position); + } } if (!globeIndex || this.selected || SelectedAllPlanes || replay) { diff --git a/html/script.js b/html/script.js index 545816b..ae4c31c 100644 --- a/html/script.js +++ b/html/script.js @@ -629,6 +629,7 @@ function initialize() { if (receiverJson.lat != null) { SiteLat = receiverJson.lat; SiteLon = receiverJson.lon; + SitePosition = [SiteLon, SiteLat]; DefaultCenterLat = receiverJson.lat; DefaultCenterLon = receiverJson.lon; } @@ -1780,7 +1781,7 @@ function parseHistory() { for (let i in g.planesOrdered) { let plane = g.planesOrdered[i]; - if (plane.position && SitePosition) + if (plane.position && SitePosition && !pTracks) plane.sitedist = ol.sphere.getDistance(SitePosition, plane.position); if (uatNoTISB && plane.uat && plane.type && plane.type.substring(0,4) == "tisb") { @@ -3239,14 +3240,15 @@ function refreshSelected() { jQuery('#selected_position').updateText(format_latlng(selected.position)); } } + let sitedist; if (selected.position && SitePosition) { - selected.sitedist = ol.sphere.getDistance(SitePosition, selected.position); + sitedist = ol.sphere.getDistance(SitePosition, selected.position); } jQuery('#selected_source').updateText(format_data_source(selected.dataSource)); jQuery('#selected_category').updateText(selected.category ? selected.category : "n/a"); jQuery('#selected_category_label').updateText(get_category_label(selected.category)); - jQuery('#selected_sitedist1').updateText(format_distance_long(selected.sitedist, DisplayUnits)); - jQuery('#selected_sitedist2').updateText(format_distance_long(selected.sitedist, DisplayUnits)); + jQuery('#selected_sitedist1').updateText(format_distance_long(sitedist, DisplayUnits)); + jQuery('#selected_sitedist2').updateText(format_distance_long(sitedist, DisplayUnits)); jQuery('#selected_rssi1').updateText(selected.rssi != null ? selected.rssi.toFixed(1) : "n/a"); if (globeIndex && binCraft && !showTrace) { jQuery('#selected_message_count').prev().updateText('Receivers:');