Fixed plane trace history
This commit is contained in:
@@ -116,7 +116,7 @@ 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 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)
|
||||
@@ -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 = <any>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 } {
|
||||
|
||||
Reference in New Issue
Block a user