feat: add ads-b exchange source
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
import fetch from './fetch.mjs';
|
||||
|
||||
const positionSourceMap = ['ADS-B', 'ASTERIX', 'MLAT'];
|
||||
|
||||
export async function getOpenskyData() {
|
||||
const positionSourceMap = ['ADS-B', 'ASTERIX', 'MLAT'];
|
||||
const res = await fetch.get(`https://opensky-network.org/api/states/all`);
|
||||
return res.data.states.map(rec => ({
|
||||
transponder: `${rec[0]}`.toLowerCase(),
|
||||
@@ -23,3 +22,34 @@ export async function getOpenskyData() {
|
||||
position_source: positionSourceMap[rec[16]],
|
||||
}));
|
||||
}
|
||||
|
||||
export async function getAdbsExchangeData({ lat, lon, radius }) {
|
||||
const positionSourceMap = ['Unknown', 'Mode-S', 'ADS-B', 'ADS-B', 'ADS-B', 'ADS-B'];
|
||||
const res = await fetch.get(
|
||||
`http://public-api.adsbexchange.com/VirtualRadar/AircraftList.json?lat=${lat}&lng=${lon}&fDstL=0&fDstU=${radius}`
|
||||
);
|
||||
|
||||
return res.data.acList.map(rec => ({
|
||||
transponder: `${rec.Icao}`.toLowerCase(),
|
||||
callsign: `${rec.Call}`.trim(),
|
||||
origin_country: rec.Cou,
|
||||
time_position: new Date(rec.PosTime),
|
||||
last_contact: new Date(rec.PosTime),
|
||||
location: rec.Lat && rec.Long ? `${rec.Lat},${rec.Long}` : null,
|
||||
lat: rec.Lat,
|
||||
lon: rec.Long,
|
||||
baro_altitude: rec.Alt,
|
||||
geo_altitude: rec.Galt,
|
||||
on_ground: rec.Gnd,
|
||||
velocity: rec.Spd,
|
||||
vertical_rate: rec.Vsi,
|
||||
squawk: rec.Sqk,
|
||||
spi: false,
|
||||
position_source: positionSourceMap[rec.Trt],
|
||||
operator: rec.Op,
|
||||
aircraft: rec.Mdl,
|
||||
aircraft_manufacturer: rec.Man,
|
||||
from: rec.From,
|
||||
to: rec.To,
|
||||
}));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user