Test radiosonde.mjs
This commit is contained in:
@@ -218,14 +218,22 @@ export class AirTrafficLayer {
|
||||
|
||||
const history = this.historyCache[icao];
|
||||
const cur = {
|
||||
ts: Math.floor(Date.now() / 1000),
|
||||
latitude: plane.latitude,
|
||||
longitude: plane.longitude,
|
||||
altitude: plane.alt_baro ?? plane.alt_geom ?? 0,
|
||||
live: true,
|
||||
};
|
||||
|
||||
const last = history[history.length - 1];
|
||||
if (!last || last.latitude !== cur.latitude || last.longitude !== cur.longitude) history.push(cur);
|
||||
if (history.length < 2) return;
|
||||
|
||||
const traceHistory = history;
|
||||
if (traceHistory.length < 2) {
|
||||
const popup = this.popups[icao];
|
||||
if (popup) popup.update(plane, history);
|
||||
return;
|
||||
}
|
||||
|
||||
let traceLayer = this.traceLayers[icao];
|
||||
let vs: VectorSource;
|
||||
@@ -242,8 +250,8 @@ export class AirTrafficLayer {
|
||||
|
||||
const segs: any = this.traceSegs[icao];
|
||||
|
||||
for (let i = segs.length; i < history.length - 1; i++) {
|
||||
const s = history[i], e = history[i + 1];
|
||||
for (let i = segs.length; i < traceHistory.length - 1; i++) {
|
||||
const s = traceHistory[i], e = traceHistory[i + 1];
|
||||
const sc = getAltColor(s.altitude || 0), ec: any = getAltColor(e.altitude || 0);
|
||||
const avg = sc.map((v, idx) => Math.round((v + ec[idx]) / 2));
|
||||
|
||||
@@ -262,6 +270,9 @@ export class AirTrafficLayer {
|
||||
vs.addFeature(f);
|
||||
segs.push(f);
|
||||
}
|
||||
|
||||
const popup = this.popups[icao];
|
||||
if (popup) popup.update(plane, history);
|
||||
}
|
||||
|
||||
private _openPopup(plane: any) {
|
||||
@@ -272,8 +283,9 @@ export class AirTrafficLayer {
|
||||
document.body.appendChild(container);
|
||||
|
||||
const mobile = window.innerWidth <= 768;
|
||||
const makeProps = (p: any) => ({
|
||||
const makeProps = (p: any, history: any[] = []) => ({
|
||||
plane: p,
|
||||
history,
|
||||
position: mobile
|
||||
? {x: window.innerWidth / 2 - 180, y: window.innerHeight - 540 - 16}
|
||||
: {x: 16, y: 16},
|
||||
@@ -281,10 +293,10 @@ export class AirTrafficLayer {
|
||||
onBringToFront: () => bringToFront(container),
|
||||
});
|
||||
|
||||
vueRender(h(AircraftPopup, makeProps(plane)), container);
|
||||
vueRender(h(AircraftPopup, makeProps(plane, this.historyCache[icao] || [])), container);
|
||||
|
||||
this.popups[icao] = {
|
||||
update: (p: any) => vueRender(h(AircraftPopup, makeProps(p)), container),
|
||||
update: (p: any, history: any[] = []) => vueRender(h(AircraftPopup, makeProps(p, history)), container),
|
||||
unmount: () => {
|
||||
vueRender(null, container);
|
||||
container.remove();
|
||||
@@ -322,7 +334,6 @@ export class AirTrafficLayer {
|
||||
continue;
|
||||
}
|
||||
|
||||
this.popups[icao].update(plane);
|
||||
this._fetchTrace(plane);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,7 +176,7 @@ export class SondesLayer {
|
||||
marker.setStyle(new Style({
|
||||
image: new Icon({
|
||||
src: '/sonde.png',
|
||||
scale: 0.15,
|
||||
scale: 0.1,
|
||||
anchor: [0.5, 0.5],
|
||||
}),
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user