From 688552d0d3171aab079b65d8c70c1ff90d96db43 Mon Sep 17 00:00:00 2001 From: ztimson Date: Fri, 11 Sep 2026 10:36:33 -0400 Subject: [PATCH] Fixed plane trace history --- client/src/services/adsb.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/client/src/services/adsb.ts b/client/src/services/adsb.ts index d67c1af..c89c8c7 100644 --- a/client/src/services/adsb.ts +++ b/client/src/services/adsb.ts @@ -116,9 +116,9 @@ export class AirTrafficLayer { const j = await fetch(`${API}/adsb/${icao}`).then(r => r.json()) this.historyCache[icao] = j.history || [] } - const history = [...this.historyCache[icao]] - const cur = { latitude: plane.latitude, longitude: plane.longitude, altitude: plane.alt_baro ?? plane.alt_geom ?? 0 } - const last = history[history.length - 1] + const history = this.historyCache[icao] + const cur = { latitude: plane.latitude, longitude: plane.longitude, altitude: plane.alt_baro ?? plane.alt_geom ?? 0 } + const last = history[history.length - 1] if (!last || last.latitude !== cur.latitude || last.longitude !== cur.longitude) history.push(cur) if (history.length < 2) return @@ -133,11 +133,12 @@ export class AirTrafficLayer { this.traceSegs[icao] = [] } else { vs = traceLayer.getSource()! - ;(this.traceSegs[icao] || []).forEach(f => vs.removeFeature(f)) } - const segs: Feature[] = [] - for (let i = 0; i < history.length - 1; i++) { + // Only draw segments that haven't been drawn yet + const segs = this.traceSegs[icao] + const start = segs.length + for (let i = start; i < history.length - 1; i++) { const s = history[i], e = history[i + 1] const sc = getAltColor(s.altitude || 0) const ec = getAltColor(e.altitude || 0) @@ -147,7 +148,6 @@ export class AirTrafficLayer { vs.addFeature(f) segs.push(f) } - this.traceSegs[icao] = segs } private _calcPopupPos(plane: any): { x: number; y: number } {