feat: add ads-b exchange source
This commit is contained in:
@@ -26,6 +26,9 @@ export async function createIndex(client, index) {
|
|||||||
mappings: {
|
mappings: {
|
||||||
[doctype]: {
|
[doctype]: {
|
||||||
properties: {
|
properties: {
|
||||||
|
operator: { type: 'keyword' },
|
||||||
|
aircraft: { type: 'text' },
|
||||||
|
aircraft_manufacturer: { type: 'keyword' },
|
||||||
transponder: { type: 'keyword' },
|
transponder: { type: 'keyword' },
|
||||||
callsign: { type: 'keyword' },
|
callsign: { type: 'keyword' },
|
||||||
origin_country: { type: 'keyword' },
|
origin_country: { type: 'keyword' },
|
||||||
@@ -42,6 +45,8 @@ export async function createIndex(client, index) {
|
|||||||
squawk: { type: 'keyword' },
|
squawk: { type: 'keyword' },
|
||||||
spi: { type: 'boolean' },
|
spi: { type: 'boolean' },
|
||||||
position_source: { type: 'keyword' },
|
position_source: { type: 'keyword' },
|
||||||
|
from: { type: 'text' },
|
||||||
|
to: { type: 'text' },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
|
||||||
export default axios.create({
|
export default axios.create({
|
||||||
timeout: 3000,
|
timeout: 5000,
|
||||||
responseType: 'json',
|
responseType: 'json',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json; charset=utf-8',
|
'Content-Type': 'application/json; charset=utf-8',
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
import fetch from './fetch.mjs';
|
import fetch from './fetch.mjs';
|
||||||
|
|
||||||
const positionSourceMap = ['ADS-B', 'ASTERIX', 'MLAT'];
|
|
||||||
|
|
||||||
export async function getOpenskyData() {
|
export async function getOpenskyData() {
|
||||||
|
const positionSourceMap = ['ADS-B', 'ASTERIX', 'MLAT'];
|
||||||
const res = await fetch.get(`https://opensky-network.org/api/states/all`);
|
const res = await fetch.get(`https://opensky-network.org/api/states/all`);
|
||||||
return res.data.states.map(rec => ({
|
return res.data.states.map(rec => ({
|
||||||
transponder: `${rec[0]}`.toLowerCase(),
|
transponder: `${rec[0]}`.toLowerCase(),
|
||||||
@@ -23,3 +22,34 @@ export async function getOpenskyData() {
|
|||||||
position_source: positionSourceMap[rec[16]],
|
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