diff --git a/client/src/services/airtraffic.ts b/client/src/services/airtraffic.ts index ad7ad70..7a91641 100644 --- a/client/src/services/airtraffic.ts +++ b/client/src/services/airtraffic.ts @@ -7,6 +7,7 @@ import { fromLonLat } from 'ol/proj' import { Style, Icon, Stroke } from 'ol/style' import { Vector as VectorLayer } from 'ol/layer' import { Vector as VectorSource } from 'ol/source' +import {adjustedInterval} from '@ztimson/utils'; const API = BASE + '/api' @@ -202,7 +203,7 @@ export class AirTrafficLayer { private shapes: any = null private data: any[] = [] private clickHandler: ((e: any) => void) | null = null - private refreshTimer: ReturnType | null = null + private refreshTimer: any = null; visible = false constructor(map: Map) { this.map = map } @@ -222,7 +223,7 @@ export class AirTrafficLayer { this._draw() this._attachClick() - this.refreshTimer = setInterval(async () => { + this.refreshTimer = adjustedInterval(async () => { await this._fetch() this._draw() this._refreshPopups() diff --git a/server/src/adsb.mjs b/server/src/adsb.mjs index 600ff40..ef2aa7b 100644 --- a/server/src/adsb.mjs +++ b/server/src/adsb.mjs @@ -46,7 +46,7 @@ async function importAircraftDb() { const insert = db.prepare(`INSERT OR REPLACE INTO aircraft(icao, reg, type_code, flags, desc) VALUES (?,?,?,?,?)`); const run = db.transaction((rows) => { for(const [icao, a] of Object.entries(rows)) { - insert.run(icao.toUpperCase(), a.r || null, a.t || null, a.f || null, a.desc || null); + insert.run(icao.toUpperCase().padStart(6, '0'), reg || null, type_code || null, flags || null, desc || null); total++; } });