fix: correctly formatted ads-b exchange data
This commit is contained in:
@@ -25,6 +25,8 @@ export async function getOpenskyData() {
|
|||||||
|
|
||||||
export async function getAdbsExchangeData({ lat, lon, radius }) {
|
export async function getAdbsExchangeData({ lat, lon, radius }) {
|
||||||
const positionSourceMap = ['Unknown', 'Mode-S', 'ADS-B', 'ADS-B', 'ADS-B', 'ADS-B'];
|
const positionSourceMap = ['Unknown', 'Mode-S', 'ADS-B', 'ADS-B', 'ADS-B', 'ADS-B'];
|
||||||
|
const formatNumber = str => str && Number(`${str}`.replace(/[^0-9.-]/, ''));
|
||||||
|
|
||||||
const res = await fetch.get(
|
const res = await fetch.get(
|
||||||
`http://public-api.adsbexchange.com/VirtualRadar/AircraftList.json?lat=${lat}&lng=${lon}&fDstL=0&fDstU=${radius}`
|
`http://public-api.adsbexchange.com/VirtualRadar/AircraftList.json?lat=${lat}&lng=${lon}&fDstL=0&fDstU=${radius}`
|
||||||
);
|
);
|
||||||
@@ -38,11 +40,11 @@ export async function getAdbsExchangeData({ lat, lon, radius }) {
|
|||||||
location: rec.Lat && rec.Long ? `${rec.Lat},${rec.Long}` : null,
|
location: rec.Lat && rec.Long ? `${rec.Lat},${rec.Long}` : null,
|
||||||
lat: rec.Lat,
|
lat: rec.Lat,
|
||||||
lon: rec.Long,
|
lon: rec.Long,
|
||||||
baro_altitude: rec.Alt,
|
baro_altitude: formatNumber(rec.Alt),
|
||||||
geo_altitude: rec.Galt,
|
geo_altitude: formatNumber(rec.GAlt),
|
||||||
on_ground: rec.Gnd,
|
on_ground: rec.Gnd,
|
||||||
velocity: rec.Spd,
|
velocity: formatNumber(rec.Spd),
|
||||||
vertical_rate: rec.Vsi,
|
vertical_rate: formatNumber(rec.Vsi),
|
||||||
squawk: rec.Sqk,
|
squawk: rec.Sqk,
|
||||||
spi: false,
|
spi: false,
|
||||||
position_source: positionSourceMap[rec.Trt],
|
position_source: positionSourceMap[rec.Trt],
|
||||||
|
|||||||
Reference in New Issue
Block a user