Compare commits
5 Commits
4de052ef0d
...
v2.1.0
| Author | SHA1 | Date | |
|---|---|---|---|
| c4870763a9 | |||
| 6591e7eaa8 | |||
| 58d405396e | |||
| f7523ae5e2 | |||
| 024a43e20b |
@@ -1,5 +1,12 @@
|
||||
### Changelog
|
||||
|
||||
#### [v2.1.0](https://git.w33ble.com/w33ble/adsb-index/compare/v2.0.1...v2.1.0) (2 November 2018)
|
||||
- feat: add raw version of text fields [`6591e7e`](https://git.w33ble.com/w33ble/adsb-index/commit/6591e7eaa8c9c317a55632f856310cdd3f783464)
|
||||
|
||||
#### [v2.0.1](https://git.w33ble.com/w33ble/adsb-index/compare/v2.0.0...v2.0.1) (2 November 2018)
|
||||
- fix: format undefined fields [`024a43e`](https://git.w33ble.com/w33ble/adsb-index/commit/024a43e20b7ebcf79ef5625df2021a41fa9b2ce9)
|
||||
- fix: exit on errors [`f7523ae`](https://git.w33ble.com/w33ble/adsb-index/commit/f7523ae5e20414dfec597050051566adbba9a310)
|
||||
|
||||
### [v2.0.0](https://git.w33ble.com/w33ble/adsb-index/compare/v1.0.1...v2.0.0) (2 November 2018)
|
||||
- feat: add ads-b exchange source [`9f0da54`](https://git.w33ble.com/w33ble/adsb-index/commit/9f0da54ccfc639ec6367ea85ec39bea117fd3108)
|
||||
- feat: use ads-b exchange data [`89261d0`](https://git.w33ble.com/w33ble/adsb-index/commit/89261d0010315ad248dcfdcf25916d952de648d8)
|
||||
|
||||
@@ -42,7 +42,7 @@ async function run() {
|
||||
// scheduled running
|
||||
if (interval === 0) return;
|
||||
logger.debug(`Starting interval (${interval}s)...`);
|
||||
runInterval(fetchAndIndex, interval * 1000);
|
||||
runInterval(() => fetchAndIndex().catch(handleError), interval * 1000);
|
||||
}
|
||||
|
||||
run().catch(handleError);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "adsb-index",
|
||||
"version": "2.0.0",
|
||||
"version": "2.1.0",
|
||||
"private": true,
|
||||
"description": "ADS-B indexing script",
|
||||
"bin": "bin/index.js",
|
||||
|
||||
@@ -26,8 +26,8 @@ export async function createIndex(client, index) {
|
||||
mappings: {
|
||||
[doctype]: {
|
||||
properties: {
|
||||
operator: { type: 'keyword' },
|
||||
aircraft: { type: 'text' },
|
||||
operator: { type: 'text', fields: { raw: { type: 'keyword' } } },
|
||||
aircraft: { type: 'text', fields: { raw: { type: 'keyword' } } },
|
||||
aircraft_manufacturer: { type: 'keyword' },
|
||||
transponder: { type: 'keyword' },
|
||||
callsign: { type: 'keyword' },
|
||||
@@ -45,8 +45,8 @@ export async function createIndex(client, index) {
|
||||
squawk: { type: 'keyword' },
|
||||
spi: { type: 'boolean' },
|
||||
position_source: { type: 'keyword' },
|
||||
from: { type: 'text' },
|
||||
to: { type: 'text' },
|
||||
from: { type: 'text', fields: { raw: { type: 'keyword' } } },
|
||||
to: { type: 'text', fields: { raw: { type: 'keyword' } } },
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
import fetch from './fetch.mjs';
|
||||
|
||||
const formatNumber = str => str && Number(`${str}`.replace(/[^0-9.-]/, ''));
|
||||
const formatString = str => {
|
||||
if (str == null) return 'N/A';
|
||||
if (typeof str !== 'string') return str;
|
||||
return str && str.length && str !== 'undefined' ? str.trim() : 'N/A';
|
||||
};
|
||||
|
||||
export async function getOpenskyData() {
|
||||
const positionSourceMap = ['ADS-B', 'ASTERIX', 'MLAT'];
|
||||
const res = await fetch.get(`https://opensky-network.org/api/states/all`);
|
||||
@@ -25,15 +32,14 @@ export async function getOpenskyData() {
|
||||
|
||||
export async function getAdbsExchangeData({ lat, lon, radius }) {
|
||||
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(
|
||||
`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(),
|
||||
transponder: formatString(`${rec.Icao}`.toLowerCase()),
|
||||
callsign: formatString(rec.Call),
|
||||
origin_country: rec.Cou,
|
||||
time_position: new Date(rec.PosTime),
|
||||
last_contact: new Date(rec.PosTime),
|
||||
@@ -48,10 +54,10 @@ export async function getAdbsExchangeData({ lat, lon, radius }) {
|
||||
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,
|
||||
operator: formatString(rec.Op),
|
||||
aircraft: formatString(rec.Mdl),
|
||||
aircraft_manufacturer: formatString(rec.Man),
|
||||
from: formatString(rec.From),
|
||||
to: formatString(rec.To),
|
||||
}));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user